From e3a4c595518a7dc7efe52df036ca2e2ea259a71c Mon Sep 17 00:00:00 2001 From: Yash Suthar Date: Thu, 30 Oct 2025 01:50:56 +0530 Subject: [PATCH 1/3] Update CI auto-formate Signed-off-by: Yash Suthar --- .github/workflows/ci.yaml | 58 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 977f27f3762..cd56a7906c2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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_formate_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]') }} + 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 }} + + - 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]`. From 4755b21079cdfed34a8b98a61dc45bf2e21b959c Mon Sep 17 00:00:00 2001 From: Yash Suthar Date: Sun, 2 Nov 2025 21:58:39 +0530 Subject: [PATCH 2/3] fix typo Signed-off-by: Yash Suthar --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cd56a7906c2..6e4d0d3afc7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -449,7 +449,7 @@ jobs: - name: run cpython unittest run: wasmer run --dir `pwd` target/wasm32-wasip1/release/rustpython.wasm -- `pwd`/Lib/test/test_int.py - auto_formate_commit: + auto_format_commit: needs: [rust_tests, exotic_targets, snippets_cpython, lint, miri, wasm, wasm-wasi] permissions: contents: write From aae26a31e5772762f97cc2ecbe4e6fbb94d68222 Mon Sep 17 00:00:00 2001 From: Yash Suthar Date: Sun, 2 Nov 2025 22:53:17 +0530 Subject: [PATCH 3/3] Seprate the job to a new workflow as we not need branch restriction Signed-off-by: Yash Suthar --- .github/workflows/auto-format.yaml | 64 ++++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 52 ------------------------ 2 files changed, 64 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/auto-format.yaml diff --git a/.github/workflows/auto-format.yaml b/.github/workflows/auto-format.yaml new file mode 100644 index 00000000000..2acf83715a0 --- /dev/null +++ b/.github/workflows/auto-format.yaml @@ -0,0 +1,64 @@ +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +name: Auto format + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + auto_format_commit: + permissions: + contents: write + pull-requests: write + name: Auto-format code + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && !contains(github.event.workflow_run.head_commit.message, '[skip ci]') }} + concurrency: + group: fmt-${{ github.event.workflow_run.head_branch }} + cancel-in-progress: true + + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_branch }} + repository: ${{ github.event.workflow_run.head_repository.full_name }} + + - 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.workflow_run.event == '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]`. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e4d0d3afc7..2ce4b475773 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -448,55 +448,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 - - 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]') }} - 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 }} - - - 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]`.