forked from NOAA-GSL/ufs-weather-model
-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (150 loc) · 4.96 KB
/
build_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
name: Pull Request Tests
on:
pull_request:
branches: ['develop']
types: ['labeled']
env:
app: Accept:application/vnd.github.v3+json
jobs:
repocheck:
name: Check if repos are up to date
runs-on: ubuntu-20.04
outputs:
current: ${{ steps.check.outputs.current }}
steps:
- uses: actions/checkout@v2
- name: Wait for caching source
run: sleep 30
- uses: actions/cache@v2
with:
path: ~/id_file
key: helperid-${{ github.run_id }}
- name: Wait until repocheck in aux is complete
run: |
helper_id=$(cat ~/id_file)
cd ${{ github.workspace }}/tests/ci
jobs_url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$helper_id/jobs
conclusion=$(echo $jobs_url | ./check_status.py completion "Repo check")
if [[ $conclusion == "failure" ]]; then
exit 1
fi
- uses: actions/cache@v2
with:
path: ~/repocheck_file
key: repocheck-${{ github.run_id }}
- name: Set repocheck currency flag
id: check
run: |
repocheck_result=$(cat ~/repocheck_file)
if [[ $repocheck_result == success ]]; then
echo "::set-output name=current::yes"
elif [[ $repocheck_result == failure ]]; then
echo "::set-output name=current::no"
fi
setup:
name: Configure cases to run
needs: [repocheck]
runs-on: ubuntu-20.04
if: needs.repocheck.outputs.current == 'yes' && github.event.label.name == 'run-ci'
outputs:
bld: ${{ steps.parse.outputs.bld }}
test: ${{ steps.parse.outputs.test }}
img: ${{ steps.parse.outputs.img }}
steps:
- uses: actions/checkout@v2
- name: Collect cases to run
id: parse
run: |
cd ${{ github.workspace }}/tests/ci
IFS='|'; parsed_output=( $(./setup.py) )
bld_=${parsed_output[0]}
test_=${parsed_output[1]}
img_=ci-test-weather
echo "::set-output name=bld::$bld_"
echo "::set-output name=test::$test_"
echo "::set-output name=img::$img_"
echo "build set : $bld_"
echo "test set : $test_"
echo "image name: $img_"
echo "repocheck: ${{needs.repocheck.outputs.current}}"
build:
name: Build ${{ matrix.bld_set }}
needs: setup
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.bld) }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
run: |
printf '{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json >/dev/null
sudo systemctl restart docker
sleep 10
cd tests/ci && ./ci.sh -n ${{ matrix.name }} -b ${{ matrix.case }}
- name: Free up disk space
run: |
sudo docker rmi $(sudo docker image ls | grep -E -m1 '<none>' | awk '{ print $3 }')
sudo docker rmi $(sudo docker image ls | awk '/ubuntu-hpc/ { print $3 }')
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.bld_set }}.artifact
path: ~/fv3.tar.gz
wait:
name: Wait for ec2 instances to start
needs: build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/id_file
key: helperid-${{ github.run_id }}
- name: Check if ec2 instances started
run: |
cd ${{ github.workspace }}/tests/ci
helper_id=$(cat ~/id_file)
url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$helper_id/jobs
ec2_started=$(echo -n $url | ./check_status.py completion "Start runners")
if [ $ec2_started != 'success' ]; then
echo "ec2 instances did not start"
exit 1
fi
utest:
name: Test ${{ matrix.test_set }}
needs: [setup,build,wait]
runs-on: self-hosted
#runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.test) }}
steps:
- name: Clean up in case of left-over files
run: |
rm -rf ${{ github.workspace }} && mkdir -p ${{ github.workspace }}
docker ps -a --filter "name=my-container" | grep my-container >/dev/null 2>&1 \
&& docker rm my-container >/dev/null 2>&1 && d=$? || d=$?
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact }}.artifact
path: ${{ github.workspace}}/tests
- name: Run utest
run: |
cd ${{ github.workspace }}/tests && tar -xvzf fv3.tar.gz && rm -f fv3.tar.gz
cd ${{ github.workspace }}/tests/ci
./ci.sh -n ${{ matrix.name }} -r ${{ matrix.case }}
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: memory_stat_${{ matrix.test_set }}
path: memory_stat
- name: Clean up
if: ${{ always() }}
run: |
docker stop my-container && docker rm my-container
docker volume rm DataVolume