Skip to content

Commit 4423abf

Browse files
Merge pull request #2922 from AI-Hypercomputer:hengtaoguo-ci-copy
PiperOrigin-RevId: 854332976
2 parents c32eb92 + 67a2833 commit 4423abf

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/build_and_test_maxtext.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,44 @@ concurrency:
3737
permissions:
3838
contents: read
3939
jobs:
40+
doc_only_check:
41+
name: Check for Documentation-Only Changes
42+
runs-on: ubuntu-latest
43+
outputs:
44+
skip_tests: ${{ steps.check.outputs.skip_tests }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
- name: Check if only documentation changed
50+
id: check
51+
run: |
52+
if [ "${{ github.event_name }}" != "pull_request" ]; then
53+
echo "Not a pull request, running all tests"
54+
echo "skip_tests=false" >> $GITHUB_OUTPUT
55+
exit 0
56+
fi
57+
58+
git fetch origin ${{ github.base_ref }}
59+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
60+
61+
echo "Changed files:"
62+
echo "$CHANGED_FILES"
63+
64+
if [ -z "$CHANGED_FILES" ]; then
65+
echo "No files changed"
66+
echo "skip_tests=false" >> $GITHUB_OUTPUT
67+
elif echo "$CHANGED_FILES" | grep -v -E '\.(md|ipynb)$' > /dev/null; then
68+
echo "Non-documentation files changed, running tests"
69+
echo "skip_tests=false" >> $GITHUB_OUTPUT
70+
else
71+
echo "Only documentation (.md|ipynb) files changed, skipping tests"
72+
echo "skip_tests=true" >> $GITHUB_OUTPUT
73+
fi
74+
4075
build_and_upload_maxtext_package:
76+
needs: doc_only_check
77+
if: needs.doc_only_check.outputs.skip_tests != 'true'
4178
uses: ./.github/workflows/build_package.yml
4279
with:
4380
device_type: tpu
@@ -177,6 +214,38 @@ jobs:
177214
container_resource_option: "--shm-size 2g --runtime=nvidia --gpus all --privileged"
178215
is_scheduled_run: ${{ github.event_name == 'schedule' }}
179216

217+
all_tests_passed:
218+
name: All Required Tests Passed
219+
needs: [doc_only_check, build_and_upload_maxtext_package, maxtext_cpu_unit_tests, maxtext_tpu_unit_tests, maxtext_tpu_integration_tests, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, maxtext_gpu_unit_tests, maxtext_gpu_integration_tests]
220+
if: always()
221+
runs-on: ubuntu-latest
222+
steps:
223+
- name: Check test results
224+
run: |
225+
# If doc-only, all tests should be skipped
226+
if [ "${{ needs.doc_only_check.outputs.skip_tests }}" == "true" ]; then
227+
echo "Documentation-only changes detected, tests were skipped"
228+
exit 0
229+
fi
230+
231+
# Otherwise, check that build and all tests passed or were skipped
232+
echo "Build result: ${{ needs.build_and_upload_maxtext_package.result }}"
233+
echo "CPU tests: ${{ needs.maxtext_cpu_unit_tests.result }}"
234+
echo "TPU tests: ${{ needs.maxtext_tpu_unit_tests.result }}"
235+
echo "TPU integration: ${{ needs.maxtext_tpu_integration_tests.result }}"
236+
echo "TPU pathways: ${{ needs.maxtext_tpu_pathways_unit_tests.result }}"
237+
echo "TPU pathways integration: ${{ needs.maxtext_tpu_pathways_integration_tests.result }}"
238+
echo "GPU tests: ${{ needs.maxtext_gpu_unit_tests.result }}"
239+
echo "GPU integration: ${{ needs.maxtext_gpu_integration_tests.result }}"
240+
241+
# Fail only if any job failed or was cancelled (skipped is OK)
242+
if [ "${{ contains(needs.*.result, 'failure') }}" == "true" ] || [ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]; then
243+
echo "One or more jobs failed or were cancelled"
244+
exit 1
245+
fi
246+
247+
echo "All required tests passed successfully"
248+
180249
notify_failure:
181250
name: Notify failed build # creates an issue or modifies last open existing issue for failed build
182251
needs: [maxtext_cpu_unit_tests, maxtext_tpu_unit_tests, maxtext_tpu_integration_tests, maxtext_tpu_pathways_unit_tests, maxtext_tpu_pathways_integration_tests, maxtext_gpu_unit_tests, maxtext_gpu_integration_tests]

0 commit comments

Comments
 (0)