diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index 64f94fdd..7fa3407b 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -12,6 +12,12 @@ permissions: jobs: fmt: runs-on: ubuntu-latest + # Explicit job-level permissions + permissions: + contents: write + pull-requests: write + issues: write + steps: - name: Resolve PR head id: pr @@ -19,6 +25,7 @@ jobs: echo "repo=${{ github.event.client_payload.pull_request.head.repo.full_name }}" >> "$GITHUB_OUTPUT" echo "ref=${{ github.event.client_payload.pull_request.head.ref }}" >> "$GITHUB_OUTPUT" echo "number=${{ github.event.client_payload.pull_request.number }}" >> "$GITHUB_OUTPUT" + echo "is_fork=${{ github.event.client_payload.pull_request.head.repo.fork }}" >> "$GITHUB_OUTPUT" # Use a repo-scoped PAT for forks, else fall back to GITHUB_TOKEN - name: Set push token @@ -56,10 +63,44 @@ jobs: git push origin "HEAD:${{ steps.pr.outputs.ref }}" echo "changed=true" >> $GITHUB_OUTPUT else - echo "No formatting changes" + echo "changed=false" >> $GITHUB_OUTPUT fi + - name: Push changes + if: steps.commit.outputs.changed == 'true' && steps.pr.outputs.is_fork == 'false' + run: git push origin "HEAD:${{ steps.pr.outputs.ref }}" + + - name: Trigger Linux build/test + if: steps.fmt.outputs.changed == 'true' + run: | + gh workflow run linux_build_test.yml --ref "${{ github.head_ref }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Trigger macOS build/test + if: steps.fmt.outputs.changed == 'true' + run: | + gh workflow run macos_build_test.yml --ref "${{ github.head_ref }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment if forked + if: steps.pr.outputs.is_fork == 'true' && steps.commit.outputs.changed == 'true' + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ steps.token.outputs.token }} + issue-number: ${{ steps.pr.outputs.number }} + body: | + ⚠️ This PR comes from a fork (`${{ steps.pr.outputs.repo }}`), so the bot can't push changes. + Please run: + ```bash + cargo fmt --all + ``` + locally and commit the results. + + - name: Comment on PR + if: steps.commit.outputs.changed == 'false' uses: peter-evans/create-or-update-comment@v4 with: token: ${{ steps.token.outputs.token }} diff --git a/aria-bin/src/main.rs b/aria-bin/src/main.rs index a17711c0..4b3335df 100644 --- a/aria-bin/src/main.rs +++ b/aria-bin/src/main.rs @@ -48,7 +48,6 @@ impl From<&Args> for VmOptions { options.dump_stack = true; } } - options.vm_args = value.extra_args.clone(); options