-
Notifications
You must be signed in to change notification settings - Fork 2
fix(dev-env): resolve ruff from the declared pin instead of PATH #1871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4bc8909
fix(dev-env): align local ruff runs with the CI pin
kyle-sexton 729f3a9
fix(source-control): bump 0.45.1 for the CI-pinned ruff harness
kyle-sexton 5460634
Merge remote-tracking branch 'origin/main' into fix/dev-env-ruff-pin-…
kyle-sexton 3d34592
fix(dev-env): avoid SC2310 on ruff version probe
kyle-sexton eb65ec4
fix(dev-env): probe ruff version without SC2310
kyle-sexton a4ea6c8
Merge origin/main into fix/dev-env-ruff-pin-alignment
kyle-sexton a4706da
fix(dev-env): re-target the ruff wrapper at the fleet pin, and fix it…
kyle-sexton afac9ea
Merge remote-tracking branch 'origin/main' into fix/dev-env-ruff-pin-…
kyle-sexton 748e669
fix(dev-env): restore the shared version probe and record the lookup fix
kyle-sexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env bash | ||
| # Run ruff at the version pinned in .github/requirements-ci.txt. | ||
| # | ||
| # CI installs that pin via hash-locked pip (Linux x64 wheels only). Local | ||
| # workstations often carry a newer global ruff that auto-upgraded past the pin; | ||
| # a bare `ruff check` then reports findings CI does not (and that are out of | ||
| # scope for an ordinary lane). This wrapper keeps local verification aligned | ||
| # with the pin without requiring a mass lint cleanup for every ruff minor. | ||
| # | ||
| # Resolution order: | ||
| # 1. `ruff` on PATH when it already reports the pinned version (CI path) | ||
| # 2. `uvx ruff==<pin>` when uv is available (cross-platform local path) | ||
| # 3. exit 2 if PATH ruff exists but drifts and uvx is unavailable | ||
| # 4. exit 127 if neither a matching ruff nor uvx is available | ||
| # | ||
| # Usage: scripts/run-ruff.sh [ruff-args...] | ||
| # Example: scripts/run-ruff.sh check plugins/source-control | ||
| set -euo pipefail | ||
|
|
||
| repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| req="$repo_root/.github/requirements-ci.txt" | ||
|
|
||
| if [[ ! -f "$req" ]]; then | ||
| echo "error: missing $req" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # First `ruff==VERSION` line; ignore trailing backslashes / hash pins. | ||
| pin="$(awk '/^ruff==/ { | ||
| sub(/^ruff==/, "") | ||
| sub(/[[:space:]\\].*$/, "") | ||
| exit | ||
| }' "$req")" | ||
|
|
||
| if [[ -z "$pin" ]]; then | ||
| echo "error: could not parse ruff==VERSION from $req" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # `ruff --version` prints "ruff X.Y.Z"; anything else (including a failed probe) | ||
| # is reported as the caller's fallback rather than treated as a version. | ||
| ruff_reported_version() { | ||
| local out | ||
| out="$(ruff --version 2>/dev/null)" || return 1 | ||
| printf '%s\n' "${out##* }" | ||
| } | ||
|
|
||
| if command -v ruff >/dev/null 2>&1; then | ||
| # shellcheck disable=SC2310 # the probe's only failure is "no version", handled by the fallback | ||
| got="$(ruff_reported_version)" || got="" | ||
| if [[ "$got" == "$pin" ]]; then | ||
| exec ruff "$@" | ||
| fi | ||
| fi | ||
|
kyle-sexton marked this conversation as resolved.
|
||
|
|
||
| if command -v uvx >/dev/null 2>&1; then | ||
| exec uvx "ruff==${pin}" "$@" | ||
| fi | ||
|
|
||
| if command -v ruff >/dev/null 2>&1; then | ||
| # shellcheck disable=SC2310 # same probe, same fallback — reported, never trusted | ||
| got="$(ruff_reported_version)" || got="unknown" | ||
| echo "error: ruff on PATH is ${got}, but CI pins ruff==${pin} (.github/requirements-ci.txt)." >&2 | ||
| echo "error: install the pin, or install uv and re-run (uvx ruff==${pin} ...)." >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| echo "error: ruff==${pin} not available (no matching PATH ruff, no uvx)" >&2 | ||
| exit 127 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.