fix(pip-audit): run uv lock before export to handle version bumps#242
fix(pip-audit): run uv lock before export to handle version bumps#242JacobPEvans merged 1 commit intomainfrom
Conversation
release-please bumps the version in pyproject.toml without running uv lock, leaving the lock file stale. uv export --locked then fails with "lockfile needs to be updated". Adding uv lock before the export makes the step a no-op when the lock is current, and fixes it when only the package version changed (no dependency updates). (claude)
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the pip-audit execution script to ensure the environment's lockfile is synchronized before attempting to export dependencies. By running Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. The version bumped in silent night, The lockfile lagged, a sorry sight. But uv lock now clears the way, To keep the audit green all day. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Updates the central run-pip-audit.sh used by the reusable Python security workflow so pip-audit continues to run successfully when pyproject.toml’s version changes without a corresponding uv.lock update (e.g., release-please PRs).
Changes:
- Run
uv lockbeforeuv export --lockedto refresh the lockfile when version metadata drifts. - Add inline rationale explaining why the extra lock step is needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Sync lock file in case pyproject.toml version was bumped (e.g. by | ||
| # release-please) without a corresponding `uv lock` run. This is a | ||
| # no-op when the lock file is already up to date. | ||
| uv lock |
There was a problem hiding this comment.
Running uv lock here changes the semantics of this check: previously uv export --locked would fail if the repo’s committed uv.lock was out of date, which helps catch PRs that modify dependency constraints but forget to update/commit the lockfile. With an unconditional uv lock, those PRs will now pass pip-audit by regenerating a lockfile in CI, and pip-audit may end up auditing dependencies that don’t match what’s committed.
Consider either (a) adding a follow-up guard that fails if uv lock produced substantive uv.lock changes that aren’t present in the PR (or at least emits a clear failure message instructing to commit the updated lock), or (b) scoping this behavior to the release-please/version-bump case so dependency drift still fails fast.
| # Sync lock file in case pyproject.toml version was bumped (e.g. by | |
| # release-please) without a corresponding `uv lock` run. This is a | |
| # no-op when the lock file is already up to date. | |
| uv lock | |
| # Refresh the lockfile, but fail if this produces uncommitted changes. | |
| # This preserves the original `uv export --locked` semantics: PRs that | |
| # change dependency constraints without committing the updated `uv.lock` | |
| # should fail fast instead of auditing CI-regenerated dependencies. | |
| uv lock | |
| if ! git diff --no-ext-diff --quiet --exit-code -- uv.lock; then | |
| echo "::error file=$dir/uv.lock::uv.lock is out of date with the committed project metadata. Run 'uv lock' locally and commit the updated lockfile." | |
| git --no-pager diff -- uv.lock | |
| exit 1 | |
| fi |
Summary
uv lockbeforeuv export --lockedinrun-pip-audit.shWhy
release-pleasebumps the package version inpyproject.tomlwithout runninguv lock. The existinguv export --lockedstep then fails with:uv lockwithout--upgradeis a no-op when the lock file is already current — it only updates the local package's version metadata. This makes release-please PRs pass pip-audit without manual intervention.Test Plan
mlx-benchmarksPR Epic: Comprehensive PR Automation #24 (chore(main): release 0.5.0) pip-audit passes after this merges🤖 Generated with Claude Code