From df498ad423a894d7621d4d290599279153223670 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:15:16 +0200 Subject: [PATCH 1/4] Add auto-format before checks --- .github/workflows/ci.yaml | 92 +++++++++++++++++++++++-- .github/workflows/pr-auto-commit.yaml | 99 --------------------------- 2 files changed, 86 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/pr-auto-commit.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9ab4610ed11..aed37f5cfd0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -107,11 +107,79 @@ env: PYTHON_VERSION: "3.13.1" jobs: + auto_format_pr: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + checks: read + steps: + - name: Checkout PR branch + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + token: ${{ github.token }} + fetch-depth: 0 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Run cargo fmt + run: cargo fmt --all + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: git add + run: git add -u + + - name: git commit + id: git-commit + run: git commit -m "run `cargo fmt --all`" + continue-on-error: true # Will fail if nothing to commit + + - name: Comment on PR + if: ${{ steps.git_commit.outcome == 'success' }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + number: ${{ github.event.pull_request.number }} + message: | + **Code has been automatically formatted** + + The code in this PR has been formatted using `cargo fmt --all`. + + You may need to pull the latest changes before pushing again: + ```bash + git pull origin ${{ github.event.pull_request.head.ref }} + ``` + + **Triggered by commit:** `${{ github.event.pull_request.head.sha }}` + **Last formatted:** ${{ github.event.pull_request.updated_at }} + **Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + + - name: git push + run: git push origin HEAD:${{ github.event.pull_request.head.ref }} + if: steps.git-commit.outcome == 'success' + + # This step is not really needed as the earlier push should cancel this run anyways. + # But we are making sure that we abort if we had badly formatted files. + - name: Exit if changed + run: exit 1 + if: ${{ steps.git_commit.outcome == 'success' }} + rust_tests: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} env: RUST_BACKTRACE: full name: Run rust tests + needs: + - auto_format_pr runs-on: ${{ matrix.os }} timeout-minutes: ${{ contains(matrix.os, 'windows') && 45 || 35 }} strategy: @@ -173,8 +241,10 @@ jobs: if: runner.os == 'macOS' exotic_targets: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Ensure compilation on various targets + needs: + - auto_format_pr runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -234,10 +304,12 @@ jobs: # args: --ignore-rust-version snippets_cpython: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} env: RUST_BACKTRACE: full name: Run snippets and cpython tests + needs: + - auto_format_pr runs-on: ${{ matrix.os }} timeout-minutes: ${{ contains(matrix.os, 'windows') && 45 || 35 }} strategy: @@ -308,6 +380,8 @@ jobs: lint: name: Check Rust code with clippy + needs: + - auto_format_pr runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 @@ -342,8 +416,10 @@ jobs: incremental_files_only: true miri: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Run tests under miri + needs: + - auto_format_pr runs-on: ubuntu-latest timeout-minutes: 30 env: @@ -366,8 +442,10 @@ jobs: MIRIFLAGS: '-Zmiri-ignore-leaks' wasm: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Check the WASM package and demo + needs: + - auto_format_pr runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -427,8 +505,10 @@ jobs: PUBLISH_BRANCH: master wasm-wasi: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} + if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Run snippets and cpython tests on wasm-wasi + needs: + - auto_format_pr runs-on: ubuntu-latest timeout-minutes: 30 steps: diff --git a/.github/workflows/pr-auto-commit.yaml b/.github/workflows/pr-auto-commit.yaml deleted file mode 100644 index 8546c2abe51..00000000000 --- a/.github/workflows/pr-auto-commit.yaml +++ /dev/null @@ -1,99 +0,0 @@ -name: PR Auto-format - -# This workflow triggers when a PR is opened/updated -on: - pull_request_target: - types: [opened, synchronize, reopened] - branches: - - main - - release - -concurrency: - group: pr-fmt-${{ github.event.pull_request.number }} - cancel-in-progress: true - -jobs: - auto_format: - if: | - !contains(github.event.pull_request.labels.*.name, 'skip:ci') && - !contains(github.event.pull_request.head.sha, '[skip ci]') - permissions: - contents: write - pull-requests: write - checks: read - runs-on: ubuntu-latest - timeout-minutes: 60 - - steps: - - name: Checkout PR branch - uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - - # Wait for all PR check runs to complete - - name: Wait for all checks to complete - uses: poseidon/wait-for-status-checks@v0.6.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - delay: 60 - interval: 30 - timeout: 7200 - - - name: CI completed successfully - run: echo "CI workflow completed successfully - proceeding with auto-format" - - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - - name: Run cargo fmt - run: | - echo "Running cargo fmt --all on PR #${{ github.event.pull_request.number }}" - cargo fmt --all - - - name: Check for formatting changes - id: check_changes - run: | - if [ -n "$(git status --porcelain)" ]; then - echo "has_changes=true" >> $GITHUB_OUTPUT - else - echo "has_changes=false" >> $GITHUB_OUTPUT - fi - - - name: Commit and push formatting changes - if: steps.check_changes.outputs.has_changes == 'true' - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - git add -u - git commit -m "Auto-format code [skip ci]" - - git push origin HEAD:${{ github.event.pull_request.head.ref }} - - - name: Comment on PR - if: steps.check_changes.outputs.has_changes == 'true' - uses: marocchino/sticky-pull-request-comment@v2 - with: - number: ${{ github.event.pull_request.number }} - message: | - **Code has been automatically formatted** - - The code in this PR has been formatted using `cargo fmt`. - The changes have been committed with `[skip ci]` to avoid triggering another CI run. - - **Triggered by commit:** `${{ github.event.pull_request.head.sha }}` - **Last formatted:** ${{ github.event.pull_request.updated_at }} - - You may need to pull the latest changes before pushing again: - ```bash - git pull origin ${{ github.event.pull_request.head.ref }} - ``` - - - name: No formatting needed - if: steps.check_changes.outputs.has_changes == 'false' - run: echo "Code is already properly formatted" From 65549b24e9a50e4a2d4bed34716497d607fa47b3 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sat, 15 Nov 2025 14:02:52 +0200 Subject: [PATCH 2/4] Fix --- .github/workflows/ci.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aed37f5cfd0..1a52479b7c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -145,7 +145,7 @@ jobs: continue-on-error: true # Will fail if nothing to commit - name: Comment on PR - if: ${{ steps.git_commit.outcome == 'success' }} + if: ${{ steps.git-commit.outcome == 'success' }} uses: marocchino/sticky-pull-request-comment@v2 with: number: ${{ github.event.pull_request.number }} @@ -164,14 +164,16 @@ jobs: **Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - name: git push - run: git push origin HEAD:${{ github.event.pull_request.head.ref }} + run: git push origin HEAD:${{ env.HEAD_REF }} + env: + HEAD_REF: ${{ github.event.pull_request.head.ref }} if: steps.git-commit.outcome == 'success' # This step is not really needed as the earlier push should cancel this run anyways. # But we are making sure that we abort if we had badly formatted files. - name: Exit if changed run: exit 1 - if: ${{ steps.git_commit.outcome == 'success' }} + if: ${{ steps.git-commit.outcome == 'success' }} rust_tests: if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} From 7b52ebc8a720368dd99282b11a91fb66cb21dec1 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sat, 15 Nov 2025 14:19:28 +0200 Subject: [PATCH 3/4] Trigger CI From a577106efd36a6d55e88597feab0fecde9108d36 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 16 Nov 2025 22:14:14 +0900 Subject: [PATCH 4/4] malformat --- crates/vm/src/stdlib/ast/other.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/vm/src/stdlib/ast/other.rs b/crates/vm/src/stdlib/ast/other.rs index 780d7cc7124..84bb79bd5d8 100644 --- a/crates/vm/src/stdlib/ast/other.rs +++ b/crates/vm/src/stdlib/ast/other.rs @@ -14,10 +14,13 @@ impl Node for ruff::ConversionFlag { ) -> PyResult { i32::try_from_object(vm, object)? .to_u32() - .and_then(bytecode::ConversionFlag::from_op_arg) + .and_then( + bytecode::ConversionFlag::from_op_arg) .map(|flag| match flag { - bytecode::ConversionFlag::None => Self::None, - bytecode::ConversionFlag::Str => Self::Str, + bytecode::ConversionFlag::None => + Self::None, + bytecode::ConversionFlag::Str => + Self::Str, bytecode::ConversionFlag::Ascii => Self::Ascii, bytecode::ConversionFlag::Repr => Self::Repr, })