Skip to content

Commit 7aac059

Browse files
committed
ci: add ci fail-fast implementation plan
1 parent 6a5ecc4 commit 7aac059

3 files changed

Lines changed: 76 additions & 63 deletions

File tree

.github/workflows/check_docs_build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
name: Check the Documentation Build
1818

1919
on:
20-
pull_request:
21-
types: [opened, synchronize]
2220
workflow_call:
2321
inputs:
2422
maxtext_sha:
25-
required: true
23+
description: 'The specific MaxText commit SHA.'
24+
required: false
2625
type: string
2726
workflow_dispatch:
2827

@@ -38,7 +37,7 @@ jobs:
3837
with:
3938
persist-credentials: false
4039
fetch-depth: 0
41-
ref: ${{ inputs.maxtext_sha }}
40+
ref: ${{ inputs.maxtext_sha || github.sha }}
4241

4342
- name: Check if only documentation changed
4443
id: check

.github/workflows/ci_pipeline.yml

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,23 @@ jobs:
126126
echo "run_notebooks=false" >> $GITHUB_OUTPUT
127127
fi
128128
129+
code_quality_check:
130+
uses: ./.github/workflows/code_quality.yml
131+
with:
132+
maxtext_sha: ${{ inputs.maxtext_sha || github.sha }}
133+
134+
docs_build_check:
135+
uses: ./.github/workflows/check_docs_build.yml
136+
with:
137+
maxtext_sha: ${{ inputs.maxtext_sha || github.sha }}
138+
129139
build_and_upload_maxtext_package:
130-
needs: analyze_code_changes
131-
# Run if either tests or notebooks need to run
140+
needs: [analyze_code_changes, code_quality_check, docs_build_check]
141+
# Run if either tests or notebooks need to run; on PRs, gate on code quality + docs passing
132142
if: |
133-
needs.analyze_code_changes.outputs.run_tests == 'true' ||
134-
needs.analyze_code_changes.outputs.run_notebooks == 'true'
143+
always() &&
144+
(needs.analyze_code_changes.outputs.run_tests == 'true' || needs.analyze_code_changes.outputs.run_notebooks == 'true') &&
145+
(github.event_name != 'pull_request' || (needs.code_quality_check.result == 'success' && needs.docs_build_check.result == 'success'))
135146
uses: ./.github/workflows/build_package.yml
136147
with:
137148
device_type: tpu
@@ -154,10 +165,29 @@ jobs:
154165
secrets:
155166
HF_TOKEN: ${{ secrets.HF_TOKEN }}
156167

168+
gate_test_run:
169+
name: Gate and Formalize Parameters
170+
needs: [analyze_code_changes, build_and_upload_maxtext_package]
171+
if: |
172+
always() &&
173+
needs.analyze_code_changes.outputs.run_tests == 'true' &&
174+
needs.build_and_upload_maxtext_package.result == 'success'
175+
runs-on: ubuntu-latest
176+
outputs:
177+
total_workers: ${{ steps.set-params.outputs.total_workers }}
178+
worker_groups: ${{ steps.set-params.outputs.worker_groups }}
179+
steps:
180+
- id: set-params
181+
name: Formalize Test Suite Parameters
182+
run: |
183+
TPU_UNIT_TOTAL_WORKERS=2
184+
TPU_UNIT_WORKER_GROUPS='[1, 2]'
185+
echo "total_workers=${TPU_UNIT_TOTAL_WORKERS}" >> "$GITHUB_OUTPUT"
186+
echo "worker_groups=${TPU_UNIT_WORKER_GROUPS}" >> "$GITHUB_OUTPUT"
187+
157188
tpu-tests:
158189
name: ${{ matrix.flavor || 'TPU' }} tests
159-
needs: [build_and_upload_maxtext_package]
160-
if: needs.analyze_code_changes.outputs.run_tests == 'true'
190+
needs: [build_and_upload_maxtext_package, gate_test_run]
161191
uses: ./.github/workflows/run_tests_coordinator.yml
162192
strategy:
163193
fail-fast: false
@@ -171,8 +201,8 @@ jobs:
171201

172202
tpu7x-tests:
173203
name: TPU7X tests
174-
needs: [build_and_upload_maxtext_package]
175-
if: needs.analyze_code_changes.outputs.run_tests == 'true' && github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
204+
needs: [build_and_upload_maxtext_package, gate_test_run]
205+
if: github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
176206
uses: ./.github/workflows/run_tests_coordinator.yml
177207
strategy:
178208
fail-fast: false
@@ -186,8 +216,7 @@ jobs:
186216

187217
gpu-tests:
188218
name: ${{ matrix.flavor || 'GPU' }} tests
189-
needs: [build_and_upload_maxtext_package]
190-
if: needs.analyze_code_changes.outputs.run_tests == 'true'
219+
needs: [build_and_upload_maxtext_package, gate_test_run]
191220
strategy:
192221
fail-fast: false
193222
matrix:
@@ -201,8 +230,7 @@ jobs:
201230

202231
cpu-tests:
203232
name: ${{ matrix.flavor || 'CPU' }} tests
204-
needs: [build_and_upload_maxtext_package]
205-
if: needs.analyze_code_changes.outputs.run_tests == 'true'
233+
needs: [build_and_upload_maxtext_package, gate_test_run]
206234
uses: ./.github/workflows/run_tests_coordinator.yml
207235
strategy:
208236
fail-fast: false
@@ -214,31 +242,13 @@ jobs:
214242
is_scheduled_run: ${{ github.event_name == 'schedule' }}
215243
maxtext_sha: ${{ needs.build_and_upload_maxtext_package.outputs.maxtext_sha }}
216244

217-
setup-pathways-parameters:
218-
name: Setup Pathways Parameters
219-
runs-on: ubuntu-latest
220-
outputs:
221-
total_workers: ${{ steps.set-params.outputs.total_workers }}
222-
worker_groups: ${{ steps.set-params.outputs.worker_groups }}
223-
steps:
224-
- id: set-params
225-
name: Set Pathways Worker Parameters
226-
run: |
227-
# TPU worker constants
228-
TPU_UNIT_TOTAL_WORKERS=2
229-
TPU_UNIT_WORKER_GROUPS='[1, 2]'
230-
231-
echo "total_workers=${TPU_UNIT_TOTAL_WORKERS}" >> "$GITHUB_OUTPUT"
232-
echo "worker_groups=${TPU_UNIT_WORKER_GROUPS}" >> "$GITHUB_OUTPUT"
233-
234245
maxtext_tpu_pathways_unit_tests:
235-
needs: [build_and_upload_maxtext_package, setup-pathways-parameters]
236-
if: needs.analyze_code_changes.outputs.run_tests == 'true'
246+
needs: [build_and_upload_maxtext_package, gate_test_run]
237247
uses: ./.github/workflows/run_pathways_tests.yml
238248
strategy:
239249
fail-fast: false
240250
matrix:
241-
group: ${{ fromJSON(needs.setup-pathways-parameters.outputs.worker_groups) }}
251+
group: ${{ fromJSON(needs.gate_test_run.outputs.worker_groups || '[1, 2]') }}
242252
with:
243253
device_type: tpu
244254
device_name: v6e-4
@@ -251,12 +261,11 @@ jobs:
251261
container_resource_option: "--privileged"
252262
is_scheduled_run: ${{ github.event_name == 'schedule' }}
253263
maxtext_sha: ${{ needs.build_and_upload_maxtext_package.outputs.maxtext_sha }}
254-
total_workers: ${{ needs.setup-pathways-parameters.outputs.total_workers }}
264+
total_workers: ${{ needs.gate_test_run.outputs.total_workers || '2' }}
255265
worker_group: ${{ matrix.group }}
256266

257267
maxtext_tpu_pathways_integration_tests:
258-
needs: build_and_upload_maxtext_package
259-
if: needs.analyze_code_changes.outputs.run_tests == 'true'
268+
needs: [build_and_upload_maxtext_package, gate_test_run]
260269
uses: ./.github/workflows/run_pathways_tests.yml
261270
strategy:
262271
fail-fast: false
@@ -275,20 +284,19 @@ jobs:
275284

276285
all_tests_passed:
277286
name: All Required Tests Passed
278-
needs: [tpu-tests, gpu-tests, cpu-tests, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests]
287+
needs: [build_and_upload_maxtext_package, gate_test_run, tpu-tests, tpu7x-tests, gpu-tests, cpu-tests, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, code_quality_check, docs_build_check]
279288
if: always()
280289
runs-on: ubuntu-latest
281290
steps:
282291
- name: Check test results
283292
run: |
284-
if [ "${NEEDS_ANALYZE_CHANGES_OUTPUTS_RUN_TESTS}" == "false" ]; then
285-
echo "Tests were skipped"
286-
exit 0
287-
fi
288-
289-
# Otherwise, check that build and all tests passed or were skipped
293+
# Check that build and all tests passed or were skipped
290294
echo "Build result: ${NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT}"
295+
echo "Code Quality result: ${NEEDS_CODE_QUALITY_CHECK_RESULT}"
296+
echo "Docs Build result: ${NEEDS_DOCS_BUILD_CHECK_RESULT}"
297+
echo "Gate result: ${NEEDS_GATE_TEST_RUN_RESULT}"
291298
echo "TPU Tests (Matrix) result: ${NEEDS_TPU_TESTS_RESULT}"
299+
echo "TPU7X Tests (Matrix) result: ${NEEDS_TPU7X_TESTS_RESULT}"
292300
echo "GPU Tests (Matrix) result: ${NEEDS_GPU_TESTS_RESULT}"
293301
echo "CPU Tests (Matrix) result: ${NEEDS_CPU_TESTS_RESULT}"
294302
echo "Pathways Unit result: ${NEEDS_MAXTEXT_TPU_PATHWAYS_UNIT_TESTS_RESULT}"
@@ -302,10 +310,13 @@ jobs:
302310
303311
echo "All required tests passed successfully"
304312
env:
305-
NEEDS_ANALYZE_CODE_CHANGES_OUTPUTS_RUN_TESTS: ${{ needs.analyze_code_changes.outputs.run_tests }}
306313
NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT: ${{ needs.build_and_upload_maxtext_package.result }}
314+
NEEDS_CODE_QUALITY_CHECK_RESULT: ${{ needs.code_quality_check.result }}
315+
NEEDS_DOCS_BUILD_CHECK_RESULT: ${{ needs.docs_build_check.result }}
316+
NEEDS_GATE_TEST_RUN_RESULT: ${{ needs.gate_test_run.result }}
307317
NEEDS_CPU_TESTS_RESULT: ${{ needs.cpu-tests.result }}
308318
NEEDS_TPU_TESTS_RESULT: ${{ needs.tpu-tests.result }}
319+
NEEDS_TPU7X_TESTS_RESULT: ${{ needs.tpu7x-tests.result }}
309320
NEEDS_GPU_TESTS_RESULT: ${{ needs.gpu-tests.result }}
310321
NEEDS_MAXTEXT_TPU_PATHWAYS_UNIT_TESTS_RESULT: ${{ needs.maxtext_tpu_pathways_unit_tests.result }}
311322
NEEDS_MAXTEXT_TPU_PATHWAYS_INTEGRATION_TESTS_RESULT: ${{ needs.maxtext_tpu_pathways_integration_tests.result }}
@@ -341,7 +352,7 @@ jobs:
341352

342353
notify_failure:
343354
name: Notify failed build # creates an issue or modifies last open existing issue for failed build
344-
needs: [tpu-tests, tpu7x-tests, gpu-tests, cpu-tests, maxtext_jupyter_notebooks, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests]
355+
needs: [gate_test_run, tpu-tests, tpu7x-tests, gpu-tests, cpu-tests, maxtext_jupyter_notebooks, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, code_quality_check, docs_build_check]
345356
if: ${{ always() }}
346357
runs-on: ubuntu-latest
347358
permissions:
@@ -355,7 +366,7 @@ jobs:
355366

356367
investigate_failure:
357368
name: Investigate failed build # investigates failure of scheduled run and comments on tracking issue
358-
needs: [tpu-tests, tpu7x-tests, gpu-tests, cpu-tests, maxtext_jupyter_notebooks, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, notify_failure]
369+
needs: [gate_test_run, tpu-tests, tpu7x-tests, gpu-tests, cpu-tests, maxtext_jupyter_notebooks, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, code_quality_check, docs_build_check, notify_failure]
359370
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
360371
uses: ./.github/workflows/gemini_investigate.yml
361372
permissions:

.github/workflows/code_quality.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,22 @@
1717
name: Code Quality
1818

1919
on:
20-
pull_request:
21-
22-
concurrency:
23-
# Dedup pull requests (canceling previous runs of the same workflow for same PR), and scheduled runs but nothing else
24-
group: >
25-
${{
26-
github.event_name == 'pull_request' && format('{0}-pr-{1}', github.workflow, github.event.pull_request.number) ||
27-
github.event_name == 'schedule' && format('{0}-schedule', github.workflow) ||
28-
github.run_id
29-
}}
30-
cancel-in-progress: true
20+
workflow_call:
21+
inputs:
22+
maxtext_sha:
23+
description: 'The specific MaxText commit SHA.'
24+
required: false
25+
type: string
3126

3227
jobs:
3328
qa:
3429
name: "Static code-quality checkers"
3530
runs-on: ubuntu-latest
3631
steps:
3732
- uses: actions/checkout@v5
33+
with:
34+
fetch-depth: 0
35+
ref: ${{ inputs.maxtext_sha || github.sha }}
3836

3937
- name: Install uv and set the Python version
4038
uses: astral-sh/setup-uv@v7
@@ -56,7 +54,12 @@ jobs:
5654

5755
- name: Run pre-commit checks on just the files that have changed
5856
run: |
59-
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
60-
git branch "$GITHUB_HEAD_REF"
6157
. "$GITHUB_WORKSPACE"/venv/bin/activate
62-
pre-commit run --from-ref "$GITHUB_BASE_REF" --to-ref "$GITHUB_HEAD_REF" --show-diff-on-failure
58+
if [ "${{ github.event_name }}" == "pull_request" ]; then
59+
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
60+
git branch "$GITHUB_HEAD_REF"
61+
pre-commit run --from-ref "$GITHUB_BASE_REF" --to-ref "$GITHUB_HEAD_REF" --show-diff-on-failure
62+
else
63+
echo "Not a pull request event (${{ github.event_name }}), checking all files."
64+
pre-commit run --all-files --show-diff-on-failure
65+
fi

0 commit comments

Comments
 (0)