Skip to content

Fix(workflow): Pin setup-uv's Python install dir - #145

Merged
ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-144
Nov 5, 2026
Merged

ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-144

Conversation

@lf-releng-code-monkey-bot

Copy link
Copy Markdown
Contributor

Closes #144

Authored by an AI agent; human review required
Command Exit
bash tests/test-lint-plan-interpreter.sh 0
bash tests/test-lint-plan-interpreter.sh (with the new setting removed, negative check) 1
prek run --files .github/workflows/linting.yaml .github/workflows/uv-isolation.yaml docs/linting.md tests/test-lint-plan-interpreter.sh 0
uvx zizmor --persona auditor --offline .github/workflows/linting.yaml .github/workflows/uv-isolation.yaml 0
aislop scan --staged --json 0
git commit -s (prek pre-commit and commit-msg hooks incl. gitlint) 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds; a maintainer must act on any finding that remains after that, and reviews every round before merge.


What changed

setup-uv puts its Python install directory on PATH ahead of its own uv directory and then runs a bare uv python find. An earlier step can export UV_PYTHON_INSTALL_DIR through GITHUB_ENV. If it names a directory that holds a uv, setup-uv runs that uv, and the invalid UV_PYTHON_PREFERENCE added in #143 never takes effect.

  • linting.yaml (job plan) and uv-isolation.yaml: the Set up uv step env now sets UV_PYTHON_INSTALL_DIR: ${{ runner.temp }}/uv-python. This is the directory Install Python already uses, and the step value overrides any inherited one. A comment explains why. Both Install Python steps already run with working-directory: ${{ runner.temp }}, so they are unchanged.
  • Isolation job (uv-isolation.yaml), both legs: the plant step now also writes a bait uv into $GITHUB_WORKSPACE/uv-python-bait and exports UV_PYTHON_INSTALL_DIR pointing at it. The bait .venv (bin/python, python3, pyvenv.cfg) in the checkout stays. The control step runs a bare uv with that directory first on PATH, as setup-uv does, and fails unless the marker records the bait. Check no bait ran then fails if the marker exists after the uv steps.
  • tests/test-lint-plan-interpreter.sh: the Set up uv contract pins the new setting. The drift check already compares the two workflows' copies of the step, so both must carry it. run_step also unsets UV_PYTHON_INSTALL_DIR, as it already unsets the other planted variables, so the fixtures stay hermetic when the isolation job runs them.
  • docs/linting.md: describes the new setting and the new bait.

What I ran

  • bash tests/test-lint-plan-interpreter.sh: 60 passed, 0 failed.
  • Negative check: I removed the new line from linting.yaml and the test failed twice: once on the missing pin and once on drift from uv-isolation.yaml. I then restored the line.
  • I extracted the Plant bait interpreters and Control: the bait is live scripts and ran them locally against a temporary GITHUB_ENV/GITHUB_PATH. Both exit 0, and the control saw the install-dir bait run.
  • Local probe: uv python find and uv python list ignore a stray uv file in UV_PYTHON_INSTALL_DIR. Later steps inherit the bait directory, and this shows they do not break because of it.
  • prek run --files <changed files>: all hooks pass, including actionlint, zizmor, shellcheck, yamllint, markdownlint and the interpreter fixtures. gitlint passed on commit.
  • zizmor --persona auditor --offline on both changed workflows: no findings.
  • aislop scan --changes / --staged: empty diagnostics. aislop has no engine for YAML, shell or Markdown, so it scanned 0 files.

For reviewers

  • I took setup-uv's PATH ordering from the issue and did not check it against the setup-uv v10.3.3 source. The control models that ordering with PATH="$UV_PYTHON_INSTALL_DIR:$PATH" uv rather than running setup-uv without the guard.
  • After Set up uv, the job environment may still name the bait directory in UV_PYTHON_INSTALL_DIR, depending on whether setup-uv re-exports the variable. Later uv calls are not affected: Install Python runs under env -i, and the resolver passes an absolute --python. Check no bait ran would catch any regression.
  • The new UV_PYTHON_INSTALL_DIR route is only exercised on a real runner by uv-isolation.yaml. The shell fixtures cannot run setup-uv itself.

setup-uv puts its Python install directory on PATH ahead of its own
uv directory and then runs a bare 'uv python find'. An earlier step
that exports UV_PYTHON_INSTALL_DIR naming a directory holding a 'uv'
therefore gets that 'uv' run, and the invalid UV_PYTHON_PREFERENCE
guarding the lookup never applies.

Set UV_PYTHON_INSTALL_DIR to the RUNNER_TEMP directory 'Install
Python' already uses in the 'Set up uv' step env of linting.yaml and
uv-isolation.yaml, so the step value overrides any inherited one.

The isolation job now plants a bait 'uv' in a checkout directory that
UV_PYTHON_INSTALL_DIR names, and its control runs a bare 'uv' with
that directory first on PATH to show the bait is live. The fixture
test pins the new setting and unsets the variable for its own runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 are reported for the setup-uv install-directory hardening.

No open issues 🎉

What changed in this PR

This PR closes #144 by pinning setup-uv’s Python install directory under runner.temp, preventing an inherited environment variable from directing setup-uv to a planted uv executable.

Changes:

  • Pin UV_PYTHON_INSTALL_DIR in the lint-plan and isolation workflows.
  • Extend both isolation test legs with a bait uv and a control confirming it runs.
  • Update contract tests, fixture environment cleanup, and documentation.
File Description
tests/​test-lint-plan-interpreter.sh Require the new directory pin and clear inherited values in fixtures.
docs/​linting.md Explain the directory guard and expanded isolation coverage.
.github/​workflows/​uv-isolation.yaml Add install-directory bait and its control; pin setup-uv’s directory.
.github/​workflows/​linting.yaml Pin setup-uv’s Python install directory and document why.

Review effort: Balanced

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit a8b720b into lfreleng-actions:main Nov 5, 2026
55 of 56 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-144 branch November 5, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix(workflow): Pin setup-uv's Python install dir

2 participants