diff --git a/.github/workflows/accelerate-examples.yml b/.github/workflows/accelerate-examples.yml index bc43d2208..728cae943 100644 --- a/.github/workflows/accelerate-examples.yml +++ b/.github/workflows/accelerate-examples.yml @@ -10,12 +10,16 @@ name: accelerate-examples concurrency: - # schedule runs serialize; each manual run gets its own group so a - # dispatch is never blocked behind a scheduled run. - group: ${{ github.event_name == 'schedule' && 'accelerate-examples-schedule' || format('manual-{0}', github.run_id) }} - # false: a run cancelled mid-way loses its outcome writeback, and the - # outcome is what drives the next cycle's retry. - cancel-in-progress: false + # Three groups: schedule runs serialize (a run cancelled mid-way + # loses its outcome writeback, and the outcome drives the next + # cycle's retry); each PR serializes per number so a new push + # cancels the stale run instead of queueing another matrix on the + # NPU runners; each manual run stands alone. Group names are + # repository-wide, so the PR group carries the workflow name. + group: ${{ github.event_name == 'schedule' && 'accelerate-examples-schedule' || (github.event_name == 'pull_request' && format('accelerate-examples-pr-{0}', github.event.pull_request.number)) || format('manual-{0}', github.run_id) }} + # true on PR runs only: a stale push's matrix should be cancelled, + # but a schedule run cancelled mid-way loses its outcome writeback. + cancel-in-progress: ${{ github.event_name == 'pull_request' }} on: # Daily at 02:00 Beijing time (UTC 18:00). @@ -28,6 +32,18 @@ on: required: false default: '' type: string + # PR runs need no merge: GitHub executes the workflow files from the + # PR merge ref, so a newly added trigger and engine run on the PR + # that adds them. `pull_request`, not `pull_request_target`: the + # declared read permissions are all the engine needs. paths lists + # only this project's files, so a PR that touches only the shared + # engine, scripts or schema starts no project's matrix. + pull_request: + branches: [main] + types: [opened, synchronize, reopened] + paths: + - 'examples-guards/accelerate/**' + - '.github/workflows/accelerate-examples.yml' # Engine jobs query the GitHub Job API (validate-results); called # workflows run with the caller's GITHUB_TOKEN permissions.