Skip to content

Commit 5e8f077

Browse files
committed
feature: capability to skip if docs-only
1 parent fb1add8 commit 5e8f077

1 file changed

Lines changed: 95 additions & 5 deletions

File tree

.github/workflows/cicd-main.yml

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,71 @@ permissions:
2929
contents: read
3030

3131
jobs:
32+
pre-flight:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
is_ci_workload: ${{ steps.is_ci_workload.outputs.main }}
36+
docs_only: ${{ steps.docs_only.outputs.main == 'true' }}
37+
env:
38+
EVENT_NAME: ${{ github.event_name }}
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Get PR info
46+
id: get-pr-info
47+
if: startsWith(github.ref, 'refs/heads/pull-request/')
48+
uses: nv-gha-runners/get-pr-info@main
49+
50+
- name: Determine base reference
51+
id: base-ref
52+
run: |
53+
echo "base=${{ (startsWith(github.ref, 'refs/heads/pull-request/') && fromJSON(steps.get-pr-info.outputs.pr-info).base.ref) || 'HEAD~1' }}" >> $GITHUB_OUTPUT
54+
55+
- name: Get changed files
56+
id: changed-files
57+
uses: step-security/changed-files@v45.0.1
58+
with:
59+
files: |
60+
emerging_optimizers/**
61+
.github/**
62+
pyproject.toml
63+
docker/**
64+
tests/**
65+
base_sha: ${{ steps.base-ref.outputs.base }}
66+
67+
- name: Check if docs only
68+
shell: bash
69+
id: docs_only
70+
env:
71+
DOCS_ONLY: ${{ steps.changed-files.outputs.any_changed == 'false' }}
72+
run: |
73+
echo "main=$DOCS_ONLY" | tee -a "$GITHUB_OUTPUT"
74+
75+
- name: Check if this is a CI workload
76+
shell: bash
77+
id: is_ci_workload
78+
run: |
79+
branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
80+
81+
if [[ "$branch_name" =~ ^bump-ci-container || "$EVENT_NAME" == "schedule" ]]; then
82+
is_ci_workload=true
83+
echo "main=true" | tee -a "$GITHUB_OUTPUT"
84+
else
85+
is_ci_workload=false
86+
fi
87+
88+
echo "main=$is_ci_workload" | tee -a "$GITHUB_OUTPUT"
3289
3390
cicd-wait-in-queue:
91+
needs: [pre-flight]
3492
runs-on: ubuntu-latest
3593
environment: test
94+
if: |
95+
needs.pre-flight.outputs.is_ci_workload == 'false'
96+
&& needs.pre-flight.outputs.docs_only == 'false'
3697
steps:
3798
- name: Running CI tests
3899
run: |
@@ -62,10 +123,16 @@ jobs:
62123
runner: linux-amd64-cpu16
63124
timeout: 30
64125
cpu-only: true
65-
needs: [cicd-container-build]
126+
needs: [pre-flight, cicd-container-build]
66127
runs-on: ${{ matrix.runner }}
67128
name: ${{ matrix.script }}
68129
environment: nemo-ci
130+
if: |
131+
(
132+
success()
133+
|| needs.pre-flight.outputs.is_ci_workload == 'true'
134+
)
135+
&& !cancelled()
69136
steps:
70137
- name: Checkout
71138
uses: actions/checkout@v4
@@ -85,9 +152,15 @@ jobs:
85152

86153
Nemo_CICD_Test:
87154
needs:
155+
- pre-flight
88156
- cicd-container-build
89157
- cicd-unit-tests
90-
if: always()
158+
if: |
159+
(
160+
needs.pre-flight.outputs.docs_only == 'true'
161+
|| always()
162+
)
163+
&& !cancelled()
91164
runs-on: ubuntu-latest
92165
permissions: write-all
93166
steps:
@@ -99,13 +172,13 @@ jobs:
99172
env:
100173
GH_TOKEN: ${{ github.token }}
101174
RUN_ID: ${{ github.run_id }}
175+
DOCS_ONLY: ${{ needs.pre-flight.outputs.docs_only }}
102176
run: |
103177
# Get workflow run details and check job conclusions
104-
LATEST_ATTEMPT=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion != null) | .conclusion] | last')
105178
NUM_FAILED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "failure") | .name] | length')
106179
NUM_CANCELLED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "cancelled") | .name] | length')
107180
108-
if [[ $NUM_FAILED -eq 0 && $NUM_CANCELLED -eq 0 ]]; then
181+
if [[ ($NUM_FAILED -eq 0 && $NUM_CANCELLED -eq 0) || $DOCS_ONLY == 'true' ]]; then
109182
RESULT="success"
110183
elif [[ $NUM_CANCELLED -gt 0 ]]; then
111184
RESULT="cancelled"
@@ -182,7 +255,14 @@ jobs:
182255
183256
Coverage:
184257
runs-on: ubuntu-latest
185-
needs: [Nemo_CICD_Test]
258+
needs: [pre-flight, Nemo_CICD_Test]
259+
if: |
260+
needs.pre-flight.outputs.docs_only == 'false'
261+
&& (
262+
success()
263+
|| needs.Nemo_CICD_Test.result == 'success'
264+
)
265+
&& !cancelled()
186266
strategy:
187267
matrix:
188268
flag: [unit-test]
@@ -222,3 +302,13 @@ jobs:
222302
path: |
223303
.coverage
224304
include-hidden-files: true
305+
306+
codecov-placeholder:
307+
name: codecov/patch
308+
needs: [pre-flight]
309+
if: needs.pre-flight.outputs.docs_only == 'true'
310+
runs-on: ubuntu-latest
311+
steps:
312+
- name: codecov_placeholder
313+
run: |
314+
echo "This is a placeholder status check for when no tests are ran but the codecov status is expected"

0 commit comments

Comments
 (0)