From 956bb71629d44d3c2eb5c54b37b5aa503190a122 Mon Sep 17 00:00:00 2001 From: Josh Thomas Date: Thu, 10 Oct 2024 16:53:46 -0500 Subject: [PATCH] set python version in nox sessions when syncing uv (#138) --- .github/workflows/test.yml | 19 +++---------------- noxfile.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b80a8fb..aa851c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,6 @@ concurrency: env: PYTHONUNBUFFERED: "1" FORCE_COLOR: "1" - PY_MAX_VERSION: "3.13" - PY_MIN_VERSION: "3.9" UV_VERSION: "0.4.x" jobs: @@ -31,9 +29,6 @@ jobs: enable-cache: true version: ${{ env.UV_VERSION }} - - name: Install Python - run: uv python install ${{ env.PY_MIN_VERSION }} - - id: set-matrix run: | uv run nox --session "gha_matrix" @@ -54,9 +49,6 @@ jobs: enable-cache: true version: ${{ env.UV_VERSION }} - - name: Install Python - run: uv python install ${{ matrix.python-version }} - - name: Run tests run: | uv run nox --session "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')" @@ -77,16 +69,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install uv uses: astral-sh/setup-uv@v3 with: enable-cache: true version: ${{ env.UV_VERSION }} - - name: Install Python - run: uv python install ${{ env.PY_MAX_VERSION }} - - - name: Run mypy + - name: Run type checks run: | uv run nox --session "types" @@ -101,9 +91,6 @@ jobs: enable-cache: true version: ${{ env.UV_VERSION }} - - name: Install Python - run: uv python install ${{ env.PY_MIN_VERSION }} - - - name: Run mypy + - name: Generate code coverage run: | uv run nox --session "coverage" diff --git a/noxfile.py b/noxfile.py index 0a72646..7869e6c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -71,12 +71,14 @@ def tests(session, django): session.run_install( "uv", "sync", - "--frozen", "--extra", "tests", + "--frozen", "--inexact", "--no-install-package", "django", + "--python", + session.python, env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, ) @@ -98,9 +100,11 @@ def coverage(session): session.run_install( "uv", "sync", - "--frozen", "--extra", "tests", + "--frozen", + "--python", + PY_LATEST, env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, ) @@ -129,9 +133,11 @@ def types(session): session.run_install( "uv", "sync", - "--frozen", "--extra", "types", + "--frozen", + "--python", + PY_LATEST, env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, ) command = ["python", "-m", "mypy", "."] @@ -145,9 +151,11 @@ def demo(session): session.run_install( "uv", "sync", - "--frozen", "--extra", "types", + "--frozen", + "--python", + PY_DEFAULT, env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, )