Skip to content

Commit 09e8a8e

Browse files
committed
Branch protection WAR: NVIDIA#605 Reprise
1 parent e40e51e commit 09e8a8e

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

.github/workflows/ci-workflow-nightly.yml

+19-10
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ jobs:
6161
name: ${{ matrix.name }}
6262
jobs: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)[matrix.name]) }}
6363

64-
# Check all other job statuses. This job gates branch protection checks.
65-
ci:
66-
name: CI
67-
if: ${{ always() || !cancelled() }}
64+
# This job acts as a sentry and will fail if any leaf job in the workflow tree fails, as
65+
# run-workflow always succeeds. Use this job when checking for successful matrix workflow job completion.
66+
verify-workflow:
67+
name: Verify and summarize workflow results
68+
if: ${{ always() && !cancelled() }}
6869
needs:
6970
- build-workflow
7071
- run-workflow
@@ -78,9 +79,19 @@ jobs:
7879
- name: Check workflow success
7980
id: check-workflow
8081
uses: ./.github/actions/workflow-results
81-
with:
82-
github_token: ${{ secrets.GITHUB_TOKEN }}
8382

83+
# Check all other job statuses. This job gates branch protection checks.
84+
ci:
85+
name: CI
86+
# !! Important: This job is used for branch protection checks.
87+
# !! Need to use always() instead of !cancelled() because skipped jobs count as success
88+
# !! for Github branch protection checks. Yes, really: by default, branch protections
89+
# !! can be bypassed by cancelling CI. See NVIDIA/cccl#605.
90+
if: ${{ always() }}
91+
needs:
92+
- verify-workflow
93+
runs-on: ubuntu-latest
94+
steps:
8495
- name: Check results
8596
run: |
8697
status="passed"
@@ -98,10 +109,8 @@ jobs:
98109
fi
99110
}
100111
101-
# Note that run-workflow is different:
102-
check_result "build-workflow" "success" "${{needs.build-workflow.result}}"
103-
check_result "run-workflow" "true" "${{steps.check-workflow.outputs.success}}"
112+
check_result "verify-workflow" "success" "${{needs.verify-workflow.result}}"
104113
105-
if [[ "$status" == "failed" ]]; then
114+
if [[ "$status" != "success" ]]; then
106115
exit 1
107116
fi

.github/workflows/ci-workflow-pull-request.yml

+26-15
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,14 @@ jobs:
7373
name: ${{ matrix.name }}
7474
jobs: ${{ toJSON(fromJSON(needs.build-workflow.outputs.workflow)[matrix.name]) }}
7575

76-
verify-devcontainers:
77-
name: Verify Dev Containers
78-
permissions:
79-
id-token: write
80-
contents: read
81-
uses: ./.github/workflows/verify-devcontainers.yml
82-
83-
# Check all other job statuses. This job gates branch protection checks.
84-
ci:
85-
name: CI
76+
# This job acts as a sentry and will fail if any leaf job in the workflow tree fails, as
77+
# run-workflow always succeeds. Use this job when checking for successful matrix workflow job completion.
78+
verify-workflow:
79+
name: Verify and summarize workflow results
8680
if: ${{ always() && !cancelled() }}
8781
needs:
8882
- build-workflow
8983
- run-workflow
90-
- verify-devcontainers
9184
permissions:
9285
contents: read
9386
pull-requests: write # Posts a comment back to the PR.
@@ -107,6 +100,26 @@ jobs:
107100
github_token: ${{ secrets.GITHUB_TOKEN }}
108101
pr_number: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}
109102

103+
verify-devcontainers:
104+
name: Verify Dev Containers
105+
permissions:
106+
id-token: write
107+
contents: read
108+
uses: ./.github/workflows/verify-devcontainers.yml
109+
110+
# Check all other job statuses. This job gates branch protection checks.
111+
ci:
112+
name: CI
113+
# !! Important: This job is used for branch protection checks.
114+
# !! Need to use always() instead of !cancelled() because skipped jobs count as success
115+
# !! for Github branch protection checks. Yes, really: by default, branch protections
116+
# !! can be bypassed by cancelling CI. See NVIDIA/cccl#605.
117+
if: ${{ always() }}
118+
needs:
119+
- verify-workflow
120+
- verify-devcontainers
121+
runs-on: ubuntu-latest
122+
steps:
110123
- name: Check results
111124
run: |
112125
status="passed"
@@ -124,11 +137,9 @@ jobs:
124137
fi
125138
}
126139
127-
# Note that run-workflow is different:
128-
check_result "build-workflow" "success" "${{needs.build-workflow.result}}"
129-
check_result "run-workflow" "true" "${{steps.check-workflow.outputs.success}}"
140+
check_result "verify-workflow" "success" "${{needs.verify-workflow.result}}"
130141
check_result "verify-devcontainers" "success" "${{needs.verify-devcontainers.result}}"
131142
132-
if [[ "$status" == "failed" ]]; then
143+
if [[ "$status" != "success" ]]; then
133144
exit 1
134145
fi

0 commit comments

Comments
 (0)