From 22f5873f81e4e1d5a5508c0cfed14e68f4b244af Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Mon, 4 Nov 2024 22:20:34 -0500 Subject: [PATCH 1/2] GitHub Actions pytest workflow now uses uv instead of nox --- .github/workflows/build.yml | 32 ++++++++++++++++++-------------- noxfile.py | 25 ------------------------- pyproject.toml | 1 - tasks.py | 13 +------------ 4 files changed, 19 insertions(+), 52 deletions(-) delete mode 100644 noxfile.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bbc482e..dd290214 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,29 +2,33 @@ # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions name: "build" -on: [ push, pull_request ] +on: [push, pull_request] jobs: build: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 # https://github.com/actions/checkout + - uses: actions/checkout@v4 # https://github.com/actions/checkout with: # Only a single commit is fetched by default, for the ref/SHA that triggered the workflow. # Set fetch-depth: 0 to fetch all history for all branches and tags. fetch-depth: 0 # Needed for setuptools_scm to work correctly - - uses: actions/setup-python@v5 # https://github.com/actions/setup-python - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - - name: Install dependencies - run: python -m pip install --upgrade pip setuptools setuptools-scm nox - - name: Run tests and post coverage results - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python -m nox --non-interactive --session tests-${{ matrix.python-version }} # Run nox for a single version of Python + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Run tests + run: uv run inv pytest --junit --no-pty --base + + - name: Run isolated tests + run: uv run inv pytest --junit --no-pty --isolated diff --git a/noxfile.py b/noxfile.py deleted file mode 100644 index 88045f24..00000000 --- a/noxfile.py +++ /dev/null @@ -1,25 +0,0 @@ -import nox - - -@nox.session(python=['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']) -@nox.parametrize('plugin', [None, 'ext_test', 'template', 'coverage']) -def tests(session, plugin): - if plugin is None: - session.install('invoke', './[test]') - session.run('invoke', 'pytest', '--junit', '--no-pty', '--base') - session.install('./plugins/ext_test/') - session.run('invoke', 'pytest', '--junit', '--no-pty', '--isolated') - elif plugin == 'coverage': - session.install('invoke', 'codecov', 'coverage') - session.run('codecov') - else: - session.install('invoke', './', 'plugins/{}[test]'.format(plugin)) - - # cd into test directory to run other unit test - session.run( - 'invoke', - 'plugin.{}.pytest'.format(plugin.replace('_', '-')), - '--junit', - '--no-pty', - '--append-cov', - ) diff --git a/pyproject.toml b/pyproject.toml index 57c36c6a..6ad87239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,6 @@ dev = [ "doc8", "invoke", "mypy", - "nox", "pytest", "pytest-cov", "pytest-mock", diff --git a/tasks.py b/tasks.py index 6b2d5a03..e4ea17df 100644 --- a/tasks.py +++ b/tasks.py @@ -49,7 +49,7 @@ def rmrf(items, verbose=True): ##### # -# pytest, nox, pylint, and codecov +# pytest, pylint, and codecov # ##### @@ -117,17 +117,6 @@ def mypy_clean(context): namespace_clean.add_task(mypy_clean, 'mypy') -@invoke.task -def nox_clean(context): - """Remove nox virtualenvs and logs""" - # pylint: disable=unused-argument - with context.cd(TASK_ROOT_STR): - rmrf('.nox') - - -namespace_clean.add_task(nox_clean, 'nox') - - ##### # # documentation From 518dded36e42409fef0d2a6b4facec8f3617f5b7 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Mon, 4 Nov 2024 22:30:52 -0500 Subject: [PATCH 2/2] Install Python from GitHubActions instead of uv --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd290214..3f66f7f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,10 @@ jobs: uses: astral-sh/setup-uv@v3 - name: Set up Python ${{ matrix.python-version }} - run: uv python install ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install the project run: uv sync --all-extras --dev