@@ -21,10 +21,22 @@ jobs:
21
21
configuration : [nwm_ana, nwm_long_range, gridded, reach]
22
22
runs-on : ubuntu-latest
23
23
24
+ env :
25
+ MPI_HOME : /usr/share/miniconda
26
+ NETCDF : /usr/share/miniconda
27
+ NETCDF_INCLUDES : /usr/share/miniconda/include
28
+ NETCDF_LIBRARIES : /usr/share/miniconda/lib
29
+
30
+
24
31
steps :
32
+ - uses : actions/checkout@v4
33
+ - uses : actions/setup-python@v5
34
+ with :
35
+ python-version : ' 3.10'
36
+
25
37
- name : Checkout candidate (pull request / push)
26
38
if : ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
27
- uses : actions/checkout@v3
39
+ uses : actions/checkout@v4
28
40
with :
29
41
path : candidate
30
42
@@ -36,14 +48,14 @@ jobs:
36
48
37
49
- name : Checkout reference (pull request)
38
50
if : ${{ github.event_name == 'pull_request' }}
39
- uses : actions/checkout@v3
51
+ uses : actions/checkout@v4
40
52
with :
41
53
ref : ${{ github.event.pull_request.base.ref }}
42
54
path : reference
43
55
44
56
- name : Checkout reference (push)
45
57
if : ${{ github.event_name == 'push' }}
46
- uses : actions/checkout@v3
58
+ uses : actions/checkout@v4
47
59
with :
48
60
ref : ${{ github.event.before }}
49
61
path : reference
@@ -54,29 +66,148 @@ jobs:
54
66
GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
55
67
run : gh repo clone ${{ github.repository }} reference && cd reference && git checkout origin/$(gh pr view ${{ github.event.inputs.pr }} --json baseRefName --jq '.baseRefName')
56
68
57
- - name : Run testing container
69
+ - name : Install dependencies with apt-get
58
70
run : |
59
- docker run -e TRAVIS=1 -t --name test_container \
60
- -v $GITHUB_WORKSPACE/candidate:/home/docker/candidate \
61
- -v $GITHUB_WORKSPACE/reference:/home/docker/reference \
62
- wrfhydro/dev:modeltesting --config ${{ matrix.configuration }} --domain_tag dev
71
+ sudo apt-get update \
72
+ && sudo apt-get install -yq --no-install-recommends \
73
+ wget \
74
+ curl \
75
+ bzip2 \
76
+ ca-certificates \
77
+ libhdf5-dev \
78
+ gfortran \
79
+ g++ \
80
+ m4 \
81
+ make \
82
+ libswitch-perl \
83
+ git \
84
+ bc \
85
+ openmpi-bin openmpi-common libopenmpi-dev \
86
+ libxml2-dev \
87
+ libnetcdf-dev \
88
+ libnetcdff-dev
63
89
64
- - name : Copy test results from container
90
+ - name : Install dependencies with pip
91
+ run : |
92
+ python3 -m pip install matplotlib numpy xarray dask netCDF4 pygithub
93
+
94
+ - name : Compile reference
95
+ run : |
96
+ cd $GITHUB_WORKSPACE/reference
97
+ cmake -B build
98
+ make -C build -j
99
+
100
+ - name : Compile candidate
101
+ run : |
102
+ cd $GITHUB_WORKSPACE/candidate
103
+ cmake -B build
104
+ make -C build -j
105
+
106
+ - name : Run reference model
107
+ run : |
108
+ cd $GITHUB_WORKSPACE/reference/build/Run
109
+ make run-croton-${{ matrix.configuration }}
110
+
111
+ - name : Run candidate model
112
+ run : |
113
+ cd $GITHUB_WORKSPACE/candidate/build/Run
114
+ make run-croton-${{ matrix.configuration }}
115
+
116
+ - name : Compare HYDRO_RST.* output with xrcmp
117
+ if : ${{ always() }}
118
+ run : |
119
+ cd $GITHUB_WORKSPACE/candidate/build/Run
120
+ for file in output_${{ matrix.configuration }}/HYDRO_RST.*; do\
121
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
122
+ --candidate $file \
123
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
124
+ --log_file $file_diff.txt \
125
+ --n_cores 1; \
126
+ done
127
+
128
+ - name : Compare RESTART.* output with xrcmp
65
129
if : ${{ always() }}
66
- run : docker cp test_container:/home/docker/test_out $GITHUB_WORKSPACE/test_report
130
+ run : |
131
+ cd $GITHUB_WORKSPACE/candidate/build/Run
132
+ for file in output_${{ matrix.configuration }}/RESTART.*; do\
133
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
134
+ --candidate $file \
135
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
136
+ --log_file $file_diff.txt \
137
+ --n_cores 1; \
138
+ done
139
+
140
+ - name : Compare last *.CHANOBS_DOMAIN1 output with xrcmp
141
+ if : ${{ always() }}
142
+ run : |
143
+ cd $GITHUB_WORKSPACE/candidate/build/Run
144
+ file=$(ls -t output_${{ matrix.configuration }}/*.CHANOBS_DOMAIN1 | head -n 1)
145
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
146
+ --candidate $file \
147
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
148
+ --log_file $file_diff.txt \
149
+ --n_cores 1; \
150
+
151
+ - name : Compare last *.CHRTOUT_DOMAIN1 output with xrcmp
152
+ if : ${{ always() }}
153
+ run : |
154
+ cd $GITHUB_WORKSPACE/candidate/build/Run
155
+ file=$(ls -t output_${{ matrix.configuration }}/*.CHRTOUT_DOMAIN1 | head -n 1)
156
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
157
+ --candidate $file \
158
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
159
+ --log_file $file_diff.txt \
160
+ --n_cores 1; \
161
+
162
+ - name : Compare last *.LSMOUT_DOMAIN1 output with xrcmp
163
+ if : ${{ always() }}
164
+ run : |
165
+ cd $GITHUB_WORKSPACE/candidate/build/Run
166
+ file=$(ls -t output_${{ matrix.configuration }}/*.LSMOUT_DOMAIN1 | head -n 1)
167
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
168
+ --candidate $file \
169
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
170
+ --log_file $file_diff.txt \
171
+ --n_cores 1; \
67
172
68
- - name : Checkout Github API
173
+ - name : Compare last *.RTOUT_DOMAIN1 output with xrcmp
69
174
if : ${{ always() }}
70
175
run : |
71
- pip install pygithub
176
+ cd $GITHUB_WORKSPACE/candidate/build/Run
177
+ file=$(ls -t output_${{ matrix.configuration }}/*.RTOUT_DOMAIN1 | head -n 1)
178
+ python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
179
+ --candidate $file \
180
+ --reference $GITHUB_WORKSPACE/reference/build/Run/$file \
181
+ --log_file $file_diff.txt \
182
+ --n_cores 1; \
183
+
184
+ - name : Compare output with compare_output
185
+ if : ${{ always() }}
186
+ run : |
187
+ cd $GITHUB_WORKSPACE/candidate/build/Run
188
+ mkdir output_diff
189
+ python -c \
190
+ "import sys; \
191
+ sys.path.append('${GITHUB_WORKSPACE}/candidate/tests/utils'); \
192
+ import compare_output; \
193
+ from pathlib import Path; \
194
+ compare_output.plot_diffs('${GITHUB_WORKSPACE}/candidate/build/Run/output_diff', \
195
+ '${GITHUB_WORKSPACE}/candidate/build/Run/output_${{ matrix.configuration }}/', \
196
+ '${GITHUB_WORKSPACE}/reference/build/Run/output_${{ matrix.configuration }}/', \
197
+ '${{ matrix.configuration }}')"
198
+
199
+ - name : Copy test results from container
200
+ if : ${{ always() }}
201
+ run : |
202
+ mkdir -p $GITHUB_WORKSPACE/test_report
203
+ cp -r $GITHUB_WORKSPACE/candidate/build/Run/output_${{ matrix.configuration }}/* $GITHUB_WORKSPACE/test_report/
72
204
73
205
- name : Attach diff plots to PR
74
206
if : ${{ always() }}
75
207
run : |
76
208
cd $GITHUB_WORKSPACE/candidate/tests/local/utils
77
209
bash attach_all_plots.bash $(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") ${{ matrix.configuration }}
78
210
79
-
80
211
- name : Archive test results to GitHub
81
212
if : ${{ always() }}
82
213
uses : actions/upload-artifact@v3
0 commit comments