-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yaml
319 lines (299 loc) · 11.5 KB
/
action.yaml
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: NUOPC Component Testing Action
author: Ufuk Turuncoglu (ESMF/CGD/NCAR)
description: Tests given earth system model component in a isolated way forced by data component
inputs:
app_install_dir:
description: installation directory for apps such as components
required: false
default: ${{ github.workspace }}/app
architecture:
description: spack target architecture
required: false
default: x86_64
artifacts_files:
description: list of files that will be pushed to artifacts
required: false
default: None
artifacts_name:
description: artifact name
required: false
default: artifacts for ${{ github.workflow }}
artifacts_retention_period:
description: custom retention period for individual artifacts
required: false
default: 2
baseline_files:
description: lit of files that will be used to create baseline file
required: false
default: None
cache_input_file_list:
description: list of input files that needs to be cached
required: false
compiler:
description: compiler that will be used
required: false
default: [email protected]
component_name:
description: component name
required: false
default: ${{ github.event.repository.name }}
component_build:
description: component build script
required: true
component_module_name:
description: name of the component module
required: true
data_component_name:
description: data component name
required: false
default: datm
debug:
description: enable debug capability
required: false
default: OFF
dependencies:
description: list of packages to install
required: true
dependencies_install_dir:
description: spack dependency installation directory
required: false
default: ~/.spack-ci
mpirun_args:
description: atguments that will be used in mpirun command
required: true
test_definition:
description: YAML file that describes the test
required: true
runs:
using: "composite"
steps:
# checkout base repository
- name: Checkout Component Repository
uses: actions/checkout@v3
with:
path: ${{ inputs.app_install_dir }}/${{ inputs.component_name }}
# prepare core environment
- name: Install Core Development Tools
run: |
sudo apt-get -qq update
sudo apt-get -qq install tar unzip file gringo
sudo apt-get -qq install build-essential binutils-dev gfortran
sudo apt-get -qq install python3-dev python3-pip python3-boto3 python3-yaml
sudo apt-get -qq install wget awscli ca-certificates gh libxml2-dev
pip3 install --target ~/.local botocore
shell: bash
# concretize dependencies
- name: Concretize Spack Environment Using YAML Specification
run: |
echo "${{ inputs.dependencies }}"
$GITHUB_ACTION_PATH/scripts/concretize_deps.sh \
-a ${{ inputs.architecture }} \
-c ${{ inputs.compiler }} \
-d "$(echo "${{ inputs.dependencies }}" | sed -z 's/\n/:/g' | sed 's/:$//')" \
-i ${{ inputs.dependencies_install_dir }} \
-r $GITHUB_WORKSPACE
shell: bash
# restore dependencies from cache
- name: Restore Dependencies
uses: actions/cache@v3
with:
path: ${{ inputs.dependencies_install_dir }}
key: spack-${{ runner.os }}-${{ inputs.architecture }}-${{ hashFiles('**/spack.lock') }}
restore-keys: |
spack-${{ runner.os }}-${{ inputs.architecture }}-${{ hashFiles('**/spack.lock') }}
# install dependencies
- name: Install Dependencies with Spack
run: |
$GITHUB_ACTION_PATH/scripts/install_deps.sh \
-i "${{ inputs.dependencies_install_dir }}" \
-r "$GITHUB_WORKSPACE"
shell: bash
# checkout data models
- name: Checkout CDEPS
uses: actions/checkout@v3
with:
repository: uturuncoglu/CDEPS
path: ${{ inputs.app_install_dir }}/cdeps
ref: hotfix/std_build
# build and install data models
- name: Build and Install CDEPS
run: |
export PATH=${{ inputs.dependencies_install_dir }}/view/bin:$PATH
export ESMFMKFILE=${{ inputs.dependencies_install_dir }}/view/lib/esmf.mk
export FC=gfortran
cd ${{ inputs.app_install_dir }}/cdeps
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=${{ inputs.app_install_dir }} \
-DPIO_C_LIBRARY=${{ inputs.dependencies_install_dir }}/view/lib \
-DPIO_C_INCLUDE_DIR=${{ inputs.dependencies_install_dir }}/view/include \
-DPIO_Fortran_LIBRARY=${{ inputs.dependencies_install_dir }}/view/lib \
-DPIO_Fortran_INCLUDE_DIR=${{ inputs.dependencies_install_dir }}/view/include \
-DCMAKE_Fortran_FLAGS="-ffree-line-length-none -fallow-argument-mismatch -fallow-invalid-boz" \
-DDISABLE_FoX=ON ../
make
make install
shell: bash
# build component
- name: Build and Install Component
run: |
cd ${{ inputs.app_install_dir }}
echo "${{ inputs.component_build }}" >> install_comp.sh
chmod 755 install_comp.sh
./install_comp.sh
shell: bash
# use ESMX generic driver and create executable
- name: Use ESMX to create executable
run: |
$GITHUB_ACTION_PATH/scripts/create_exe.sh \
-a ${{ inputs.app_install_dir }} \
-d ${{ inputs.data_component_name }} \
-i ${{ inputs.dependencies_install_dir }} \
-m ${{ inputs.component_name }} \
-n ${{ inputs.component_module_name }}
shell: bash
# restore input files from cache
- name: Restore Input Files From Cache
uses: actions/cache@v3
with:
path: ${{ inputs.cache_input_file_list }}
key: input-
restore-keys: |
input
# create run directory and download input
# no need to check the cache hit since script is able to check the existing files and not download again
- name: Download Input Files
run: |
export PATH=${{ inputs.dependencies_install_dir }}/view/bin:$PATH
export PYTHONPATH=~/.local:$PYTHONPATH
if [ ! -d "${{ inputs.app_install_dir }}/run" ]; then
mkdir ${{ inputs.app_install_dir }}/run
fi
cd ${{ inputs.app_install_dir }}/run
python3 $GITHUB_ACTION_PATH/scripts/get_input.py --ifile ${{ inputs.test_definition }}
shell: bash
# generate configuration files
- name: Generate Configuration Files
run: |
export PYTHONPATH=$GITHUB_ACTION_PATH/scripts:$PYTHONPATH
export PYTHONPATH=$GITHUB_ACTION_PATH/scripts/paramgen:$PYTHONPATH
cd ${{ inputs.app_install_dir }}/run
python3 $GITHUB_ACTION_PATH/scripts/gen_config.py --ifile ${{ inputs.test_definition }}
shell: bash
# used to debug run and allow ssh just before running the model
- name: Setup tmate session to allow ssh connection
if: ${{ inputs.debug == 'ON' }}
uses: mxschmitt/action-tmate@v3
# run application
- name: Run Application
run: |
export PATH=${{ inputs.dependencies_install_dir }}/view/bin:$PATH
cd ${{ inputs.app_install_dir }}/run
mpirun ${{ inputs.mpirun_args }} ${{ inputs.app_install_dir }}/build/esmx >& out_err.txt
cat out_err.txt
exc=$?
if [ $exc -ne 0 ]; then
echo "Component did not run successfully! Partial output from PET log files: "
tail -n 50 PET*
exit $exc
fi
shell: bash {0}
# upload model artifacts to check it later
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: ${{ inputs.artifacts_name }}
path: ${{ inputs.artifacts_files }}
retention-days: ${{ inputs.artifacts_retention_period }}
# find baseline date from cache, the most recent baseline will be picked
- name: Query Date for Old Baseline From Cache
run: |
# get date for old baseline
BL_DATE_OLD=$(gh api -H "Accept: application/vnd.github+json" \
--jq '.actions_caches[] | (.id|tostring) + " " + .key + " " + .ref' \
/repos/${{ github.repository }}/actions/caches | sort -n | \
( grep "baseline-" || true ) | ( grep "${{ github.ref }}" || true ) | \
tail -n 1 | awk -F\- '{print $2"-"$3"-"$4}' | awk '{print $1}')
# if there is no baseline assign new date
if [ -z "$BL_DATE_OLD" ]; then
BL_DATE_OLD=$(date -u '+%Y-%m-%dT%I:%M:%S.%NZ')
fi
echo "BL_DATE_OLD=$BL_DATE_OLD" >> $GITHUB_ENV
echo "BL_DATE_OLD = $BL_DATE_OLD"
shell: bash
# calculate hashes
- name: Calculate Hashes of Output Files and Query Baseline Date
run: |
# get current baseline date
BL_DATE_OLD=${{ env.BL_DATE_OLD }}
# set new baseline date if 'Baseline Change' tag in PR
force_bc=${{ contains(github.event.pull_request.labels.*.name, 'Baseline Change') }}
echo "Baseline change request is force_bc = $force_bc"
if [[ "$force_bc" == "true" ]]; then
BL_DATE_NEW=$(date -u '+%Y-%m-%dT%I:%M:%S.%NZ')
else
BL_DATE_NEW=$BL_DATE_OLD
fi
echo "BL_DATE_NEW=$BL_DATE_NEW" >> $GITHUB_ENV
# save hashes of output files for current run
cd ${{ inputs.app_install_dir }}/run
for i in $(echo "${{ inputs.baseline_files }}" | awk '$1=$1' RS= OFS=" ")
do
if echo x"$i" | grep '*' > /dev/null; then
lst2=`ls -al $i | awk '{print $9}'`
for j in $lst2; do
md5sum $j >> output_hash.txt
done
else
md5sum $i >> output_hash.txt
fi
done
# print out some debug information
if [[ "$BL_DATE_OLD" == "$BL_DATE_NEW" ]]; then
echo "BL_DATE_OLD = $BL_DATE_OLD"
echo "BL_DATE_NEW = $BL_DATE_NEW"
else
echo "Force baseline change! BL_DATE_OLD ($BL_DATE_OLD) =! BL_DATE_NEW ($BL_DATE_NEW)"
fi
shell: bash
# restore baseline hash file and files from cache
- name: Restore Baseline Hash File From Cache
uses: actions/cache@v3
with:
path: |
${{ inputs.app_install_dir }}/run/output_hash_baseline.txt
key: baseline-${{ env.BL_DATE_NEW }}
restore-keys: |
baseline-${{ env.BL_DATE_NEW }}
# compare with the baseline
- name: Compare with Baseline or Create New One
run: |
cd ${{ inputs.app_install_dir }}/run
# compare against the baseline, returns false if it does not match
if [ -f "output_hash_baseline.txt" ]; then
echo "Baseline:"
cat output_hash_baseline.txt
echo "Current Run:"
cat output_hash.txt
echo "CHECK_RESULT=$(cmp --silent output_hash_baseline.txt output_hash.txt && echo 'true' || echo 'false' )" >> $GITHUB_ENV
# there is no baseline, just copy current one as baseline
else
echo "Current run will be used as a baseline."
# print out content of the has file
cat output_hash.txt
cp output_hash.txt output_hash_baseline.txt
echo "CHECK_RESULT=$(echo 'true')" >> $GITHUB_ENV
fi
shell: bash
# Force to fail if the results are not matched with the baseline
- name: Result of Baseline Check
run: |
if [[ "${{ env.CHECK_RESULT }}" == "false" ]]; then
echo "The results do not match with the baseline!"
exit 1
else
echo "The results match with the baseline."
exit 0
fi
shell: bash