Skip to content

chore(hooks): install the latest stable Python from .python-version with mise - #247

Merged
DevSecNinja merged 1 commit into
devsecninja-lint-workflow-v3from
devsecninja-python-version-source
Nov 16, 2026
Merged

DevSecNinja merged 1 commit into
devsecninja-lint-workflow-v3from
devsecninja-python-version-source

Conversation

@DevSecNinja

@DevSecNinja DevSecNinja commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

.python-version is the single source for the Python the git hooks and CI use. It holds the latest stable Python minor that has been out for 90 days, mise installs it for every contributor, and Renovate moves it forward automatically. It is currently 3.14: 3.15 was released on 2026-10-09 and is only 38 days old.

  • .python-version → 3.14 (major.minor). mise installs the latest patch of that minor, so patch releases need no PR.
  • .mise.toml: [settings] idiomatic_version_file_enable_tools = ["python"], so mise install installs Python from .python-version. It is a mise idiomatic version file, with no second pin in [tools]. On Windows mise downloads a prebuilt CPython: it installed cpython-3.14.10 … aarch64-pc-windows-msvc here. The Dev Container's mise install picks it up too.
  • scripts/py.sh tries mise's Python first (mise -C <repo> which python, which works without mise activate). Otherwise it uses the first of python3, py -3 and python that is at least that version, skipping the Microsoft Store stub. When nothing fits, the error says to run mise install. It still parses .python-version with shell builtins and rejects malformed values.
  • CI: Windows Hooks installs Python with mise (install_args: lefthook python), just as a contributor would, and setup-python and the PY_PYTHON3 workaround are gone. Markdown Validation's test job now runs on the same Python through setup-python's python-version-file, instead of ubuntu-latest's python3.
  • Renovate: tracks the latest stable minor with minimumReleaseAge: "90 days" in its own PR (groupName: null), outside the weekly non-major group. The shared autoMerge preset merges it once CI passes, and a Python 4 major would stay manual like every other major. The pyenv manager normally looks Python up as the python Docker image, but tags like 3.14 are re-pushed with every patch and image rebuild, so their timestamp never ages 90 days. overrideDatasource: endoflife-date uses endoflife.date instead, which dates each minor by its x.y.0 release (releaseDate; Renovate's datasource reports releaseTimestampSupport). extractVersion turns its latest value (3.14.10) into the minor (3.14), so docker versioning compares like with like.
  • tests/test_py_launcher.py: uses a fake mise to test that mise's Python is preferred and that the launcher falls back when mise's is missing or too old. Single-source checks fail if:
    • .python-version isn't major.minor;
    • py.sh hard-codes a version;
    • .mise.toml stops reading the file or pins Python in [tools];
    • Windows CI stops installing Python with mise;
    • any actions/setup-python step uses something other than python-version-file: .python-version.
  • CONTRIBUTING explains where the version lives, the 90-day policy, and running mise install after a bump.

Stack

Stacked on #256 (lint workflow v3.7.1 + pipx:yamllint: the old shared lint jobs install pipx: tools without the configured Python, so they fail here) and #252 (hook-fixture isolation, #251), which was split out of this PR because it's urgent: main's hook fixtures wrote core.bare = true to the main checkout's config. Order: #252 ← #256 ← this PR.

Validation (native Windows ARM64, no WSL)

Each check ran in a fresh testing context, separate from implementation. The hooks used the user's mise Python 3.14.8. The fresh-contributor flow used a throwaway MISE_DATA_DIR and was deleted afterwards. Nothing was installed system-wide.

Check Result
py.sh picks mise's Python (…\mise\installs\python\3.14.8\python.exe) ✅
Empty mise data dir → mise: Python 3.14 not installed + "Run mise install"; after mise install python (3.14.10) py.sh picks it ✅
test_py_launcher.py ✅ 12/12
test_hook_git_env.py (from #252) ✅ 1/1
Mutations, each failing exactly its test: idiomatic setting removed; python pinned in [tools]; install_args without python; literal python-version: ✅
lefthook run pre-commit --all-files (10 hooks, incl. hook-git-env) ✅
shellcheck, shfmt, actionlint, yamlfmt, dprint, validate-prompts.sh ✅
zizmor ✅ (only the two existing artipacked findings on untouched markdown-validation.yml checkouts)

renovate-config-validator can't run locally (npm remote fetching is blocked). The rule only uses documented packageRules options: overrideDatasource, overridePackageName, extractVersion, minimumReleaseAge and groupName.

All commits are signed (1Password SSH) and passed every pre-commit hook.

Closes #246

@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 15, 2026 20:31
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd8ef0a5-eb5a-486d-a611-f58e08b31bad
Commits

Reviewing files that changed from the base of the PR and between 1b5e937 and 3ef974d.

Files selected for processing: 9

  • .github/workflows/markdown-validation.yml
  • .github/workflows/windows-hooks.yml
  • .lefthook.toml
  • .mise.toml
  • .python-version
  • CONTRIBUTING.md
  • renovate.json5
  • scripts/py.sh
  • tests/test_py_launcher.py

No actionable comments were generated in the recent review.

Walkthrough

The pull request makes .python-version the source for the minimum Python version used by the launcher and Windows Hooks workflow. It updates hook commands, tests, Renovate settings, workflow triggers, and contributor documentation.

Changes: Python version and hooks

Layer / File(s) Summary
Version file and launcher validation
.python-version, scripts/py.sh, tests/test_py_launcher.py
The launcher reads and validates the major and minor version in .python-version. Tests cover accepted formats, missing or malformed values, and the launcher’s version checks.
Workflow and hook integration
.github/workflows/windows-hooks.yml, .github/workflows/markdown-validation.yml, .lefthook.toml, tests/test_apm_external_skills.py
The Windows Hooks workflow reads the version file and sets PY_PYTHON3 from the resolved version. Workflow triggers and the external-skills hook command are updated. Tests remove inherited Git variables and check that a decoy repository receives no commit.
Version update settings and contributor guidance
renovate.json5, CONTRIBUTING.md
Renovate tracks .python-version updates for manual merging. Contributor guidance describes the version minimum and related launcher, workflow, and tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Merge Risk: Minimal · previous review 1b5e9

This change makes the minimum Python version come from a single file shared by the launcher and the Windows CI workflow, and it hardens the tests against inherited Git environment variables. No concrete problems were found, so the merge risk is minimal.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title names the change as installing the latest stable Python from .python-version with mise. The changeset does not do that. It makes .python-version (pinned to 3.12) the single source for the ho… Rewrite the title to describe the actual change. For example: "fix(hooks): use .python-version as the single source for minimum Python". Remove the claim about installing the latest stable Python and the mise tool, unless the changeset adds…
Passed Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed Issue #246 has four coding requirements. All are implemented at the reviewed head.

(1) Single source of truth [#246]: .python-version holds 3.12. scripts/py.sh reads the first non-comment line …
Out of Scope Changes check Passed Changes outside the literal text of #246 have a concrete connection to the hook Python minimum or to the hook test environment.

- .lefthook.toml: apm-external-skills now runs through `sh scripts/…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Linked Issues check

Explanation

Issue #246 has four coding requirements. All are implemented at the reviewed head.

(1) Single source of truth [#246]: .python-version holds 3.12. scripts/py.sh reads the first non-comment line and keeps major.minor, with no hard-coded minimum. .github/workflows/windows-hooks.yml uses python-version-file: .python-version, and PY_PYTHON3 derives from the setup-python output. The workflow no longer pins a literal.

(2) Renovate tracking [#246]: renovate.json5 adds a rule for matchManagers: ["pyenv"] and matchFileNames: [".python-version"]. It sets automerge: false, groupName: null, pinDigests: false, and addLabels: ["merge: manual"]. A comment states that the value is a floor, not "latest". Minor and major bumps are possible; patch bumps are not, because the value is major.minor.

(3) Consistency test [#246]: The PR adds MinimumPythonSourceTests in tests/test_py_launcher.py. Per the PR description and the raw summary, it fails when the file is not major.minor, when py.sh hard-codes the minimum, or when the workflow drops python-version-file or adds a literal. I did not open the test file. This conclusion relies on the PR description and summary.

(4) Documentation [#246]: CONTRIBUTING documents where the minimum lives and how it is enforced.

No unmet coding requirement is identified. Requirements about manual validation or the Renovate validator run are non-coding and were not assessed as objectives.

Full details: Out of Scope Changes check

Explanation

Changes outside the literal text of #246 have a concrete connection to the hook Python minimum or to the hook test environment.

  • .lefthook.toml: apm-external-skills now runs through sh scripts/py.sh instead of bare python3. This follows the same launcher and minimum-version path (the Microsoft Store stub on Windows). The Python-hook comment is updated to match.
  • tests/test_apm_external_skills.py: WorkTreeTests drops inherited GIT_* variables, and HookEnvironmentTests is added. The PR states that the hook now runs on Windows commits and that the earlier fixture leak was found during that run. This is a direct consequence of routing the hook through py.sh.
  • .github/workflows/markdown-validation.yml: path filters add .python-version and windows-hooks.yml. This matches the new file dependency.
  • CONTRIBUTING: adds the apm-external-skills hook to the hook list and describes the new minimum source.

The PR description explains each connection. The GIT_* scrub is the least directly tied to #246, but it is needed for the newly routed hook tests to run safely. No unrelated change is demonstrated.

Full details: Title check

Explanation

The title names the change as installing the latest stable Python from .python-version with mise. The changeset does not do that. It makes .python-version (pinned to 3.12) the single source for the hooks' minimum Python version. scripts/py.sh, the Windows workflow, the launcher, CONTRIBUTING, and Renovate all read or track that file. The changeset does not add mise and does not install the latest stable Python, so the title describes something absent from the changes.

Resolution

Rewrite the title to describe the actual change. For example: "fix(hooks): use .python-version as the single source for minimum Python". Remove the claim about installing the latest stable Python and the mise tool, unless the changeset adds them.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: edae627a-e503-48f2-93c2-1b93aa264b12
Commits

Reviewing files that changed from the base of the PR and between 8a522d6 and 1b5e937.

Files selected for processing: 9

  • .github/workflows/markdown-validation.yml
  • .github/workflows/windows-hooks.yml
  • .lefthook.toml
  • .python-version
  • CONTRIBUTING.md
  • renovate.json5
  • scripts/py.sh
  • tests/test_apm_external_skills.py
  • tests/test_py_launcher.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

scripts/py.sh discards the patch suffix before validation, allowing malformed Python version values to pass and hooks to proceed instead of reporting a configuration error.

1 open issue
What changed in this PR

Centralizes the hooks’ minimum Python version in .python-version, aligning interpreter selection, Windows CI, and manual Renovate updates. Also isolates external-skill test repositories from Git environment variables inherited by commit hooks.

Changes:

  • Makes the launcher and Windows CI read one shared Python minimum.
  • Adds parsing and drift checks, manual Renovate handling, and contributor documentation.
  • Routes the external-skills hook through the launcher and adds Git-environment isolation coverage.
File Description
tests/​test_py_launcher.py Adds version-file parsing, error handling, and drift checks.
tests/​test_apm_external_skills.py Isolates fixture repositories from inherited Git variables.
scripts/​py.sh Reads the minimum version from .python-version.
renovate.json5 Keeps Python minimum updates separate and manually merged.
CONTRIBUTING.md Documents the shared minimum and external-skills hook.
.python-version Defines the Python minimum as 3.12.
.lefthook.toml Routes the external-skills hook through the Python launcher.
.github/​workflows/​windows-hooks.yml Uses the shared minimum and derives launcher configuration.
.github/​workflows/​markdown-validation.yml Triggers validation when the minimum or Windows workflow changes.

Review effort: Balanced

Comment thread scripts/py.sh Resolved
@DevSecNinja DevSecNinja changed the title chore(hooks): read the minimum Python version from .python-version chore(hooks): install the latest stable Python from .python-version with mise Nov 16, 2026
@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 16, 2026 10:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new pre-commit tests require unprovisioned jq, causing feature-branch push checks to fail and block commits on systems without it even after the documented setup.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/test_hook_git_env.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes centralizing Python-version configuration across hooks and CI.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@DevSecNinja
DevSecNinja force-pushed the devsecninja-python-version-source branch from f3670a0 to 73ef87b Compare November 16, 2026 10:57
@DevSecNinja
DevSecNinja force-pushed the devsecninja-python-version-source branch from 73ef87b to 749893c Compare November 16, 2026 11:36
…ith mise

Make .python-version the single source of the Python the hooks and CI
use: the latest stable minor that has been out for 90 days (3.14; 3.15
is only 38 days old). mise installs it from the file (idiomatic version
file) for contributors and Windows CI. scripts/py.sh parses its
major.minor, prefers mise's Python, rejects malformed values and points
to `mise install`. The Ubuntu test job sets it up via
python-version-file. test_py_launcher.py fails if py.sh, mise or CI stop
reading the file.

Renovate looks the version up on endoflife.date, which dates each minor
by its x.y.0 release (the Docker tag the pyenv manager uses is re-pushed
with every patch), and auto-merges a newer minor 90 days after release
in its own PR.

Closes #246

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja
DevSecNinja force-pushed the devsecninja-python-version-source branch from 749893c to 3ef974d Compare November 16, 2026 12:13
@DevSecNinja
DevSecNinja merged commit eef88cf into main Nov 16, 2026
23 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-python-version-source branch November 16, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(hooks): single Renovate-tracked source for the minimum Python version

2 participants