diff --git a/.github/workflows/code_changes.yaml b/.github/workflows/code_changes.yaml index 3ffa1b7d9a..2241a3dc59 100644 --- a/.github/workflows/code_changes.yaml +++ b/.github/workflows/code_changes.yaml @@ -80,7 +80,17 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v8.1.0 - name: Check formatting - run: uvx ruff format --check . + # With the ruff that uv.lock pins, so a new ruff release cannot change + # what Lint accepts until the lock is updated. + run: | + set -euo pipefail + ruff=$(uv export --frozen --extra dev --no-hashes --no-header | { grep -E '^ruff==' || true; } | cut -d' ' -f1) + if [ "$(printf '%s' "$ruff" | grep -c '^ruff==')" != 1 ]; then + echo "::error::uv.lock should pin exactly one ruff; found: ${ruff:-none}" + exit 1 + fi + echo "RUFF=$ruff" >> "$GITHUB_ENV" + uvx --from "$ruff" ruff format --check . - name: Lint # The ruff rules pyproject.toml selects, then two pyflakes rules it # ignores, checked in the package: F811, a definition that a later @@ -89,8 +99,8 @@ jobs: # notice 16), and F821, an undefined name. Neither has a finding # in the package today. run: | - uvx ruff check . - uvx ruff check --select F811,F821 policyengine_uk + uvx --from "$RUFF" ruff check . + uvx --from "$RUFF" ruff check --select F811,F821 policyengine_uk # The same suite as pull requests (test-suite.yaml), on the merged commit. Test: needs: Tested diff --git a/.github/workflows/pr_code_changes.yaml b/.github/workflows/pr_code_changes.yaml index e959391554..2f22d1ed82 100644 --- a/.github/workflows/pr_code_changes.yaml +++ b/.github/workflows/pr_code_changes.yaml @@ -110,7 +110,17 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v8.1.0 - name: Check formatting - run: uvx ruff format --check . + # With the ruff that uv.lock pins, so a new ruff release cannot change + # what Lint accepts until the lock is updated. + run: | + set -euo pipefail + ruff=$(uv export --frozen --extra dev --no-hashes --no-header | { grep -E '^ruff==' || true; } | cut -d' ' -f1) + if [ "$(printf '%s' "$ruff" | grep -c '^ruff==')" != 1 ]; then + echo "::error::uv.lock should pin exactly one ruff; found: ${ruff:-none}" + exit 1 + fi + echo "RUFF=$ruff" >> "$GITHUB_ENV" + uvx --from "$ruff" ruff format --check . - name: Lint # The ruff rules pyproject.toml selects, then two pyflakes rules it # ignores, checked in the package: F811, a definition that a later @@ -119,8 +129,8 @@ jobs: # notice 16), and F821, an undefined name. Neither has a finding # in the package today. run: | - uvx ruff check . - uvx ruff check --select F811,F821 policyengine_uk + uvx --from "$RUFF" ruff check . + uvx --from "$RUFF" ruff check --select F811,F821 policyengine_uk - name: No agent working notes at the repository root # Agent jobs keep their working notes at the root of their # worktree, and #2376's REPORT.md and PROGRESS.md reached main by @@ -150,16 +160,10 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v6 - - name: Install uv - uses: astral-sh/setup-uv@v8.1.0 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - name: Install package - run: uv pip install -e .[dev] --system - - name: Install policyengine - run: uv pip install policyengine --system + # The environment the tests use: uv.lock with the dev extra (which + # includes jupyter-book), so a new release cannot change the build. + - name: Install the locked environment + uses: ./.github/actions/test-environment - name: Test documentation builds run: make documentation # The YAML tests, the Python tests on five runners, and the check that diff --git a/.github/workflows/pr_docs_changes.yaml b/.github/workflows/pr_docs_changes.yaml index f3468523a3..09f7d5cad6 100644 --- a/.github/workflows/pr_docs_changes.yaml +++ b/.github/workflows/pr_docs_changes.yaml @@ -26,19 +26,9 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v6 - - name: Install uv - uses: astral-sh/setup-uv@v8.1.0 - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - - name: Install package - run: uv pip install -e .[dev] --system - - name: Install policyengine - run: uv pip install policyengine --system - - name: Install JB - run: uv pip install "jupyter-book>=2.0.0a0" --system + # The environment the tests use: uv.lock with the dev extra (which + # includes jupyter-book), so a new release cannot change the build. + - name: Install the locked environment + uses: ./.github/actions/test-environment - name: Test documentation builds run: make documentation \ No newline at end of file diff --git a/.github/workflows/versioning.yaml b/.github/workflows/versioning.yaml index d929669041..c605d856e0 100644 --- a/.github/workflows/versioning.yaml +++ b/.github/workflows/versioning.yaml @@ -269,7 +269,17 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v8.1.0 - name: Check formatting - run: uvx ruff format --check . + # With the ruff that uv.lock pins, so a new ruff release cannot change + # what Lint accepts until the lock is updated. + run: | + set -euo pipefail + ruff=$(uv export --frozen --extra dev --no-hashes --no-header | { grep -E '^ruff==' || true; } | cut -d' ' -f1) + if [ "$(printf '%s' "$ruff" | grep -c '^ruff==')" != 1 ]; then + echo "::error::uv.lock should pin exactly one ruff; found: ${ruff:-none}" + exit 1 + fi + echo "RUFF=$ruff" >> "$GITHUB_ENV" + uvx --from "$ruff" ruff format --check . - name: Lint # The ruff rules pyproject.toml selects, then two pyflakes rules it # ignores, checked in the package: F811, a definition that a later @@ -278,8 +288,8 @@ jobs: # notice 16), and F821, an undefined name. Neither has a finding # in the package today. run: | - uvx ruff check . - uvx ruff check --select F811,F821 policyengine_uk + uvx --from "$RUFF" ruff check . + uvx --from "$RUFF" ruff check --select F811,F821 policyengine_uk Compat: # What a user gets: the wheel, with the newest dependencies it allows, diff --git a/changelog.d/ci-lint-docs-from-lock.fixed.md b/changelog.d/ci-lint-docs-from-lock.fixed.md new file mode 100644 index 0000000000..f631b550c1 --- /dev/null +++ b/changelog.d/ci-lint-docs-from-lock.fixed.md @@ -0,0 +1 @@ +- Lint and the documentation build now install from uv.lock, as the tests already do, so a new release of ruff, jupyter-book or another dependency cannot change what pull requests are checked against.