Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions .github/workflows/e2e-label-dispatch.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/e2e-label-help.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: E2E Label Help

# When a `test:e2e` / `test:e2e-gpu` label is applied, post a PR comment
# telling the maintainer the next manual step. We don't dispatch the workflow
# ourselves: a workflow_dispatch-triggered run does not surface in the PR's
# Checks tab, so we'd lose in-progress visibility. Instead we point the
# maintainer at either the existing run (re-run from the UI) or the
# `/ok to test <SHA>` command needed to refresh the mirror.
#
# Uses `pull_request_target` so forked PRs get a token capable of posting
# comments. The job never checks out PR code; it only calls the GitHub API.

on:
pull_request_target:
types: [labeled]

permissions: {}

jobs:
hint:
name: Post next-step hint for E2E label
if: github.event.label.name == 'test:e2e' || github.event.label.name == 'test:e2e-gpu'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Post comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
LABEL_NAME: ${{ github.event.label.name }}
shell: bash
run: |
set -euo pipefail

case "$LABEL_NAME" in
test:e2e) workflow_file=branch-e2e.yml; workflow_name="Branch E2E Checks" ;;
test:e2e-gpu) workflow_file=test-gpu.yml; workflow_name="GPU Test" ;;
*) echo "Unrecognized label $LABEL_NAME"; exit 1 ;;
esac

mirror_ref="pull-request/$PR_NUMBER"
mirror_sha=$(gh api "repos/$GH_REPO/branches/$mirror_ref" --jq '.commit.sha' 2>/dev/null || echo "")
short_pr=${PR_HEAD_SHA:0:7}

if [ -z "$mirror_sha" ]; then
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."
elif [ "$mirror_sha" != "$PR_HEAD_SHA" ]; then
short_mirror=${mirror_sha:0:7}
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."
else
run_id=$(gh api "repos/$GH_REPO/actions/workflows/$workflow_file/runs?head_sha=$PR_HEAD_SHA&event=push" \
--jq '.workflow_runs | sort_by(.created_at) | reverse | .[0].id // empty')
if [ -n "$run_id" ]; then
run_link="[the existing run](https://github.com/$GH_REPO/actions/runs/$run_id)"
else
run_link="[$workflow_name](https://github.com/$GH_REPO/actions/workflows/$workflow_file)"
fi
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."
fi

gh pr comment "$PR_NUMBER" --body "$body"
17 changes: 8 additions & 9 deletions CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ Prerequisites:
Flow:

1. Open the PR. copy-pr-bot mirrors it to `pull-request/<N>` automatically.
2. A maintainer applies `test:e2e` and/or `test:e2e-gpu`.
3. `E2E Label Dispatch` detects the label and triggers the matching workflow against the mirror.
4. Results post as checks on your PR head SHA.
5. New commits push to the mirror automatically; gated workflows re-run on their own. No re-labeling needed.
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).
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.
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.
5. When the run finishes, the `E2E Gate` check on the PR flips to green automatically.
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.

### Forked PR

Expand All @@ -79,11 +80,9 @@ Flow:

1. Open the PR. The vouch check confirms you are vouched (otherwise the PR is auto-closed).
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.
3. After `/ok to test`, copy-pr-bot mirrors to `pull-request/<N>`.
4. A maintainer applies `test:e2e` / `test:e2e-gpu`. The dispatcher runs the matching workflow against the mirror.
5. Results post as checks on your PR.
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.

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.
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.

## copy-pr-bot

Expand All @@ -108,4 +107,4 @@ The bot's full administrator documentation is internal to NVIDIA. The only comma
| `.github/actions/pr-gate/action.yml` | Composite action that resolves PR metadata and verifies the required label is set. |
| `.github/workflows/e2e-gate.yml` | Posts the required `E2E Gate` check on the PR. Re-evaluates after the gated workflow completes. |
| `.github/workflows/e2e-gate-check.yml` | Reusable gate logic shared by E2E and GPU E2E. |
| `.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. |
| `.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). |
Loading
Loading