From 3a7925c67431c81cc91bba44180da4dab4d2f336 Mon Sep 17 00:00:00 2001 From: Jinzhe Pan Date: Tue, 31 Mar 2026 08:06:19 -0400 Subject: [PATCH] [ci] Add /test pre-commit slash command - /test pre-commit triggers pre-commit via workflow_call - Posts commit status to PR head SHA so check appears on PR page - Mergify check-success~=pre-commit condition can now be satisfied --- .github/workflows/ci-precommit.yml | 2 +- .github/workflows/ci-slash-commands.yml | 37 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-precommit.yml b/.github/workflows/ci-precommit.yml index fca4bcee0..7ca7cf79d 100644 --- a/.github/workflows/ci-precommit.yml +++ b/.github/workflows/ci-precommit.yml @@ -14,7 +14,7 @@ permissions: jobs: pre-commit: - if: github.event.pull_request.draft != true + if: github.event_name == 'workflow_call' || github.event.pull_request.draft != true runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci-slash-commands.yml b/.github/workflows/ci-slash-commands.yml index a5aa6a076..be73860eb 100644 --- a/.github/workflows/ci-slash-commands.yml +++ b/.github/workflows/ci-slash-commands.yml @@ -86,7 +86,7 @@ jobs: set -euo pipefail TEST_NAME=$(echo "$COMMENT" | grep -oP '(?<=/test\s)\S+' | head -1 || true) - VALID="encoder vae transformer kernel unit ssim training lora-inference lora-training distillation self-forcing vsa vmoba performance api full fastcheck" + VALID="encoder vae transformer kernel unit ssim training lora-inference lora-training distillation self-forcing vsa vmoba performance api full fastcheck pre-commit" if [ -z "$TEST_NAME" ] || ! echo "$VALID" | grep -qw "$TEST_NAME"; then echo "Unknown test: '$TEST_NAME'. Valid: $VALID" exit 1 @@ -114,6 +114,12 @@ jobs: echo "test_scope=fastcheck" echo "full_suite=false" } >> "$GITHUB_OUTPUT" + elif [ "$TEST_NAME" = "pre-commit" ]; then + { + echo "test_type=" + echo "test_scope=precommit" + echo "full_suite=false" + } >> "$GITHUB_OUTPUT" else { echo "test_type=${MAP[$TEST_NAME]}" @@ -136,6 +142,35 @@ jobs: core.setOutput('sha', pr.head.sha); core.setOutput('branch', pr.head.ref); + pre-commit: + needs: parse-command + if: >- + needs.parse-command.outputs.has_write == 'true' + && needs.parse-command.outputs.test_scope == 'precommit' + uses: ./.github/workflows/ci-precommit.yml + + post-precommit-status: + needs: [parse-command, pre-commit] + if: always() && needs.parse-command.outputs.test_scope == 'precommit' + runs-on: ubuntu-latest + steps: + - name: Post commit status + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + PR_SHA: ${{ needs.parse-command.outputs.pr_sha }} + RESULT: ${{ needs.pre-commit.result }} + with: + script: | + const state = process.env.RESULT === 'success' ? 'success' : 'failure'; + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: process.env.PR_SHA, + state, + context: 'pre-commit', + description: `Triggered via /test pre-commit (${state})`, + }); + trigger-buildkite: needs: parse-command if: >-