Skip to content

Commit c3f4116

Browse files
committed
Trigger unit tests for docker images upload workflow
- images will only be tagged with date and to "latest" when tests pass
1 parent 77686b6 commit c3f4116

4 files changed

Lines changed: 78 additions & 10 deletions

File tree

.github/workflows/UploadDockerImages.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# This workflow builds and pushes MaxText images for both TPU and GPU devices.
1616
# It runs automatically daily at 12am UTC, on Pull Requests, or manually via Workflow Dispatch.
1717

18-
name: Build Images
18+
name: Build and Test Images
1919

2020
on:
2121
schedule:
@@ -32,6 +32,11 @@ on:
3232
- all
3333
- tpu
3434
- gpu
35+
for_dev_test:
36+
description: 'For development test purpose. All images will be added a -test suffix'
37+
required: false
38+
type: boolean
39+
default: false
3540

3641
permissions:
3742
contents: read
@@ -42,6 +47,7 @@ jobs:
4247
outputs:
4348
maxtext_sha: ${{ steps.vars.outputs.maxtext_sha }}
4449
image_date: ${{ steps.vars.outputs.image_date }}
50+
image_suffix: ${{ steps.vars.outputs.image_suffix }}
4551
steps:
4652
- name: Checkout MaxText
4753
uses: actions/checkout@v5
@@ -55,6 +61,13 @@ jobs:
5561
# Image date
5662
echo "image_date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
5763
64+
# If for_dev_test is true, set suffix to -test, otherwise empty
65+
if [[ "${{ github.event.inputs.for_dev_test }}" == "true" ]]; then
66+
echo "image_suffix=-test" >> $GITHUB_OUTPUT
67+
else
68+
echo "image_suffix=" >> $GITHUB_OUTPUT
69+
fi
70+
5871
tpu-pre-training:
5972
name: ${{ matrix.image_name }}
6073
needs: setup
@@ -72,7 +85,7 @@ jobs:
7285
dockerfile: ./src/dependencies/dockerfiles/maxtext_tpu_dependencies.Dockerfile
7386
uses: ./.github/workflows/build_and_push_docker_image.yml
7487
with:
75-
image_name: ${{ matrix.image_name }}
88+
image_name: ${{ matrix.image_name }}${{ needs.setup.outputs.image_suffix }}
7689
device: ${{ matrix.device }}
7790
build_mode: ${{ matrix.build_mode }}
7891
dockerfile: ${{ matrix.dockerfile }}
@@ -84,7 +97,7 @@ jobs:
8497
needs: [setup]
8598
uses: ./.github/workflows/build_and_push_docker_image.yml
8699
with:
87-
image_name: maxtext_post_training_nightly
100+
image_name: maxtext_post_training_nightly${{ needs.setup.outputs.image_suffix }}
88101
device: tpu
89102
build_mode: nightly
90103
workflow: post-training
@@ -109,7 +122,7 @@ jobs:
109122
dockerfile: ./src/dependencies/dockerfiles/maxtext_gpu_dependencies.Dockerfile
110123
uses: ./.github/workflows/build_and_push_docker_image.yml
111124
with:
112-
image_name: ${{ matrix.image_name }}
125+
image_name: ${{ matrix.image_name }}${{ needs.setup.outputs.image_suffix }}
113126
device: ${{ matrix.device }}
114127
build_mode: ${{ matrix.build_mode }}
115128
dockerfile: ${{ matrix.dockerfile }}

.github/workflows/build_and_push_docker_image.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
github.event.inputs.target_device == 'tpu' ||
6363
github.event.inputs.target_device == 'gpu'
6464
)
65+
outputs:
66+
should_run: ${{ steps.check.outputs.should_run }} # Map the step output to the job level
6567
steps:
6668
- name: Check if build should run
6769
id: check
@@ -121,28 +123,80 @@ jobs:
121123
LIBTPU_VERSION=NONE
122124
INCLUDE_TEST_ASSETS=true
123125
126+
test:
127+
needs: build_and_push
128+
if: |
129+
needs.build_and_push.result == 'success' &&
130+
needs.build_and_push.outputs.should_run == 'true'
131+
strategy:
132+
fail-fast: false
133+
matrix:
134+
flavor: >-
135+
${{ fromJSON('{
136+
"gpu-pre-training": ["gpu-unit", "gpu-integration"],
137+
"tpu-post-training": ["post-training-tpu-unit", "post-training-tpu-integration", "post-training-cpu-unit"],
138+
"tpu-pre-training": ["tpu-unit", "tpu-integration", "cpu-unit"]
139+
}')[format('{0}-{1}', inputs.device, inputs.workflow)] }}
140+
uses: ./.github/workflows/run_tests_coordinator.yml
141+
with:
142+
flavor: ${{ matrix.flavor }}
143+
base_image: ${{ inputs.image_name }}:${{ github.run_id }}
144+
is_scheduled_run: true
145+
maxtext_installed: true
146+
147+
notebook-test:
148+
needs: build_and_push
149+
if: |
150+
inputs.device == 'tpu' &&
151+
inputs.workflow = 'post-training' &&
152+
needs.build_and_push.result == 'success' &&
153+
needs.build_and_push.outputs.should_run == 'true'
154+
uses: ./.github/workflows/run_jupyter_notebooks.yml
155+
with:
156+
device_type: tpu
157+
device_name: v6e-4
158+
base_image: ${{ inputs.image_name }}:${{ github.run_id }}
159+
cloud_runner: linux-x86-ct6e-180-4tpu
160+
maxtext_installed: true
161+
secrets:
162+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
163+
164+
tagging:
165+
needs: [test, notebook-test]
166+
if: |
167+
always() &&
168+
needs.test.result == 'success' &&
169+
(needs.notebook-test.result == 'success' || needs.notebook-test.result == 'skipped')
170+
runs-on: linux-x86-n2-16-buildkit
171+
container: google/cloud-sdk:524.0.0
172+
steps:
173+
- name: Configure Docker
174+
run: gcloud auth configure-docker us-docker.pkg.dev,gcr.io -q
175+
124176
- name: Add tags to Docker image
125-
if: steps.check.outputs.should_run == 'true'
126177
shell: bash
127178
run: |
128179
SOURCE_IMAGE="gcr.io/tpu-prod-env-multipod/${INPUTS_IMAGE_NAME}"
180+
TEMP_IMG="${SOURCE_IMAGE}:${{ github.run_id }}"
129181
130182
if [[ $INPUTS_VERSION_NAME ]]; then
131183
echo "Tagging docker images corresponding to PyPI release..."
132-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:${INPUTS_VERSION_NAME}" --quiet
184+
gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:${INPUTS_VERSION_NAME}" --quiet
133185
else
134186
echo "Tagging docker images corresponding to nightly release..."
135187
136188
# Add date tag
137-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
189+
gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
138190
139191
# Convert date to YYYYMMDD format
140192
clean_date=$(echo "${INPUTS_IMAGE_DATE}" | sed 's/[-:]//g' | cut -c1-8)
141193
142194
# Add MaxText tag
143195
maxtext_hash=$(git rev-parse --short HEAD)
144-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:maxtext_${maxtext_hash}_${clean_date}" --quiet
145-
fi
196+
gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:maxtext_${maxtext_hash}_${clean_date}" --quiet
197+
198+
# Latest Tag
199+
gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:latest" --quiet
146200
env:
147201
INPUTS_IMAGE_NAME: ${{ inputs.image_name }}
148202
INPUTS_IMAGE_DATE: ${{ inputs.image_date }}

.github/workflows/pypi_release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ jobs:
123123
dockerfile: ${{ matrix.dockerfile }}
124124
maxtext_sha: ${{ github.sha }}
125125
version_name: ${{ needs.get_latest_maxtext_pypi_version.outputs.latest_pypi_version }}
126+
test_mode: ${{ matrix.device}}-${{ matrix.workflow }}

.github/workflows/run_tests_against_package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
uv pip install pytest-cov
138138
PYTEST_COV_ARGS="--cov=MaxText --cov=maxtext --cov-report=xml --cov-report=term"
139139
fi
140+
export PYTHONPATH="${pwd}/src${PYTHONPATH:+:${PYTHONPATH}}"
140141
141142
if [ "${INPUTS_IS_SCHEDULED_RUN}" == "true" ]; then
142143
FINAL_PYTEST_MARKER="${INPUTS_PYTEST_MARKER}"
@@ -168,7 +169,6 @@ jobs:
168169
${INPUTS_PYTEST_EXTRA_ARGS}
169170
170171
env:
171-
PYTHONPATH: "${{ github.workspace }}/src"
172172
INPUTS_IS_SCHEDULED_RUN: ${{ inputs.is_scheduled_run }}
173173
INPUTS_PYTEST_MARKER: ${{ inputs.pytest_marker }}
174174
INPUTS_DEVICE_TYPE: ${{ inputs.device_type }}

0 commit comments

Comments
 (0)