@@ -37,8 +37,8 @@ concurrency:
3737permissions :
3838 contents : read
3939jobs :
40- doc_only_check :
41- name : Check for Documentation-Only Changes
40+ analyze_code_changes :
41+ name : Analyze Code Changes for Test Orchestration
4242 runs-on : ubuntu-latest
4343 outputs :
4444 run_tests : ${{ steps.check.outputs.run_tests }}
4747 - uses : actions/checkout@v4
4848 with :
4949 fetch-depth : 0
50- - name : Check if only documentation changed
50+ - name : Check for Code Changes
5151 id : check
5252 run : |
5353 if [ "${{ github.event_name }}" != "pull_request" ]; then
@@ -64,22 +64,49 @@ jobs:
6464 echo "$CHANGED_FILES"
6565
6666 if [ -z "$CHANGED_FILES" ]; then
67- echo "No files changed "
67+ echo "No files detected or diff failed. Running everything as a fail-safe. "
6868 echo "run_tests=true" >> $GITHUB_OUTPUT
6969 echo "run_notebooks=true" >> $GITHUB_OUTPUT
7070 exit 0
7171 fi
7272
73- # Check for source code changes (anything not .md and not .ipynb)
73+ # default to running everything if something goes wrong with the checks
74+ echo "run_tests=true" >> $GITHUB_OUTPUT
75+ echo "run_notebooks=true" >> $GITHUB_OUTPUT
76+
77+ # 1. Check if only documentation files (.md) were changed
78+ if ! echo "$CHANGED_FILES" | grep -v -E '\.md$' > /dev/null; then
79+ echo "Documentation-only files changed, skipping all tests and notebooks."
80+ echo "run_tests=false" >> $GITHUB_OUTPUT
81+ echo "run_notebooks=false" >> $GITHUB_OUTPUT
82+ exit 0
83+ fi
84+
85+ # 2. Check if dependencies or Github workflows were changed
86+ if echo "$CHANGED_FILES" | grep -E '(^|/)(src/dependencies/|\.github/workflows/)' > /dev/null; then
87+ echo "Core files (dependencies, workflows) changed, enabling all tests and notebooks."
88+ echo "run_tests=true" >> $GITHUB_OUTPUT
89+ echo "run_notebooks=true" >> $GITHUB_OUTPUT
90+ exit 0
91+ fi
92+
93+ # 3. Check if post-training files were changed
94+ if echo "$CHANGED_FILES" | grep -E 'src/maxtext/trainers/post_train/' > /dev/null; then
95+ echo "run_tests=true" >> $GITHUB_OUTPUT
96+ echo "run_notebooks=true" >> $GITHUB_OUTPUT
97+ exit 0
98+ fi
99+
100+ # 4. Check for source code changes (anything not .md and not .ipynb)
74101 if echo "$CHANGED_FILES" | grep -v -E '\.(md|ipynb)$' > /dev/null; then
75- echo "Source code files changed, enabling unit tests."
102+ echo "Source code changed, enabling unit tests."
76103 echo "run_tests=true" >> $GITHUB_OUTPUT
77104 else
78- echo "No source code changes, skipping unit tests."
105+ echo "No source code changes (only notebook/doc) , skipping unit tests."
79106 echo "run_tests=false" >> $GITHUB_OUTPUT
80107 fi
81108
82- # Check for notebook (.ipynb) changes specifically
109+ # 5. Check for notebook (.ipynb) changes
83110 if echo "$CHANGED_FILES" | grep '\.ipynb$' > /dev/null; then
84111 echo "Notebook files changed, enabling notebook run."
85112 echo "run_notebooks=true" >> $GITHUB_OUTPUT
@@ -88,14 +115,12 @@ jobs:
88115 echo "run_notebooks=false" >> $GITHUB_OUTPUT
89116 fi
90117
91- exit 0
92-
93118 build_and_upload_maxtext_package :
94- needs : doc_only_check
119+ needs : analyze_code_changes
95120 # Run if either tests or notebooks need to run
96121 if : |
97- needs.doc_only_check .outputs.run_tests == 'true' ||
98- needs.doc_only_check .outputs.run_notebooks == 'true'
122+ needs.analyze_code_changes .outputs.run_tests == 'true' ||
123+ needs.analyze_code_changes .outputs.run_notebooks == 'true'
99124 uses : ./.github/workflows/build_package.yml
100125 with :
101126 device_type : tpu
@@ -104,7 +129,7 @@ jobs:
104129
105130 maxtext_jupyter_notebooks :
106131 needs : build_and_upload_maxtext_package
107- if : needs.doc_only_check .outputs.run_notebooks == 'true'
132+ if : needs.analyze_code_changes .outputs.run_notebooks == 'true'
108133 uses : ./.github/workflows/run_jupyter_notebooks.yml
109134 strategy :
110135 fail-fast : false
@@ -120,7 +145,7 @@ jobs:
120145 tpu-tests :
121146 name : ${{ matrix.flavor }} tests
122147 needs : [build_and_upload_maxtext_package]
123- if : needs.doc_only_check .outputs.run_tests == 'true'
148+ if : needs.analyze_code_changes .outputs.run_tests == 'true'
124149 uses : ./.github/workflows/run_tests_coordinator.yml
125150 strategy :
126151 fail-fast : false
@@ -135,7 +160,7 @@ jobs:
135160 gpu-tests :
136161 name : ${{ matrix.flavor }} tests
137162 needs : [build_and_upload_maxtext_package]
138- if : needs.doc_only_check .outputs.run_tests == 'true'
163+ if : needs.analyze_code_changes .outputs.run_tests == 'true'
139164 strategy :
140165 fail-fast : false
141166 matrix :
@@ -150,7 +175,7 @@ jobs:
150175 cpu-tests :
151176 name : ${{ matrix.flavor }} tests
152177 needs : [build_and_upload_maxtext_package]
153- if : needs.doc_only_check .outputs.run_tests == 'true'
178+ if : needs.analyze_code_changes .outputs.run_tests == 'true'
154179 uses : ./.github/workflows/run_tests_coordinator.yml
155180 strategy :
156181 fail-fast : false
@@ -164,7 +189,7 @@ jobs:
164189
165190 maxtext_tpu_pathways_unit_tests :
166191 needs : build_and_upload_maxtext_package
167- if : needs.doc_only_check .outputs.run_tests == 'true'
192+ if : needs.analyze_code_changes .outputs.run_tests == 'true'
168193 uses : ./.github/workflows/run_pathways_tests.yml
169194 strategy :
170195 fail-fast : false
@@ -182,7 +207,7 @@ jobs:
182207
183208 maxtext_tpu_pathways_integration_tests :
184209 needs : build_and_upload_maxtext_package
185- if : needs.doc_only_check .outputs.run_tests == 'true'
210+ if : needs.analyze_code_changes .outputs.run_tests == 'true'
186211 uses : ./.github/workflows/run_pathways_tests.yml
187212 strategy :
188213 fail-fast : false
@@ -228,7 +253,7 @@ jobs:
228253
229254 echo "All required tests passed successfully"
230255 env :
231- NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_TESTS : ${{ needs.doc_only_check .outputs.run_tests }}
256+ NEEDS_ANALYZE_CODE_CHANGES_OUTPUTS_RUN_TESTS : ${{ needs.analyze_code_changes .outputs.run_tests }}
232257 NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT : ${{ needs.build_and_upload_maxtext_package.result }}
233258 NEEDS_CPU_TESTS_RESULT : ${{ needs.cpu-tests.result }}
234259 NEEDS_TPU_TESTS_RESULT : ${{ needs.tpu-tests.result }}
@@ -238,13 +263,13 @@ jobs:
238263
239264 all_notebooks_passed :
240265 name : All Notebooks Passed
241- needs : [doc_only_check , build_and_upload_maxtext_package, maxtext_jupyter_notebooks]
266+ needs : [analyze_code_changes , build_and_upload_maxtext_package, maxtext_jupyter_notebooks]
242267 if : always()
243268 runs-on : ubuntu-latest
244269 steps :
245270 - name : Check notebooks results
246271 run : |
247- if [ "${NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_NOTEBOOKS }" == "false" ]; then
272+ if [ "${NEEDS_ANALYZE_CODE_CHANGES_OUTPUTS_RUN_NOTEBOOKS }" == "false" ]; then
248273 echo "Non-notebook changes detected, runs were skipped"
249274 exit 0
250275 fi
@@ -261,7 +286,7 @@ jobs:
261286
262287 echo "All required notebooks passed successfully"
263288 env :
264- NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_NOTEBOOKS : ${{ needs.doc_only_check .outputs.run_notebooks }}
289+ NEEDS_ANALYZE_CODE_CHANGES_OUTPUTS_RUN_NOTEBOOKS : ${{ needs.analyze_code_changes .outputs.run_notebooks }}
265290 NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT : ${{ needs.build_and_upload_maxtext_package.result }}
266291 NEEDS_MAXTEXT_JUPYTER_NOTEBOOKS_RESULT : ${{ needs.maxtext_jupyter_notebooks.result }}
267292
0 commit comments