Skip to content

Commit f4cf5e0

Browse files
committed
fix(ci): resolve mirror gate statuses for fork PRs
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 528fb29 commit f4cf5e0

4 files changed

Lines changed: 22 additions & 186 deletions

File tree

.github/workflows/e2e-gate-check.yml

Lines changed: 0 additions & 113 deletions
This file was deleted.

.github/workflows/e2e-gate.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/required-ci-gates.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
PR_HEAD_SHA_FROM_EVENT: ${{ github.event.pull_request.head.sha }}
3737
PR_LABELS_FROM_EVENT: ${{ toJSON(github.event.pull_request.labels.*.name) }}
3838
WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
39+
WORKFLOW_RUN_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
3940
WORKFLOW_RUN_EVENT: ${{ github.event.workflow_run.event }}
4041
shell: bash
4142
run: |
@@ -73,12 +74,32 @@ jobs:
7374
LABELS_JSON=$(jq -c . <<< "$PR_LABELS_FROM_EVENT")
7475
}
7576
77+
load_pr_context() {
78+
PR_NUMBER="$1"
79+
80+
local pr state
81+
pr=$(gh api "repos/$GH_REPO/pulls/$PR_NUMBER")
82+
state=$(jq -r '.state' <<< "$pr")
83+
if [ "$state" != "open" ]; then
84+
echo "PR #$PR_NUMBER is $state; nothing to publish."
85+
exit 0
86+
fi
87+
88+
HEAD_SHA=$(jq -r '.head.sha' <<< "$pr")
89+
LABELS_JSON=$(gh api "repos/$GH_REPO/issues/$PR_NUMBER" --jq '[.labels[].name]')
90+
}
91+
7692
resolve_workflow_run_event() {
7793
if [ "$WORKFLOW_RUN_EVENT" != "push" ]; then
7894
echo "Ignoring workflow_run from event '$WORKFLOW_RUN_EVENT'."
7995
exit 0
8096
fi
8197
98+
if [[ "$WORKFLOW_RUN_HEAD_BRANCH" =~ ^pull-request/([0-9]+)$ ]]; then
99+
load_pr_context "${BASH_REMATCH[1]}"
100+
return
101+
fi
102+
82103
local associated_prs pr
83104
associated_prs=$(gh api "repos/$GH_REPO/commits/$WORKFLOW_RUN_HEAD_SHA/pulls")
84105
pr=$(jq -c 'map(select(.state == "open"))[0] // empty' <<< "$associated_prs")
@@ -87,10 +108,7 @@ jobs:
87108
exit 0
88109
fi
89110
90-
PR_NUMBER=$(jq -r '.number' <<< "$pr")
91-
pr=$(gh api "repos/$GH_REPO/pulls/$PR_NUMBER")
92-
HEAD_SHA=$(jq -r '.head.sha' <<< "$pr")
93-
LABELS_JSON=$(gh api "repos/$GH_REPO/issues/$PR_NUMBER" --jq '[.labels[].name]')
111+
load_pr_context "$(jq -r '.number' <<< "$pr")"
94112
}
95113
96114
resolve_context() {

CI.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ The bot's full administrator documentation is internal to NVIDIA. The only comma
113113
| `.github/actions/pr-gate/action.yml` | Composite action that resolves PR metadata and verifies the required label is set. |
114114
| `.github/actions/pr-merge-base/action.yml` | Composite action that resolves and fetches the merge-base commit for `pull-request/<N>` push workflows. |
115115
| `.github/workflows/required-ci-gates.yml` | Posts required PR-head statuses for push-based CI workflows. This is what branch protection should require. |
116-
| `.github/workflows/e2e-gate.yml` | Posts the required `E2E Gate` check on the PR. Re-evaluates after the gated workflow completes. |
117-
| `.github/workflows/e2e-gate-check.yml` | Reusable gate logic shared by E2E and GPU E2E. |
118116
| `.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). |
119117

120118
## Release workflows

0 commit comments

Comments
 (0)