From 02c6850fe9b75b956d8474a4c85c97a3794db000 Mon Sep 17 00:00:00 2001 From: priya-sundaram-dev Date: Fri, 28 Aug 2026 11:39:50 +0000 Subject: [PATCH] ci: single-source Python version via pyproject.toml + add uv-lock pre-commit hook (#15111) - Add astral-sh/uv-pre-commit (uv-lock) so uv.lock stays in sync with pyproject.toml automatically instead of relying on manual relocks. - Replace 'python-version: 3.14' with 'python-version-file: pyproject.toml' in every workflow that uses actions/setup-python (build, project_euler, sphinx, directory_writer), making requires-python the single source of truth for the interpreter version. --- .github/workflows/build.yml | 2 +- .github/workflows/directory_writer.yml | 2 +- .github/workflows/project_euler.yml | 4 ++-- .github/workflows/sphinx.yml | 2 +- .pre-commit-config.yaml | 5 +++++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 594369c6d..4ed88a88f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: cache-dependency-glob: uv.lock - uses: actions/setup-python@v7 with: - python-version: 3.14 + python-version-file: pyproject.toml allow-prereleases: true - run: uv sync --group=test - name: Run tests diff --git a/.github/workflows/directory_writer.yml b/.github/workflows/directory_writer.yml index 8b34f9799..9df64222c 100644 --- a/.github/workflows/directory_writer.yml +++ b/.github/workflows/directory_writer.yml @@ -11,7 +11,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@v7 with: - python-version: 3.14 + python-version-file: pyproject.toml allow-prereleases: true - name: Write DIRECTORY.md run: | diff --git a/.github/workflows/project_euler.yml b/.github/workflows/project_euler.yml index 73afb2e71..06f865f0b 100644 --- a/.github/workflows/project_euler.yml +++ b/.github/workflows/project_euler.yml @@ -25,7 +25,7 @@ jobs: - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v7 with: - python-version: 3.14 + python-version-file: pyproject.toml allow-prereleases: true - run: uv sync --group=euler-validate --group=test - run: uv run pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/ @@ -43,7 +43,7 @@ jobs: - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v7 with: - python-version: 3.14 + python-version-file: pyproject.toml allow-prereleases: true - run: uv sync --group=euler-validate --group=test - run: uv run pytest scripts/validate_solutions.py diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 45a74099f..3828bea0e 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -36,7 +36,7 @@ jobs: - uses: astral-sh/setup-uv@v7 - uses: actions/setup-python@v7 with: - python-version: 3.14 + python-version-file: pyproject.toml allow-prereleases: true - run: uv sync --group=docs - uses: actions/configure-pages@v6 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a5f50751..f884a38bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,11 @@ repos: hooks: - id: auto-walrus + - repo: https://github.com/astral-sh/uv-pre-commit + rev: 0.12.7 + hooks: + - id: uv-lock + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.16.1 hooks: