-
Notifications
You must be signed in to change notification settings - Fork 21
262 lines (254 loc) · 11.1 KB
/
ci_unit_test.yml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
name: CI-UnitTest
on:
# This workflow includes AWS credential to run jobs on AWS batch.
# Thus, this workflow cannot checkout PRs and can only be triggered by CI-Lint.
workflow_run:
workflows: ["CI-Lint"]
types:
- completed
defaults:
run:
shell: bash
jobs:
check_status:
if: github.repository == 'awslabs/raf'
runs-on: ubuntu-latest
outputs:
cpu_image: "metaprojdev/raf:ci_cpu-v0.21"
gpu_image: "metaprojdev/raf:ci_gpu-v0.23"
skip_ci: ${{ steps.job_info.outputs.skip_ci }}
ref: ${{ steps.job_info.outputs.ref }}
repo: ${{ steps.job_info.outputs.repo }}
pr: ${{ steps.pr_job_info.outputs.pr }}
sha: ${{ steps.pr_job_info.outputs.sha }}
job_tag: ${{ steps.gen_tag.outputs.tag }}
steps:
# The workflow triggered by workflow run will not show its status
# in Github by default, so we have to use this action to enable it.
# Note that when this action is used, "name" in job is unavailable:
# https://github.com/haya14busa/action-workflow_run-status/issues/158
- uses: haya14busa/action-workflow_run-status@v1
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci_lint.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Parse common job info
id: job_info
run: |
skip_ci=$(head -n 1 artifact/skip.txt)
echo "skip_ci=${skip_ci}" >> $GITHUB_OUTPUT
ref=$(head -n 1 artifact/ref.txt)
echo "ref=${ref}" >> $GITHUB_OUTPUT
repo=$(head -n 1 artifact/repo.txt)
echo "repo=${repo}" >> $GITHUB_OUTPUT
lint=${{ github.event.workflow_run.conclusion }}
echo "Linting result: ${lint}"
- name: Parse PR job info
id: pr_job_info
continue-on-error: true
# Note that pr and sha only available for pull request, and will be empty for push events.
run: |
pr=$(head -n 1 artifact/pr.txt)
echo "pr=${pr}" >> $GITHUB_OUTPUT
sha=$(head -n 1 artifact/sha.txt)
echo "sha=${sha}" >> $GITHUB_OUTPUT
- name: Generate tag
id: gen_tag
# This tag is PR-unique so it can be used to connect jobs for the same PR.
# For example, we use it to share ccache caches and cancel previous runs.
run: |
tag=${{ steps.job_info.outputs.repo }}/${{ steps.pr_job_info.outputs.pr }}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Whether linting was failed
if: ${{ github.event.workflow_run.conclusion != 'success' }}
run: exit 1
test_on_cpu:
needs: [check_status]
if: github.repository == 'awslabs/raf'
runs-on: ubuntu-latest
steps:
- uses: haya14busa/action-workflow_run-status@v1
- name: List environments
run: |
echo "Job tag: ${{ needs.check_status.outputs.job_tag }}"
echo "Skip CI? ${{ needs.check_status.outputs.skip_ci }}"
echo "REF: ${{ needs.check_status.outputs.ref }}"
echo "REPO: ${{ needs.check_status.outputs.repo }}"
echo "PR: ${{ needs.check_status.outputs.pr }}"
echo "SHA: ${{ needs.check_status.outputs.sha }}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_BATCH_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_BATCH_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Checkout repository
# No need to checkout submodules because we only need the script.
uses: actions/checkout@v2
- name: Test
run: |
# env vars are unavailable in job.if so we have to implement it here.
if [ "${{ needs.check_status.outputs.skip_ci }}" == "1" ]; then
echo "Skip CPU tests"
exit 0
fi
echo "Running tests on CPU"
python3 -m pip install argparse boto3
python3 ./ci/batch/submit-job.py \
--platform CPU \
--image ${{ needs.check_status.outputs.cpu_image }} \
--name ci-cpu-${{ needs.check_status.outputs.job_tag }} \
--job-queue ci-cpu-queue \
--job-def-cfg ./ci/batch/job-def-cfg.json \
--entry-script /batch/entry.sh \
--source-ref ${{ needs.check_status.outputs.ref }} \
--repo ${{ needs.check_status.outputs.repo }} \
--wait \
--command "bash ./ci/batch/cli.sh config_cmake CPU &&
bash ./ci/batch/cli.sh compile build CPU ${{ needs.check_status.outputs.job_tag }} &&
bash ./ci/batch/cli.sh unit_test CPU"
test_on_gpu:
needs: [check_status]
if: github.repository == 'awslabs/raf'
runs-on: ubuntu-latest
steps:
- uses: haya14busa/action-workflow_run-status@v1
- name: List environments
run: |
echo "Job tag: ${{ needs.check_status.outputs.job_tag }}"
echo "Skip CI? ${{ needs.check_status.outputs.skip_ci }}"
echo "REF: ${{ needs.check_status.outputs.ref }}"
echo "REPO: ${{ needs.check_status.outputs.repo }}"
echo "PR: ${{ needs.check_status.outputs.pr }}"
echo "SHA: ${{ needs.check_status.outputs.sha }}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_BATCH_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_BATCH_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Checkout repository
# No need to checkout submodules because we only need the script.
uses: actions/checkout@v2
- name: Test
run: |
# env vars are unavailable in job.if so we have to implement it here.
if [ "${{ needs.check_status.outputs.skip_ci }}" == "1" ]; then
echo "Skip GPU tests"
exit 0
fi
echo "Running tests on GPU"
python3 -m pip install argparse boto3
python3 ./ci/batch/submit-job.py \
--platform GPU \
--image ${{ needs.check_status.outputs.gpu_image }} \
--name ci-gpu-${{ needs.check_status.outputs.job_tag }} \
--job-queue ci-gpu-queue \
--job-def-cfg ./ci/batch/job-def-cfg.json \
--entry-script /batch/entry.sh \
--source-ref ${{ needs.check_status.outputs.ref }} \
--repo ${{ needs.check_status.outputs.repo }} \
--wait \
--command "bash ./ci/batch/cli.sh config_cmake GPU 75 &&
bash ./ci/batch/cli.sh compile build GPU ${{ needs.check_status.outputs.job_tag }} &&
bash ./ci/batch/cli.sh unit_test GPU"
test_on_multi_gpu:
needs: [check_status]
if: github.repository == 'awslabs/raf'
runs-on: ubuntu-latest
steps:
- uses: haya14busa/action-workflow_run-status@v1
- name: List environments
run: |
echo "Job tag: ${{ needs.check_status.outputs.job_tag }}"
echo "Skip CI? ${{ needs.check_status.outputs.skip_ci }}"
echo "REF: ${{ needs.check_status.outputs.ref }}"
echo "REPO: ${{ needs.check_status.outputs.repo }}"
echo "PR: ${{ needs.check_status.outputs.pr }}"
echo "SHA: ${{ needs.check_status.outputs.sha }}"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_BATCH_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_BATCH_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Checkout repository
# No need to checkout submodules because we only need the script.
uses: actions/checkout@v2
- name: Test
run: |
# env vars are unavailable in job.if so we have to implement it here.
if [ "${{ needs.check_status.outputs.skip_ci }}" == "1" ]; then
echo "Skip multi-GPU tests"
exit 0
fi
echo "Running tests on Multiply GPUs"
python3 -m pip install argparse boto3
python3 ./ci/batch/submit-job.py \
--platform multi-GPU \
--image ${{ needs.check_status.outputs.gpu_image }} \
--name ci-multi-gpu-${{ needs.check_status.outputs.job_tag }} \
--job-queue ci-gpu-queue \
--job-def-cfg ./ci/batch/job-def-cfg.json \
--entry-script /batch/entry.sh \
--source-ref ${{ needs.check_status.outputs.ref }} \
--repo ${{ needs.check_status.outputs.repo }} \
--wait \
--command "bash ./ci/batch/cli.sh config_cmake GPU 75 &&
bash ./ci/batch/cli.sh compile build multi-GPU ${{ needs.check_status.outputs.job_tag }} &&
bash ./ci/batch/cli.sh unit_test multi-GPU"
update_ci_badge:
needs: [test_on_cpu, test_on_gpu, test_on_multi_gpu]
# Run this job whatever the unit tests were success or not.
if: ${{ always() && github.repository == 'awslabs/raf' }}
runs-on: ubuntu-latest
steps:
- uses: haya14busa/action-workflow_run-status@v1
- name: Checkout repository
# No need to checkout submodules because we only need to get the HEAD commit hash.
uses: actions/checkout@v2
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci_lint.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Parse PR job info
id: pr_job_info
continue-on-error: true
# Note that pr and sha only available for pull request, and will be empty for push events.
run: |
pr=$(head -n 1 artifact/pr.txt)
echo "pr=${pr}" >> $GITHUB_OUTPUT
- name: Generate CI badge
id: badge
run: |
# env vars are unavailable in job.if so we have to implement it here.
if [ "${{ steps.pr_job_info.outputs.pr }}" != "" ]; then
echo "No need to update badge for PR CI. Skip."
exit 0
fi
echo "gist_id=a3f4a76704e40ddba1b73fb0ad072eb9" >> $GITHUB_OUTPUT
head_commit=$(git rev-parse --short HEAD)
if [[ "${{ needs.test_on_cpu.result }}" == "success" &&
"${{ needs.test_on_gpu.result }}" == "success" &&
"${{ needs.test_on_multi_gpu.result }}" == "success" ]]; then
echo "message=passing (${head_commit})" >> $GITHUB_OUTPUT
echo "color=success" >> $GITHUB_OUTPUT
else
echo "message=failing (${head_commit})" >> $GITHUB_OUTPUT
echo "color=critical" >> $GITHUB_OUTPUT
fi
- name: Update CI badge
# Intentionally fail this step with empty gist_id.
uses: schneegans/dynamic-badges-action@v1.1.0
continue-on-error: true
with:
auth: ${{ secrets.BOT_TOKEN }}
gistID: ${{ steps.badge.outputs.gist_id }}
filename: awslabs-raf-ci-badge-last-pass.json
label: CI-UnitTests
message: ${{ steps.badge.outputs.message }}
color: ${{ steps.badge.outputs.color }}