Skip to content

Commit

Permalink
Adopt nox for testing against python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbrittain committed Oct 9, 2024
1 parent 34633be commit 8733839
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ jobs:
3.12
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2

- name: Setup test environment
run: |
uv sync --all-extras
uv pip install "adtl[parquet] @ git+https://github.com/globaldothealth/adtl"
- name: Unit tests (and coverage report)
- name: Run unit tests
run: |
uv run pytest --cov=InsightBoard --cov-report=html tests/unit
- name: System tests
uvx nox -s unit_tests
- name: Run system tests
run: |
uv run pytest tests/system
uvx nox -s system_tests
- name: Upload coverage report
uses: actions/upload-artifact@v4
Expand All @@ -58,7 +52,7 @@ jobs:
echo "" >> $GITHUB_STEP_SUMMARY
echo '<img src="data:image/png;base64,'$(cat screenshot_base64.txt)'" alt="Screenshot"/>' >> $GITHUB_STEP_SUMMARY
fi
- name: Upload screenshot as artifact
- name: Upload screenshot as artifact (on system test failure)
if: failure()
uses: actions/upload-artifact@v3
with:
Expand Down
45 changes: 45 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import nox

PYTHON_VERSIONS = ["3.11", "3.12"]


@nox.session(python=PYTHON_VERSIONS, venv_backend="uv")
def unit_tests(session):
"""Unit tests (with coverage)"""
session.env.update({"UV_PROJECT_ENVIRONMENT": session.virtualenv.location})
session.run(
"uv",
"sync",
"--all-extras",
)
session.run(
"uv",
"run",
"pytest",
"--cov=InsightBoard",
"--cov-report=html",
"tests/unit",
)


@nox.session(python=PYTHON_VERSIONS, venv_backend="uv")
def system_tests(session):
"""System tests"""
session.env.update({"UV_PROJECT_ENVIRONMENT": session.virtualenv.location})
session.run(
"uv",
"sync",
"--all-extras",
)
session.run(
"uv",
"pip",
"install",
"adtl[parquet] @ git+https://github.com/globaldothealth/adtl",
)
session.run(
"uv",
"run",
"pytest",
"tests/system",
)

0 comments on commit 8733839

Please sign in to comment.