forked from wrf-model/WRF
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (132 loc) · 5.54 KB
/
test_workflow.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
on :
workflow_call :
inputs :
label :
required : true
type : string
hpc-workflows_path :
required : true
type : string
archive :
required : true
type : string
name :
required : true
type : string
id :
required : true
type : string
host :
required : true
type : string
fileroot :
required : true
type : string
account :
required : true
type : string
tests :
required : true
type : string
mkdirs :
required : true
type : boolean
args :
required : false
type : string
default : ""
pool :
required : false
type : number
default : 1
tpool :
required : false
type : number
default : 1
jobs:
test_workflow :
# Is 5 days a reasonable wait time for testing?
timeout-minutes: 7200
name: Test ${{ inputs.name }} on ${{ inputs.host }}
runs-on: ${{ inputs.host }}
env :
LOG_SUFFIX : ${{ github.event_name == 'push' && 'master' || github.event.number }}
steps:
- uses: actions/checkout@v4
with:
path : main
submodules: true
# Immediately copy out to # of tests to do
- name: Create testing directories
if : ${{ inputs.mkdirs }}
id : cpTestDirs
run : |
# Limit parallel ops to 4 at a time to not thrash login nodes
# Remove if it exists to get a fresh start
echo "Cleaning old test directories..."
tests="${{ join( fromJson( inputs.tests ), ' ' ) }}"
time printf "%s\n" $tests | xargs -i -P 4 rm -rf {}
echo "Creating duplicate directory for $tests"
time printf "%s\n" $tests | xargs -i -P 4 cp -Rp main/ {}
- name: Test ${{ inputs.name }}
id : runTest
run: |
if [ "${{ inputs.mkdirs }}" = "true" ]; then
ALT_DIRS="-alt ../${{ join( fromJson( inputs.tests ), '/.ci ../' ) }}/.ci"
fi
./main/${{ inputs.hpc-workflows_path }}/.ci/runner.py \
./main/.ci/${{ inputs.fileroot }}.json \
-t ${{ join( fromJson( inputs.tests ), ' ' ) }} \
-a "${{ inputs.account }}" \
-p ${{ inputs.pool}} -tp ${{ inputs.tpool }} \
-jn ${{ github.event_name == 'push' && github.ref_name || github.event.number }}-${{ inputs.id }} \
${{ inputs.args }} $ALT_DIRS
- name: Report failed tests and steps
if : ${{ failure() }}
run : |
# move log files to safe location
./main/${{ inputs.hpc-workflows_path }}/.ci/relocator.py ./main/.ci/${{ inputs.fileroot }}.log ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}
# report on them - alt dirs need extra help
if [ "${{ inputs.mkdirs }}" = "true" ]; then
masterlogLoc=main/.ci
fi
./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \
-e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \
-o GITHUB -m # only mark fail steps with gh syntax
# report on them
echo "# Summary for ${{ join( fromJson( inputs.tests ), ' ' ) }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \
-e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \
-s >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Clean up testing directories
if : ${{ success() }}
id : rmTestDirs
run : |
for testDir in ${{ join( fromJson( inputs.tests ), ' ' ) }}; do
echo "Removing duplicate directory for $testDir"
rm -rf $testDir
done
- name: Upload test logs
if : ${{ failure() }}
uses : actions/upload-artifact@v4
with:
# as per usual with ci/cd stuff I am shocked but not surprised when the advertised
# *documented* functionality doesn't work as expected. Wow, bravo
# can't use ${{ env. }} as somehow this combination of matrix->reusable workflow->call step is too complex
# and expands to nothing
name: ${{ github.event_name == 'push' && github.ref_name || github.event.number }}-${{ inputs.id }}_logfiles
path: ${{ inputs.archive }}/${{ github.event_name == 'push' && github.ref_name || github.event.number }}/${{ inputs.id }}/
# As noted in ci.yml, this will need to be moved to a separate workflow with pull_request_target
# and strictly controlled usage of the GH token
# - name : Remove '${{ inputs.label }}' label
# if : ${{ !cancelled() && github.event.label.name == inputs.label }}
# env:
# PR_NUMBER: ${{ github.event.number }}
# run: |
# curl \
# -X DELETE \
# -H "Accept: application/vnd.github.v3+json" \
# -H 'Authorization: token ${{ github.token }}' \
# https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels/${{ inputs.label }}