Repository navigation
89 lines (78 loc) · 3.05 KB
/
Copy pathrun_e2e_tests.yml
File metadata and controls
89 lines (78 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright 2023-2026 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will trigger the MaxText E2E Airflow DAG to run the E2E tests.
name: MaxText E2E Airflow Tests
on:
workflow_call:
inputs:
mode:
description: 'Build mode: stable or nightly'
required: true
type: string
run_id:
description: 'GitHub workflow run_id to be passed to the Airflow DAG run.'
required: true
type: string
maxtext_sha:
description: 'GitHub SHA of MaxText to be passed to the Airflow DAG run.'
required: true
type: string
secrets:
AIRFLOW_CALLBACK_TOKEN:
required: false
permissions:
contents: read
jobs:
e2e_airflow_tests:
name: E2E Airflow Tests
runs-on: linux-x86-n2-16-buildkit
container: google/cloud-sdk:524.0.0
steps:
- name: Get Airflow URI
id: info
run: |
AIRFLOW_URI=$(gcloud composer environments describe ml-automation-solutions \
--location us-central1 \
--project cloud-ml-auto-solutions \
--format "value(config.airflowUri)")
echo "airflow_uri=${AIRFLOW_URI}" >> "$GITHUB_OUTPUT"
- name: Trigger DAG
env:
AIRFLOW_URI: ${{ steps.info.outputs.airflow_uri }}
BUILD_MODE: ${{ inputs.mode }}
COMMIT_SHA: ${{ inputs.maxtext_sha }}
RUN_ID: ${{ inputs.run_id }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.AIRFLOW_CALLBACK_TOKEN }}
run: |
IAP_TOKEN=$(gcloud auth print-access-token)
PAYLOAD=$(python3 -c 'import json, os
print(json.dumps({
"conf": {
"build_mode": os.environ["BUILD_MODE"],
"commit_sha": os.environ["COMMIT_SHA"],
"github_run_id": os.environ["RUN_ID"],
"github_repo": os.environ["GITHUB_REPO"],
"github_token": os.environ["GITHUB_TOKEN"],
}
}))')
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
"${AIRFLOW_URI}/api/v1/dags/maxtext_e2e_tests/dagRuns" \
-H "Authorization: Bearer ${IAP_TOKEN}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD")
HTTP_STATUS=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')
echo "Response body: ${BODY}"
if [ "${HTTP_STATUS}" -lt 200 ] || [ "${HTTP_STATUS}" -ge 300 ]; then
echo "Error: Airflow API returned HTTP ${HTTP_STATUS}"
exit 1
fi