-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Unify lint CI job #7505
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
Unify lint CI job #7505
Changes from all commits
0c9f3e5
72fd632
149cc38
e09cf9e
15b06c2
59a7d2c
b39ab51
2f12793
c7be0d6
4c3b303
3adf498
855eca1
15bdf1f
cefe51f
ae898da
88028e6
0d52e5e
eefe093
b2ba0c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,6 +66,9 @@ jobs: | |||||||||
| - name: check compilation without threading | ||||||||||
| run: cargo check ${{ env.CARGO_ARGS }} | ||||||||||
|
|
||||||||||
| - run: cargo doc --locked | ||||||||||
| if: runner.os == 'Linux' | ||||||||||
|
|
||||||||||
| - name: check compilation without host_env (sandbox mode) | ||||||||||
| run: | | ||||||||||
| cargo check -p rustpython-vm --no-default-features --features compiler | ||||||||||
|
|
@@ -326,8 +329,13 @@ jobs: | |||||||||
| run: python -I scripts/whats_left.py ${{ env.CARGO_ARGS }} --features jit | ||||||||||
|
|
||||||||||
| lint: | ||||||||||
| name: Lint Rust & Python code | ||||||||||
| name: Lint | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| permissions: | ||||||||||
| contents: read | ||||||||||
| checks: write | ||||||||||
| pull-requests: write | ||||||||||
| security-events: write # for zizmor | ||||||||||
|
Comment on lines
+332
to
+338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the Every other job in this workflow still short-circuits on ♻️ Suggested fix lint:
+ if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Lint🤖 Prompt for AI Agents
Comment on lines
+334
to
+338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's find and examine the workflow file
find . -name "ci.yaml" -o -name "ci.yml" | head -20Repository: RustPython/RustPython Length of output: 92 🌐 Web query:
💡 Result: The reviewdog/action-suggester GitHub Action requires the following permissions in your workflow YAML: permissions: contents: read checks: write issues: write pull-requests: write These are specified in the official README to enable posting code suggestions via GitHub's multi-line suggestions feature on pull requests. See GitHub docs on Assigning permissions to jobs for details. The action supports pull_request events primarily. Citations: 🏁 Script executed: # Read the workflow file around the mentioned lines
fd "ci.yaml" --type f --exec wc -l {} \; 2>/dev/null | head -5Repository: RustPython/RustPython Length of output: 47 🏁 Script executed: # Read the workflow file to check permissions and action usage
cat -n .github/workflows/ci.yaml | sed -n '320,400p'Repository: RustPython/RustPython Length of output: 3245 🏁 Script executed: # Also check the workflow triggers at the top
cat -n .github/workflows/ci.yaml | head -20Repository: RustPython/RustPython Length of output: 915 Add missing The action's documentation specifies it requires Suggested fix permissions:
contents: read
checks: write
+ issues: write
pull-requests: write
security-events: write # for zizmor - name: reviewdog
- if: failure()
+ if: failure() && github.event_name == 'pull_request'
uses: reviewdog/action-suggester@aa38384ceb608d00f84b4690cacc83a5aba307ff # 1.24.0🤖 Prompt for AI Agents |
||||||||||
| steps: | ||||||||||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||
| with: | ||||||||||
|
|
@@ -337,53 +345,52 @@ jobs: | |||||||||
| with: | ||||||||||
| python-version: ${{ env.PYTHON_VERSION }} | ||||||||||
|
|
||||||||||
| - name: Check for redundant test patches | ||||||||||
| run: python scripts/check_redundant_patches.py | ||||||||||
|
|
||||||||||
| - uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 | ||||||||||
| with: | ||||||||||
| components: clippy | ||||||||||
| toolchain: stable | ||||||||||
| components: rustfmt | ||||||||||
|
|
||||||||||
| - name: run clippy on wasm | ||||||||||
| run: cargo clippy --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings | ||||||||||
|
|
||||||||||
| - name: Ensure docs generate no warnings | ||||||||||
| run: cargo doc --locked | ||||||||||
| - uses: cargo-bins/cargo-binstall@113a77a4ce971c41332f2129c3d995df993cf746 # v1.17.8 | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, check the content around line 353 in the workflow file
cat -n .github/workflows/ci.yaml | sed -n '350,360p'Repository: RustPython/RustPython Length of output: 431 🌐 Web query:
💡 Result: The cargo-binstall GitHub Action is cargo-bins/cargo-binstall@main. It installs the cargo-binstall tool (a faster alternative to cargo install that downloads prebuilt binaries). The version input specifies the cargo-binstall version to install (e.g., version: "1.2.3"). If not provided, it defaults to the latest version available from the cargo-binstall GitHub releases. Default behavior: Downloads and installs the latest cargo-binstall binary for the current platform into ~/.cargo/bin, making cargo binstall available for subsequent steps. It supports unattended CI use and works across platforms (Linux, macOS, Windows). For specific versions, provide the version input; otherwise, latest is used automatically. Citations:
🏁 Script executed: # Check if the specific action SHA mentioned has version input support
# We'll search for action.yml metadata in the cargo-binstall repo history
curl -s "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/113a77a4ce971c41332f2129c3d995df993cf746/action.yml" 2>/dev/null | head -50Repository: RustPython/RustPython Length of output: 852 Pin the The action SHA pins the action code but not the ♻️ Suggested fix- - uses: cargo-bins/cargo-binstall@113a77a4ce971c41332f2129c3d995df993cf746 # v1.17.8
+ - uses: cargo-bins/cargo-binstall@113a77a4ce971c41332f2129c3d995df993cf746 # v1.17.8
+ with:
+ version: "1.17.8"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| - name: Ensure Lib/_opcode_metadata is updated | ||||||||||
| - name: cargo shear | ||||||||||
| run: | | ||||||||||
| python scripts/generate_opcode_metadata.py | ||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||
| exit 1 | ||||||||||
| fi | ||||||||||
| cargo binstall --no-confirm cargo-shear | ||||||||||
| cargo shear | ||||||||||
|
Comment on lines
+355
to
+358
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Checking current cargo-shear install command:"
rg -n 'cargo binstall --no-confirm .*cargo-shear' .github/workflows/ci.yamlRepository: RustPython/RustPython Length of output: 164 🏁 Script executed: # Check the context around the cargo-shear installation and other tool installations
head -360 .github/workflows/ci.yaml | tail -30Repository: RustPython/RustPython Length of output: 919 🏁 Script executed: # Look for other cargo binstall or tool installation commands to see if versions are pinned elsewhere
rg -n 'cargo binstall|curl.*install|wget' .github/workflows/ci.yaml -A 1 | head -50Repository: RustPython/RustPython Length of output: 426 🏁 Script executed: # Check if there's a Cargo.lock or similar that might indicate version management strategy
git ls-files | grep -E '(Cargo|package.*lock|requirements)'Repository: RustPython/RustPython Length of output: 822 🏁 Script executed: # Check if there are any examples of pinned versions with cargo binstall in the repo
rg -n 'cargo binstall.*@' .Repository: RustPython/RustPython Length of output: 47 🏁 Script executed: # Look at cargo-binstall documentation - check if the repo has any docs or comments about it
rg -n 'cargo-binstall' .github/workflows/ci.yaml -B 2 -A 2Repository: RustPython/RustPython Length of output: 233 🏁 Script executed: # Search for any references to cargo-shear version pinning or issues
rg -n 'cargo-shear' .Repository: RustPython/RustPython Length of output: 123 🌐 Web query:
💡 Result: The version pinning syntax in cargo-binstall uses @ followed by a Cargo version requirement string. For exact versions, use @=VERSION, such as cargo binstall radio-sx128x@=0.14.1-alpha.5. This resolves using Cargo's semver parser, where =0.14.1-alpha.5 pins to exactly that version, and underspecified forms like =1.2 are equivalent to >=1.2.0, <1.3.0. Examples: - Exact version: cargo binstall crate@=1.2.3 - Pre-release: cargo binstall crate@=1.0.0-alpha.1 - Range (compatible updates): cargo binstall crate@^1.2 Alternatively, use the --version VERSION flag: cargo binstall --version 1.2.3 crate. This syntax is shown in the official README and logs, where radio-sx128x@0.14.1-alpha.5 resolves as 'radio-sx128x@=0.14.1-alpha.5'. It leverages Cargo's version req parser (clap-cargo dependency) for flexibility matching Cargo.toml dependencies. Citations:
Pin Line 357 installs the latest ♻️ Proposed fix - name: cargo shear
run: |
- cargo binstall --no-confirm cargo-shear
+ cargo binstall --no-confirm cargo-shear@=<pinned-version>
cargo shearUse the 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| - name: Install ruff | ||||||||||
| uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3.6.1 | ||||||||||
| with: | ||||||||||
| version: "0.15.5" | ||||||||||
| args: "--version" | ||||||||||
| - name: actionlint | ||||||||||
| uses: reviewdog/action-actionlint@0d952c597ef8459f634d7145b0b044a9699e5e43 # v1.71.0 | ||||||||||
|
|
||||||||||
| - run: ruff check --diff | ||||||||||
| - name: zizmor | ||||||||||
| uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2 | ||||||||||
|
|
||||||||||
| - run: ruff format --check | ||||||||||
| - name: restore prek cache | ||||||||||
| if: ${{ github.ref != 'refs/heads/main' }} # never restore on main | ||||||||||
| uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | ||||||||||
| with: | ||||||||||
| key: prek-${{ hashFiles('.pre-commit-config.yaml') }} | ||||||||||
| path: ~/.cache/prek | ||||||||||
|
|
||||||||||
| - name: install prettier | ||||||||||
| run: | | ||||||||||
| yarn global add prettier | ||||||||||
| yarn global bin >> "$GITHUB_PATH" | ||||||||||
| - name: prek | ||||||||||
| id: prek | ||||||||||
| uses: j178/prek-action@79f765515bd648eb4d6bb1b17277b7cb22cb6468 # v2.0.0 | ||||||||||
| with: | ||||||||||
| cache: false | ||||||||||
| show-verbose-logs: false | ||||||||||
| continue-on-error: true | ||||||||||
|
|
||||||||||
| - name: check wasm code with prettier | ||||||||||
| # prettier doesn't handle ignore files very well: https://github.com/prettier/prettier/issues/8506 | ||||||||||
| run: cd wasm && git ls-files -z | xargs -0 prettier --check -u | ||||||||||
| # Keep cspell check as the last step. This is optional test. | ||||||||||
| - name: install extra dictionaries | ||||||||||
| run: npm install @cspell/dict-en_us @cspell/dict-cpp @cspell/dict-python @cspell/dict-rust @cspell/dict-win32 @cspell/dict-shell | ||||||||||
| - name: spell checker | ||||||||||
| uses: streetsidesoftware/cspell-action@v8 | ||||||||||
| - name: save prek cache | ||||||||||
| if: ${{ github.ref == 'refs/heads/main' }} # only save on main | ||||||||||
| uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | ||||||||||
| with: | ||||||||||
| files: "**/*.rs" | ||||||||||
| incremental_files_only: true | ||||||||||
| key: prek-${{ hashFiles('.pre-commit-config.yaml') }} | ||||||||||
| path: ~/.cache/prek | ||||||||||
|
|
||||||||||
| - name: reviewdog | ||||||||||
| uses: reviewdog/action-suggester@aa38384ceb608d00f84b4690cacc83a5aba307ff # 1.24.0 | ||||||||||
| with: | ||||||||||
| level: warning | ||||||||||
| fail_level: error | ||||||||||
| cleanup: false | ||||||||||
|
|
||||||||||
| miri: | ||||||||||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} | ||||||||||
|
|
@@ -425,12 +432,16 @@ jobs: | |||||||||
|
|
||||||||||
| - uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 | ||||||||||
| with: | ||||||||||
| components: clippy | ||||||||||
| toolchain: stable | ||||||||||
|
|
||||||||||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||||||||||
| with: | ||||||||||
| save-if: ${{ github.ref == 'refs/heads/main' }} | ||||||||||
|
|
||||||||||
| - name: cargo clippy | ||||||||||
| run: cargo clippy --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings | ||||||||||
|
|
||||||||||
| - name: install wasm-pack | ||||||||||
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||||||||||
| - name: install geckodriver | ||||||||||
|
|
@@ -520,29 +531,3 @@ jobs: | |||||||||
| run: wasmer run --dir "$(pwd)" target/wasm32-wasip1/release/rustpython.wasm -- "$(pwd)/extra_tests/snippets/stdlib_random.py" | ||||||||||
| - name: run cpython unittest | ||||||||||
| run: wasmer run --dir "$(pwd)" target/wasm32-wasip1/release/rustpython.wasm -- "$(pwd)/Lib/test/test_int.py" | ||||||||||
|
|
||||||||||
| cargo-shear: | ||||||||||
| name: cargo shear | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| steps: | ||||||||||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||
| with: | ||||||||||
| persist-credentials: false | ||||||||||
|
|
||||||||||
| - uses: cargo-bins/cargo-binstall@113a77a4ce971c41332f2129c3d995df993cf746 # v1.17.8 | ||||||||||
|
|
||||||||||
| - run: cargo binstall --no-confirm cargo-shear | ||||||||||
|
|
||||||||||
| - run: cargo shear | ||||||||||
|
|
||||||||||
| security-lint: | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| permissions: | ||||||||||
| security-events: write | ||||||||||
| steps: | ||||||||||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||
| with: | ||||||||||
| persist-credentials: false | ||||||||||
|
|
||||||||||
| - name: Run zizmor | ||||||||||
| uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2 | ||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # NOTE: Reason for not using `prek.toml` is dependabot supports `pre-commit` as an ecosystem | ||
| # See: https://github.blog/changelog/2026-03-10-dependabot-now-supports-pre-commit-hooks/ | ||
|
|
||
| fail_fast: false | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: check-merge-conflict | ||
| priority: 0 | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.15.7 | ||
| hooks: | ||
| - id: ruff-format | ||
| priority: 0 | ||
|
|
||
| - id: ruff-check | ||
| args: [--select, I, --fix, --exit-non-zero-on-fix] | ||
| types_or: [python] | ||
| require_serial: true | ||
| priority: 1 | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: redundant-test-patches | ||
| name: check redundant test patches | ||
| entry: scripts/check_redundant_patches.py | ||
| files: '^Lib/test/.*\.py$' | ||
| language: script | ||
| types: [python] | ||
| priority: 0 | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: rustfmt | ||
| name: rustfmt | ||
| entry: rustfmt | ||
| language: system | ||
| types: [rust] | ||
| priority: 0 | ||
|
|
||
| - id: generate-opcode-metadata | ||
| name: generate opcode metadata | ||
| entry: python scripts/generate_opcode_metadata.py | ||
| files: '^(crates/compiler-core/src/bytecode/instruction\.rs|scripts/generate_opcode_metadata\.py)$' | ||
| pass_filenames: false | ||
| language: system | ||
| require_serial: true | ||
| priority: 1 # so rustfmt runs first | ||
|
|
||
| - repo: https://github.com/streetsidesoftware/cspell-cli | ||
| rev: v9.7.0 | ||
| hooks: | ||
| - id: cspell | ||
| types: [rust] | ||
| additional_dependencies: | ||
| - '@cspell/dict-en_us' | ||
| - '@cspell/dict-cpp' | ||
| - '@cspell/dict-python' | ||
| - '@cspell/dict-rust' | ||
| - '@cspell/dict-win32' | ||
| - '@cspell/dict-shell' | ||
| priority: 0 | ||
|
|
||
| - repo: https://github.com/rbubley/mirrors-prettier | ||
| rev: v3.8.1 | ||
| hooks: | ||
| - id: prettier | ||
| files: '^wasm/.*$' | ||
| priority: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to here because
cargo checkandcargo docuses the same profile