Skip to content

Commit

Permalink
Merge pull request #106 from swryan/hatchling
Browse files Browse the repository at this point in the history
Change build system to hatchling; added a test workflow
  • Loading branch information
swryan authored Mar 13, 2024
2 parents b4ecce0 + 7e9eece commit b59e961
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 55 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Test testflo

on:
# Trigger on push or pull request events for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allow running the workflow manually from the Actions tab
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

permissions: {}

jobs:

tests:

timeout-minutes: 20

strategy:
fail-fast: false
matrix:
include:
# test on Ubuntu
- NAME: Ubuntu Baseline
OS: ubuntu-latest
PY: '3.11'

# test on MacOS
- NAME: MacOS Baseline
OS: macos-latest
PY: '3.11'

runs-on: ${{ matrix.OS }}

name: ${{ matrix.NAME }}

defaults:
run:
shell: bash -l {0}

steps:

- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PY }}

- name: Install testflo
run: |
python -m pip install --upgrade pip
python -m pip install .
# Enable tmate debugging of manually-triggered workflows if the input option was provided
#
# To access the terminal through the web-interface:
# 1. Click on the web-browser link printed out in this action from the github
# workflow terminal
# 2. Press cntrl + c in the new tab that opens up to reveal the terminal
# 3. To activate the conda environment run:
# $ source $CONDA/etc/profile.d/conda.sh
# $ conda activate test
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Run tests
run: |
cd $HOME
testflo testflo.tests || RC=$?
if [[ $RC -ne 1 ]]; then
echo "Expected some tests to fail."
exit 1
fi
if [[ ! -n `grep "Ran 26 tests" testflo_report.out` ]]; then
echo "Expected 26 tests."
exit 26
fi
if [[ ! -n `grep "Passed: 7" testflo_report.out` ]]; then
echo "Expected 7 tests to pass."
exit 7
fi
if [[ ! -n `grep "Failed: 8" testflo_report.out` ]]; then
echo "Expected 8 tests to fail."
exit 8
fi
if [[ ! -n `grep "Skipped: 11" testflo_report.out` ]]; then
echo "Expected 11 tests to be skipped."
exit 11
fi
- name: Run tests in serial
run: |
cd $HOME
testflo -n 1 testflo.tests || RC=$?
if [[ $RC -ne 1 ]]; then
echo "Expected some tests to fail."
exit 1
fi
if [[ ! -n `grep "Ran 26 tests using 1 processes" testflo_report.out` ]]; then
echo "Expected 26 tests on one process."
exit 26
fi
if [[ ! -n `grep "Passed: 7" testflo_report.out` ]]; then
echo "Expected 7 tests to pass."
exit 7
fi
if [[ ! -n `grep "Failed: 8" testflo_report.out` ]]; then
echo "Expected 8 tests to fail."
exit 8
fi
if [[ ! -n `grep "Skipped: 11" testflo_report.out` ]]; then
echo "Expected 11 tests to be skipped."
exit 11
fi
- name: Notify slack of failure
uses: act10ns/[email protected]
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ job.status }}
if: failure()
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "testflo"
dynamic = ["version"]
description = "A simple flow-based testing framework"
readme = "README.md"
license = "Apache-2.0"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = [
"setuptools",
"coverage>=6.0",
]

[project.scripts]
testflo = "testflo.main:main"

[tool.hatch.version]
path = "testflo/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/testflo",
]
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

Empty file added testflo/tests/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ def test_tcase_grouped_unexpected_success(self):

@unittest.skip("skipping 2")
def test_tcase_grouped_skip(self):
pass
self.fail("This test should have been skipped.")


@unittest.skip("skipping a whole testcase...")
class SkippedTestCase2(unittest.TestCase):
def test_1(self):
pass
self.fail("This test should have been skipped.")

def test_2(self):
pass
self.fail("This test should have been skipped.")

def test_3(self):
pass
self.fail("This test should have been skipped.")

def test_4(self):
pass
self.fail("This test should have been skipped.")
12 changes: 6 additions & 6 deletions testflo/test/test_testflo.py → testflo/tests/test_testflo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_env_var(self):
self.assertNotEqual(testflo_running, False)

def test_fail(self):
self.fail("failure 1")
self.fail("This test should fail")

@unittest.expectedFailure
def test_expected_fail_good(self):
Expand All @@ -24,7 +24,7 @@ def test_unexpected_success(self):

@unittest.skip("skipping 1")
def test_skip(self):
pass
self.fail("This test should have been skipped.")

class TestfloTestCaseWFixture(unittest.TestCase):

Expand Down Expand Up @@ -60,16 +60,16 @@ def test_tcase_grouped_skip(self):
@unittest.skip("skipping a whole testcase...")
class SkippedTestCase(unittest.TestCase):
def test_1(self):
pass
self.fail("This test should have been skipped.")

def test_2(self):
pass
self.fail("This test should have been skipped.")

def test_3(self):
pass
self.fail("This test should have been skipped.")

def test_4(self):
pass
self.fail("This test should have been skipped.")


class TestSubTests(unittest.TestCase):
Expand Down

0 comments on commit b59e961

Please sign in to comment.