Skip to content

Commit 709c402

Browse files
authored
CI: Add [doc-only] support to skip tests and non-essential builds (#1478)
When a PR title contains [doc-only], the CI will: - Skip linux-aarch64 and windows builds - Skip all test jobs (linux-64, linux-aarch64, windows) - Keep linux-64 build (required for docs) - Keep doc build and deployment This allows faster iteration on documentation-only changes without waiting for the full test matrix to complete. Closes #1350
1 parent 809dd8e commit 709c402

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
runs-on: ubuntu-latest
4141
outputs:
4242
skip: ${{ steps.get-should-skip.outputs.skip }}
43+
doc-only: ${{ steps.get-should-skip.outputs.doc_only }}
4344
steps:
4445
- name: Checkout repository
4546
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -50,11 +51,16 @@ jobs:
5051
run: |
5152
set -euxo pipefail
5253
if ${{ startsWith(github.ref_name, 'pull-request/') }}; then
53-
skip="$(gh pr view "$(grep -Po '(\d+)$' <<< '${{ github.ref_name }}')" --json title --jq '.title | contains("[no-ci]")')"
54+
pr_number="$(grep -Po '(\d+)$' <<< '${{ github.ref_name }}')"
55+
pr_title="$(gh pr view "${pr_number}" --json title --jq '.title')"
56+
skip="$(echo "${pr_title}" | grep -q '\[no-ci\]' && echo true || echo false)"
57+
doc_only="$(echo "${pr_title}" | grep -q '\[doc-only\]' && echo true || echo false)"
5458
else
5559
skip=false
60+
doc_only=false
5661
fi
5762
echo "skip=${skip}" >> "$GITHUB_OUTPUT"
63+
echo "doc_only=${doc_only}" >> "$GITHUB_OUTPUT"
5864
5965
# WARNING: make sure all of the build jobs are in sync
6066
build-linux-64:
@@ -86,7 +92,7 @@ jobs:
8692
host-platform:
8793
- linux-aarch64
8894
name: Build ${{ matrix.host-platform }}, CUDA ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
89-
if: ${{ github.repository_owner == 'nvidia' && !fromJSON(needs.should-skip.outputs.skip) }}
95+
if: ${{ github.repository_owner == 'nvidia' && !fromJSON(needs.should-skip.outputs.skip) && !fromJSON(needs.should-skip.outputs.doc-only) }}
9096
secrets: inherit
9197
uses: ./.github/workflows/build-wheel.yml
9298
with:
@@ -105,7 +111,7 @@ jobs:
105111
host-platform:
106112
- win-64
107113
name: Build ${{ matrix.host-platform }}, CUDA ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
108-
if: ${{ github.repository_owner == 'nvidia' && !fromJSON(needs.should-skip.outputs.skip) }}
114+
if: ${{ github.repository_owner == 'nvidia' && !fromJSON(needs.should-skip.outputs.skip) && !fromJSON(needs.should-skip.outputs.doc-only) }}
109115
secrets: inherit
110116
uses: ./.github/workflows/build-wheel.yml
111117
with:
@@ -121,11 +127,12 @@ jobs:
121127
host-platform:
122128
- linux-64
123129
name: Test ${{ matrix.host-platform }}
124-
if: ${{ github.repository_owner == 'nvidia' }}
130+
if: ${{ github.repository_owner == 'nvidia' && !fromJSON(needs.should-skip.outputs.doc-only) }}
125131
permissions:
126132
contents: read # This is required for actions/checkout
127133
needs:
128134
- ci-vars
135+
- should-skip
129136
- build-linux-64
130137
secrets: inherit
131138
uses: ./.github/workflows/test-wheel-linux.yml
@@ -142,6 +149,8 @@ jobs:
142149
host-platform:
143150
- linux-aarch64
144151
name: Test ${{ matrix.host-platform }}
152+
# Note: No doc-only check needed here - if build-linux-aarch64 is skipped,
153+
# this job is automatically skipped due to the dependency.
145154
if: ${{ github.repository_owner == 'nvidia' }}
146155
permissions:
147156
contents: read # This is required for actions/checkout
@@ -162,6 +171,8 @@ jobs:
162171
host-platform:
163172
- win-64
164173
name: Test ${{ matrix.host-platform }}
174+
# Note: No doc-only check needed here - if build-windows is skipped,
175+
# this job is automatically skipped due to the dependency.
165176
if: ${{ github.repository_owner == 'nvidia' }}
166177
permissions:
167178
contents: read # This is required for actions/checkout
@@ -196,6 +207,7 @@ jobs:
196207
if: always()
197208
runs-on: ubuntu-latest
198209
needs:
210+
- should-skip
199211
- test-linux-64
200212
- test-linux-aarch64
201213
- test-windows
@@ -219,11 +231,18 @@ jobs:
219231
# failing job(s) will timeout causing a cancellation here and the
220232
# build to succeed which we don't want (originally this was just
221233
# 'exit 0')
222-
if ${{ needs.test-linux-64.result == 'cancelled' ||
223-
needs.test-linux-aarch64.result == 'cancelled' ||
224-
needs.test-windows.result == 'cancelled' ||
225-
needs.doc.result == 'cancelled' }}; then
234+
#
235+
# Note: When [doc-only] is in PR title, test jobs are intentionally
236+
# skipped and should not cause failure.
237+
doc_only=${{ needs.should-skip.outputs.doc-only }}
238+
if ${{ needs.doc.result == 'cancelled' }}; then
226239
exit 1
227-
else
228-
exit 0
229240
fi
241+
if [[ "${doc_only}" != "true" ]]; then
242+
if ${{ needs.test-linux-64.result == 'cancelled' ||
243+
needs.test-linux-aarch64.result == 'cancelled' ||
244+
needs.test-windows.result == 'cancelled' }}; then
245+
exit 1
246+
fi
247+
fi
248+
exit 0

0 commit comments

Comments
 (0)