-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update CI auto-formate #6237
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
Update CI auto-formate #6237
Changes from 3 commits
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 |
|---|---|---|
|
|
@@ -307,15 +307,13 @@ jobs: | |
| run: python -I whats_left.py | ||
|
|
||
| lint: | ||
| name: Check Rust code with rustfmt and clippy | ||
| name: Check Rust code with clippy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: rustfmt, clippy | ||
| - name: run rustfmt | ||
| run: cargo fmt --check | ||
| components: clippy | ||
| - name: run clippy on wasm | ||
| run: cargo clippy --manifest-path=wasm/lib/Cargo.toml -- -Dwarnings | ||
| - uses: actions/setup-python@v6 | ||
|
|
@@ -450,3 +448,55 @@ 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 | ||
|
|
||
| auto_format_commit: | ||
| needs: [rust_tests, exotic_targets, snippets_cpython, lint, miri, wasm, wasm-wasi] | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| name: Auto-format code | ||
| runs-on: ubuntu-latest | ||
| if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} | ||
|
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 chainCritical: Condition check fails for pull_request events.
This is why the author reports CI passing on their fork but failing here—depending on how GitHub Actions handles For pull_request events, you need to check the base branch's latest commit or use an alternative approach. Replace the condition with: - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
+ if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.head.sha, 'skip-not-applicable') }}Or, if you want to reliably check the commit message for PRs, you'll need to fetch it explicitly in a step. For now, a safer fallback is: + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}(This allows the job to run on both; the git check inside the step will prevent unnecessary commits.) Alternatively, consider moving the I'll verify the review comment by examining the workflow file and checking GitHub Actions documentation. [/run_scripts] [/web_search] 🏁 Script executed: #!/bin/bash
# Inspect the workflow file around line 459
head -n 470 .github/workflows/ci.yaml | tail -n 30Length of output: 1166 🏁 Script executed: #!/bin/bash
# Show the workflow on/trigger section to see which events activate it
head -n 20 .github/workflows/ci.yamlLength of output: 666 🏁 Script executed: #!/bin/bash
# Find all jobs and their conditionals to understand context
rg -nP "^\s+if:|^\s+jobs:|^\s+[a-z_]+:" .github/workflows/ci.yaml | head -n 50Length of output: 2131 🌐 Web query: 💡 Result: Short answer
Examples
References Critical: The workflow triggers on both Use the same pattern as other jobs in this workflow (lines 111, 176): add a conditional that checks the event type and uses the appropriate context field. For PRs, use - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
+ if: ${{ github.event_name == 'push' || github.event_name != 'push' }}Or safely move the commit message check into the bash step where you always have access to the local git history.
🤖 Prompt for AI Agents |
||
| concurrency: | ||
| group: fmt-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.head_ref || github.ref_name }} | ||
YashSuthar983 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Setup Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: rustfmt | ||
|
|
||
| - name: Run cargo fmt | ||
| run: | | ||
| echo "Running cargo fmt --all" | ||
| cargo fmt --all | ||
|
|
||
| - name: Commit and push if changes | ||
| id: commit | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| git add -u | ||
| git commit -m "Auto-format code [skip ci]" | ||
| git push | ||
| echo "formatted=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "formatted=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Comment on PR if formatting was applied | ||
| if: steps.commit.outputs.formatted == 'true' && github.event_name == 'pull_request' | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| message: | | ||
| Code has been automatically formatted. | ||
| No action needed. | ||
| the changes were committed with `[skip ci]`. | ||
Uh oh!
There was an error while loading. Please reload this page.