1818# 2. If the DAG succeeded, it promotes the Docker images by tagging the artifact with the latest tag.
1919
2020name : Promote MaxText Docker Image
21+ run-name : " Triggered by Airflow ${{ github.event.client_payload.test_type }} Tests DAG"
2122
2223on :
2324 repository_dispatch :
@@ -39,11 +40,11 @@ jobs:
3940 DAG_ID : ${{ github.event.client_payload.dag_id }}
4041 DAG_RUN_ID : ${{ github.event.client_payload.dag_run_id }}
4142 SHA : ${{ github.event.client_payload.sha }}
42- GITHUB_RUN_ID : ${{ github.event.client_payload.github_run_id }}
43+ CALLER_RUN_ID : ${{ github.event.client_payload.github_run_id }}
4344 TEST_TYPE : ${{ github.event.client_payload.test_type }}
4445 run : |
4546 echo "================================"
46- echo "Github Run ID: ${GITHUB_RUN_ID }"
47+ echo "Github Run ID: ${CALLER_RUN_ID }"
4748 echo "DAG ID: ${DAG_ID}"
4849 echo "DAG Run ID: ${DAG_RUN_ID}"
4950 echo "Commit SHA: ${SHA}"
@@ -57,16 +58,16 @@ jobs:
5758 *) echo "DAG ended with unexpected state: ${STATE}"; exit 1 ;;
5859 esac
5960
60- if [ -n "$GITHUB_RUN_ID " ]; then
61- echo "Checking nightly build status for run: $GITHUB_RUN_ID "
62- gh run watch "$GITHUB_RUN_ID " --exit-status --interval 60 --repo "$GITHUB_REPOSITORY"
61+ if [ -n "$CALLER_RUN_ID " ]; then
62+ echo "Checking nightly build status for run: $CALLER_RUN_ID "
63+ gh run watch "$CALLER_RUN_ID " --exit-status --interval 60 --repo "$GITHUB_REPOSITORY"
6364 else
6465 echo "Error: No Github Run ID provided. Cannot verify nightly build status."
6566 exit 1
6667 fi
6768
6869 tag_docker_image :
69- name : Promote ${{ matrix.image_name }} Docker Image
70+ name : Promote ${{ matrix.test_type }} Docker Image
7071 needs : handle_result
7172 if : needs.handle_result.result == 'success'
7273 runs-on : linux-x86-n2-16-buildkit
@@ -76,13 +77,11 @@ jobs:
7677 matrix :
7778 include :
7879 - test_type : pre_training
79- image_name : maxtext_jax_nightly
80+ stable_image_name : maxtext_jax_stable
81+ nightly_image_name : maxtext_jax_nightly
8082 - test_type : post_training
81- image_name : maxtext_post_training_nightly
82- - test_type : pre_training
83- image_name : maxtext_jax_stable
84- - test_type : post_training
85- image_name : maxtext_post_training_stable
83+ stable_image_name : maxtext_post_training_stable
84+ nightly_image_name : maxtext_post_training_nightly
8685 steps :
8786 - name : Configure Docker
8887 if : ${{ github.event.client_payload.test_type == '' || github.event.client_payload.test_type == matrix.test_type }}
@@ -91,15 +90,33 @@ jobs:
9190 if : ${{ github.event.client_payload.test_type == '' || github.event.client_payload.test_type == matrix.test_type }}
9291 shell : bash
9392 env :
94- GITHUB_RUN_ID : ${{ github.event.client_payload.github_run_id }}
93+ CALLER_RUN_ID : ${{ github.event.client_payload.github_run_id }}
9594 PROJECT_NAME : ${{ vars.PROJECT_NAME }}
96- IMAGE_NAME : ${{ matrix.image_name }}
95+ STABLE_IMAGE_NAME : ${{ matrix.stable_image_name }}
96+ NIGHTLY_IMAGE_NAME : ${{ matrix.nightly_image_name }}
9797 run : |
98- SOURCE_IMAGE="gcr.io/${PROJECT_NAME}/${IMAGE_NAME}"
98+ tag_image() {
99+ local img="$1"
100+ local tag="$2"
101+ echo "Tagging ${img}:${CALLER_RUN_ID} as ${tag}..."
102+ gcloud container images add-tag "${img}:${CALLER_RUN_ID}" "${img}:${tag}" --quiet
103+ }
99104
100- # Add the traceability tag to confirm it passed validation suite
101- gcloud container images add-tag "${SOURCE_IMAGE}:${GITHUB_RUN_ID}" \
102- "${SOURCE_IMAGE}:verified-${GITHUB_RUN_ID}" --quiet
105+ # 1. Check if stable image exists and tag it
106+ STABLE_IMAGE="gcr.io/${PROJECT_NAME}/${STABLE_IMAGE_NAME}"
107+ if gcloud container images describe "${STABLE_IMAGE}:${CALLER_RUN_ID}" >/dev/null 2>&1; then
108+ echo "Stable image ${STABLE_IMAGE}:${CALLER_RUN_ID} exists. Tagging stable image..."
109+ tag_image "${STABLE_IMAGE}" "verified-e2e-${CALLER_RUN_ID}"
110+ tag_image "${STABLE_IMAGE}" "latest"
111+ else
112+ echo "Stable image ${STABLE_IMAGE}:${CALLER_RUN_ID} does not exist. Skipping stable image tagging."
113+ fi
103114
104- # Add "latest" tag
105- gcloud container images add-tag "${SOURCE_IMAGE}:${GITHUB_RUN_ID}" "${SOURCE_IMAGE}:latest" --quiet
115+ # 2. Check if nightly image exists and tag it
116+ NIGHTLY_IMAGE="gcr.io/${PROJECT_NAME}/${NIGHTLY_IMAGE_NAME}"
117+ if gcloud container images describe "${NIGHTLY_IMAGE}:${CALLER_RUN_ID}" >/dev/null 2>&1; then
118+ echo "Nightly image ${NIGHTLY_IMAGE}:${CALLER_RUN_ID} exists. Tagging nightly image..."
119+ tag_image "${NIGHTLY_IMAGE}" "latest"
120+ else
121+ echo "Nightly image ${NIGHTLY_IMAGE}:${CALLER_RUN_ID} does not exist. Skipping nightly image tagging."
122+ fi
0 commit comments