Skip to content

Commit f3d9f5c

Browse files
Refactor Github Action per b/485167538 (#3181)
Co-authored-by: Ben Knutson <benknutson@google.com>
1 parent 5b0bb89 commit f3d9f5c

3 files changed

Lines changed: 51 additions & 25 deletions

File tree

.github/workflows/build_and_push_docker_image.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ jobs:
6666
id: check
6767
shell: bash
6868
run: |
69-
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.target_device }}" != "all" && "${{ github.event.inputs.target_device }}" != "${{ inputs.device }}" ]]; then
69+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${GITHUB_EVENT_INPUTS_TARGET_DEVICE}" != "all" && "${GITHUB_EVENT_INPUTS_TARGET_DEVICE}" != "${INPUTS_DEVICE}" ]]; then
7070
echo "should_run=false" >> $GITHUB_OUTPUT
71-
echo "Skipping ${{ inputs.image_name }} build for device: ${{ inputs.device }} in ${{ inputs.build_mode }} mode."
71+
echo "Skipping ${INPUTS_IMAGE_NAME} build for device: ${INPUTS_DEVICE} in ${INPUTS_BUILD_MODE} mode."
7272
else
7373
echo "should_run=true" >> $GITHUB_OUTPUT
74-
echo "Building ${{ inputs.image_name }} for device: ${{ inputs.device }} in ${{ inputs.build_mode }} mode."
74+
echo "Building ${INPUTS_IMAGE_NAME} for device: ${INPUTS_DEVICE} in ${INPUTS_BUILD_MODE} mode."
7575
fi
76+
env:
77+
GITHUB_EVENT_INPUTS_TARGET_DEVICE: ${{ github.event.inputs.target_device }}
78+
INPUTS_DEVICE: ${{ inputs.device }}
79+
INPUTS_IMAGE_NAME: ${{ inputs.image_name }}
80+
INPUTS_BUILD_MODE: ${{ inputs.build_mode }}
7681

7782
- name: Checkout MaxText
7883
uses: actions/checkout@v5
@@ -125,13 +130,13 @@ jobs:
125130
if: steps.check.outputs.should_run == 'true'
126131
shell: bash
127132
run: |
128-
SOURCE_IMAGE="gcr.io/tpu-prod-env-multipod/${{ inputs.image_name }}"
133+
SOURCE_IMAGE="gcr.io/tpu-prod-env-multipod/${INPUTS_IMAGE_NAME}"
129134
130135
# Add date tag
131-
gcloud container images add-tag "$SOURCE_IMAGE:latest" "$SOURCE_IMAGE:${{ inputs.image_date }}" --quiet
136+
gcloud container images add-tag "$SOURCE_IMAGE:latest" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
132137
133138
# Convert date to YYYYMMDD format
134-
clean_date=$(echo "${{ inputs.image_date }}" | sed 's/[-:]//g' | cut -c1-8)
139+
clean_date=$(echo "${INPUTS_IMAGE_DATE}" | sed 's/[-:]//g' | cut -c1-8)
135140
136141
# Add MaxText tag
137142
maxtext_hash=$(git rev-parse --short HEAD)
@@ -147,3 +152,6 @@ jobs:
147152
fi
148153
done
149154
fi
155+
env:
156+
INPUTS_IMAGE_NAME: ${{ inputs.image_name }}
157+
INPUTS_IMAGE_DATE: ${{ inputs.image_date }}

.github/workflows/build_and_test_maxtext.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
exit 0
5858
fi
5959
60-
git fetch origin ${{ github.base_ref }}
61-
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
60+
git fetch origin ${GITHUB_BASE_REF}
61+
CHANGED_FILES=$(git diff --name-only origin/${GITHUB_BASE_REF}...HEAD)
6262
6363
echo "Changed files:"
6464
echo "$CHANGED_FILES"
@@ -273,20 +273,20 @@ jobs:
273273
- name: Check test results
274274
run: |
275275
# If doc-only, all tests should be skipped
276-
if [ "${{ needs.doc_only_check.outputs.run_tests }}" == "false" ]; then
276+
if [ "${NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_TESTS}" == "false" ]; then
277277
echo "Documentation-only changes detected, tests were skipped"
278278
exit 0
279279
fi
280280
281281
# Otherwise, check that build and all tests passed or were skipped
282-
echo "Build result: ${{ needs.build_and_upload_maxtext_package.result }}"
283-
echo "CPU tests: ${{ needs.maxtext_cpu_unit_tests.result }}"
284-
echo "TPU tests: ${{ needs.maxtext_tpu_unit_tests.result }}"
285-
echo "TPU integration: ${{ needs.maxtext_tpu_integration_tests.result }}"
286-
echo "TPU pathways: ${{ needs.maxtext_tpu_pathways_unit_tests.result }}"
287-
echo "TPU pathways integration: ${{ needs.maxtext_tpu_pathways_integration_tests.result }}"
288-
echo "GPU tests: ${{ needs.maxtext_gpu_unit_tests.result }}"
289-
echo "GPU integration: ${{ needs.maxtext_gpu_integration_tests.result }}"
282+
echo "Build result: ${NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT}"
283+
echo "CPU tests: ${NEEDS_MAXTEXT_CPU_UNIT_TESTS_RESULT}"
284+
echo "TPU tests: ${NEEDS_MAXTEXT_TPU_UNIT_TESTS_RESULT}"
285+
echo "TPU integration: ${NEEDS_MAXTEXT_TPU_INTEGRATION_TESTS_RESULT}"
286+
echo "TPU pathways: ${NEEDS_MAXTEXT_TPU_PATHWAYS_UNIT_TESTS_RESULT}"
287+
echo "TPU pathways integration: ${NEEDS_MAXTEXT_TPU_PATHWAYS_INTEGRATION_TESTS_RESULT}"
288+
echo "GPU tests: ${NEEDS_MAXTEXT_GPU_UNIT_TESTS_RESULT}"
289+
echo "GPU integration: ${NEEDS_MAXTEXT_GPU_INTEGRATION_TESTS_RESULT}"
290290
291291
# Fail only if any job failed or was cancelled (skipped is OK)
292292
if [ "${{ contains(needs.*.result, 'failure') }}" == "true" ] || [ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]; then
@@ -295,6 +295,16 @@ jobs:
295295
fi
296296
297297
echo "All required tests passed successfully"
298+
env:
299+
NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_TESTS: ${{ needs.doc_only_check.outputs.run_tests }}
300+
NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT: ${{ needs.build_and_upload_maxtext_package.result }}
301+
NEEDS_MAXTEXT_CPU_UNIT_TESTS_RESULT: ${{ needs.maxtext_cpu_unit_tests.result }}
302+
NEEDS_MAXTEXT_TPU_UNIT_TESTS_RESULT: ${{ needs.maxtext_tpu_unit_tests.result }}
303+
NEEDS_MAXTEXT_TPU_INTEGRATION_TESTS_RESULT: ${{ needs.maxtext_tpu_integration_tests.result }}
304+
NEEDS_MAXTEXT_TPU_PATHWAYS_UNIT_TESTS_RESULT: ${{ needs.maxtext_tpu_pathways_unit_tests.result }}
305+
NEEDS_MAXTEXT_TPU_PATHWAYS_INTEGRATION_TESTS_RESULT: ${{ needs.maxtext_tpu_pathways_integration_tests.result }}
306+
NEEDS_MAXTEXT_GPU_UNIT_TESTS_RESULT: ${{ needs.maxtext_gpu_unit_tests.result }}
307+
NEEDS_MAXTEXT_GPU_INTEGRATION_TESTS_RESULT: ${{ needs.maxtext_gpu_integration_tests.result }}
298308

299309
all_notebooks_passed:
300310
name: All Notebooks Passed
@@ -304,14 +314,14 @@ jobs:
304314
steps:
305315
- name: Check notebooks results
306316
run: |
307-
if [ "${{ needs.doc_only_check.outputs.run_notebooks }}" == "false" ]; then
317+
if [ "${NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_NOTEBOOKS}" == "false" ]; then
308318
echo "Non-notebook changes detected, runs were skipped"
309319
exit 0
310320
fi
311321
312322
# Otherwise, check that build and notebooks run passed or were skipped
313-
echo "Build result: ${{ needs.build_and_upload_maxtext_package.result }}"
314-
echo "Jupyter Notebooks result: ${{ needs.maxtext_jupyter_notebooks.result }}"
323+
echo "Build result: ${NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT}"
324+
echo "Jupyter Notebooks result: ${NEEDS_MAXTEXT_JUPYTER_NOTEBOOKS_RESULT}"
315325
316326
# Fail only if any job failed or was cancelled (skipped is OK)
317327
if [ "${{ contains(needs.*.result, 'failure') }}" == "true" ] || [ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]; then
@@ -320,6 +330,10 @@ jobs:
320330
fi
321331
322332
echo "All required notebooks passed successfully"
333+
env:
334+
NEEDS_DOC_ONLY_CHECK_OUTPUTS_RUN_NOTEBOOKS: ${{ needs.doc_only_check.outputs.run_notebooks }}
335+
NEEDS_BUILD_AND_UPLOAD_MAXTEXT_PACKAGE_RESULT: ${{ needs.build_and_upload_maxtext_package.result }}
336+
NEEDS_MAXTEXT_JUPYTER_NOTEBOOKS_RESULT: ${{ needs.maxtext_jupyter_notebooks.result }}
323337

324338
notify_failure:
325339
name: Notify failed build # creates an issue or modifies last open existing issue for failed build

.github/workflows/run_tests_against_package.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ jobs:
101101
- name: Run Tests
102102
shell: bash
103103
run: |
104-
if [ "${{ inputs.is_scheduled_run }}" == "true" ]; then
105-
FINAL_PYTEST_MARKER="${{ inputs.pytest_marker }}"
104+
if [ "${INPUTS_IS_SCHEDULED_RUN}" == "true" ]; then
105+
FINAL_PYTEST_MARKER="${INPUTS_PYTEST_MARKER}"
106106
else
107-
FINAL_PYTEST_MARKER="${{ inputs.pytest_marker }} and not scheduled_only"
107+
FINAL_PYTEST_MARKER="${INPUTS_PYTEST_MARKER} and not scheduled_only"
108108
fi
109109
# TODO: Use package data for testing and remove the env vars
110110
export MAXTEXT_REPO_ROOT=$(pwd)
111111
export MAXTEXT_ASSETS_ROOT=$(pwd)/src/maxtext/assets
112112
export MAXTEXT_TEST_ASSETS_ROOT=$(pwd)/tests/assets
113113
export MAXTEXT_PKG_DIR=$(pwd)/src/maxtext
114114
# omit this libtpu init args for gpu tests
115-
if [ "${{ inputs.device_type }}" != "cuda12" ]; then
115+
if [ "${INPUTS_DEVICE_TYPE}" != "cuda12" ]; then
116116
export LIBTPU_INIT_ARGS='--xla_tpu_scoped_vmem_limit_kib=65536'
117117
fi
118118
if [ "${{ inputs.total_workers }}" -gt 1 ]; then
@@ -122,7 +122,7 @@ jobs:
122122
SPLIT_ARGS=""
123123
fi
124124
# TODO: Fix the skipped tests and remove the deselect flags
125-
.venv/bin/python3 -m pytest ${{ inputs.pytest_addopts }} \
125+
.venv/bin/python3 -m pytest ${INPUTS_PYTEST_ADDOPTS} \
126126
-v \
127127
-m "${FINAL_PYTEST_MARKER}" \
128128
--durations=0 \
@@ -134,6 +134,10 @@ jobs:
134134
$SPLIT_ARGS
135135
env:
136136
PYTHONPATH: "${{ github.workspace }}/src"
137+
INPUTS_IS_SCHEDULED_RUN: ${{ inputs.is_scheduled_run }}
138+
INPUTS_PYTEST_MARKER: ${{ inputs.pytest_marker }}
139+
INPUTS_DEVICE_TYPE: ${{ inputs.device_type }}
140+
INPUTS_PYTEST_ADDOPTS: ${{ inputs.pytest_addopts }}
137141
- name: Upload results to Codecov
138142
uses: codecov/codecov-action@v5
139143
continue-on-error: true

0 commit comments

Comments
 (0)