Skip to content

Commit c428664

Browse files
authored
ci(e2e): replace label dispatcher with comment-only helper (#990)
1 parent e703b59 commit c428664

4 files changed

Lines changed: 107 additions & 105 deletions

File tree

‎.github/workflows/e2e-label-dispatch.yml‎

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: E2E Label Help
2+
3+
# When a `test:e2e` / `test:e2e-gpu` label is applied, post a PR comment
4+
# telling the maintainer the next manual step. We don't dispatch the workflow
5+
# ourselves: a workflow_dispatch-triggered run does not surface in the PR's
6+
# Checks tab, so we'd lose in-progress visibility. Instead we point the
7+
# maintainer at either the existing run (re-run from the UI) or the
8+
# `/ok to test <SHA>` command needed to refresh the mirror.
9+
#
10+
# Uses `pull_request_target` so forked PRs get a token capable of posting
11+
# comments. The job never checks out PR code; it only calls the GitHub API.
12+
13+
on:
14+
pull_request_target:
15+
types: [labeled]
16+
17+
permissions: {}
18+
19+
jobs:
20+
hint:
21+
name: Post next-step hint for E2E label
22+
if: github.event.label.name == 'test:e2e' || github.event.label.name == 'test:e2e-gpu'
23+
runs-on: ubuntu-latest
24+
permissions:
25+
pull-requests: write
26+
steps:
27+
- name: Post comment
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
GH_REPO: ${{ github.repository }}
31+
PR_NUMBER: ${{ github.event.pull_request.number }}
32+
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
33+
LABEL_NAME: ${{ github.event.label.name }}
34+
shell: bash
35+
run: |
36+
set -euo pipefail
37+
38+
case "$LABEL_NAME" in
39+
test:e2e) workflow_file=branch-e2e.yml; workflow_name="Branch E2E Checks" ;;
40+
test:e2e-gpu) workflow_file=test-gpu.yml; workflow_name="GPU Test" ;;
41+
*) echo "Unrecognized label $LABEL_NAME"; exit 1 ;;
42+
esac
43+
44+
mirror_ref="pull-request/$PR_NUMBER"
45+
mirror_sha=$(gh api "repos/$GH_REPO/branches/$mirror_ref" --jq '.commit.sha' 2>/dev/null || echo "")
46+
short_pr=${PR_HEAD_SHA:0:7}
47+
48+
if [ -z "$mirror_sha" ]; then
49+
body="Label \`$LABEL_NAME\` applied, but \`$mirror_ref\` does not exist yet. A maintainer needs to comment \`/ok to test $PR_HEAD_SHA\` to mirror this PR. Once the mirror exists, re-apply the label or re-run [$workflow_name](https://github.com/$GH_REPO/actions/workflows/$workflow_file) from the Actions tab."
50+
elif [ "$mirror_sha" != "$PR_HEAD_SHA" ]; then
51+
short_mirror=${mirror_sha:0:7}
52+
body="Label \`$LABEL_NAME\` applied, but \`$mirror_ref\` is at \`$short_mirror\` while the PR head is \`$short_pr\`. A maintainer needs to comment \`/ok to test $PR_HEAD_SHA\` to refresh the mirror. Once the mirror catches up, re-run [$workflow_name](https://github.com/$GH_REPO/actions/workflows/$workflow_file) from the Actions tab."
53+
else
54+
run_id=$(gh api "repos/$GH_REPO/actions/workflows/$workflow_file/runs?head_sha=$PR_HEAD_SHA&event=push" \
55+
--jq '.workflow_runs | sort_by(.created_at) | reverse | .[0].id // empty')
56+
if [ -n "$run_id" ]; then
57+
run_link="[the existing run](https://github.com/$GH_REPO/actions/runs/$run_id)"
58+
else
59+
run_link="[$workflow_name](https://github.com/$GH_REPO/actions/workflows/$workflow_file)"
60+
fi
61+
body="Label \`$LABEL_NAME\` applied for \`$short_pr\`. Open $run_link and click **Re-run all jobs** to execute with the label set. The \`E2E Gate\` check on this PR will flip green automatically once the run finishes."
62+
fi
63+
64+
gh pr comment "$PR_NUMBER" --body "$body"

‎CI.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ Prerequisites:
6363
Flow:
6464

6565
1. Open the PR. copy-pr-bot mirrors it to `pull-request/<N>` automatically.
66-
2. A maintainer applies `test:e2e` and/or `test:e2e-gpu`.
67-
3. `E2E Label Dispatch` detects the label and triggers the matching workflow against the mirror.
68-
4. Results post as checks on your PR head SHA.
69-
5. New commits push to the mirror automatically; gated workflows re-run on their own. No re-labeling needed.
66+
2. The first push of `pull-request/<N>` runs `Branch E2E Checks`, but it skips the build/E2E jobs because no label is set yet. The PR's `E2E Gate` check stays neutral (no label, no requirement).
67+
3. A maintainer applies `test:e2e` and/or `test:e2e-gpu`. `E2E Label Help` posts a comment with a link to the existing `Branch E2E Checks` run.
68+
4. The maintainer opens that link and clicks **Re-run all jobs**. This time `pr_metadata` sees the label and the build/E2E jobs run.
69+
5. When the run finishes, the `E2E Gate` check on the PR flips to green automatically.
70+
6. New commits push to the mirror automatically and re-trigger `Branch E2E Checks`. Because the label is still set, those runs execute the build/E2E jobs without manual re-run.
7071

7172
### Forked PR
7273

@@ -79,11 +80,9 @@ Flow:
7980

8081
1. Open the PR. The vouch check confirms you are vouched (otherwise the PR is auto-closed).
8182
2. copy-pr-bot does not mirror forks automatically. A maintainer reviews the diff and comments `/ok to test <SHA>` with your latest commit SHA.
82-
3. After `/ok to test`, copy-pr-bot mirrors to `pull-request/<N>`.
83-
4. A maintainer applies `test:e2e` / `test:e2e-gpu`. The dispatcher runs the matching workflow against the mirror.
84-
5. Results post as checks on your PR.
83+
3. After `/ok to test`, copy-pr-bot mirrors to `pull-request/<N>`. From here the flow is identical to internal PRs: maintainer applies the label, follows the comment from `E2E Label Help`, and re-runs the workflow.
8584

86-
Important: every new commit you push requires another `/ok to test <new-SHA>` from a maintainer before E2E will run on it. If a label is applied while the mirror is stale, `E2E Label Dispatch` will post a comment explaining what's needed.
85+
Important: every new commit you push requires another `/ok to test <new-SHA>` from a maintainer before E2E will run on it. If a label is applied while the mirror is stale, `E2E Label Help` will post a comment explaining what's needed.
8786

8887
## copy-pr-bot
8988

@@ -108,4 +107,4 @@ The bot's full administrator documentation is internal to NVIDIA. The only comma
108107
| `.github/actions/pr-gate/action.yml` | Composite action that resolves PR metadata and verifies the required label is set. |
109108
| `.github/workflows/e2e-gate.yml` | Posts the required `E2E Gate` check on the PR. Re-evaluates after the gated workflow completes. |
110109
| `.github/workflows/e2e-gate-check.yml` | Reusable gate logic shared by E2E and GPU E2E. |
111-
| `.github/workflows/e2e-label-dispatch.yml` | Triggers gated workflows when a `test:e2e*` label is applied. Posts a comment if the mirror is missing or stale. |
110+
| `.github/workflows/e2e-label-help.yml` | When a `test:e2e*` label is applied, posts a PR comment telling the maintainer the next manual step (re-run an existing workflow run, or `/ok to test <SHA>` to refresh the mirror). |

0 commit comments

Comments
 (0)