Skip to content

Commit 137a898

Browse files
committed
refactor(tests): refactor test framework, scripts and cases
* use modeling utilities from flopy * use testing utilities/fixtures from modflow-devtools * add pytest.ini with markers, file patterns & default opts * use keepable temp dirs instead of manually managed folder * replace common_regression.py with pytest/modflow-devtools * refactor get_exes.py with modflow-devtools and get-modflow * remove binary_file_writer.py, disu_util.py, budget_file_compare.py * remove build_exes.py (require meson setup/install before testing) * remove mfpymake dependency from autotests (replaced by devtools) * test example models separately, rename large.yml -> examples.yml * strip z0* prefix from examples/testmodel/largetestmodel scripts * rename Simulation to TestConfig (disambiguate from flopy) * rename Framework to TestHarness (avoid import errors) * add optional path argument to update_flopy.py CLI * partially refactor gwf test with pytest-cases
1 parent 49876f8 commit 137a898

222 files changed

Lines changed: 6772 additions & 16205 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 83 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,32 @@ jobs:
149149

150150
- name: Get executables
151151
working-directory: modflow6/autotest
152+
env:
153+
GITHUB_TOKEN: ${{ github.token }}
152154
run: pytest -v --durations 0 get_exes.py
153155

154-
- name: Test programs
156+
- name: Test
155157
working-directory: modflow6/autotest
156158
run: |
157159
if [ "${{ github.ref_name }}" == "master" ]; then
158-
pytest -v -n auto --durations 0 -m "not developmode"
160+
pytest -v -n auto --durations 0 -m "not repo and not developmode"
159161
else
160-
pytest -v -n auto --durations 0
162+
pytest -v -n auto --durations 0 -m "not repo"
161163
fi
162164
163-
- name: Test scripts
165+
- name: Test mf5to6 models
166+
working-directory: modflow6/autotest
167+
run: pytest -v -n auto --durations 0 test_testmodels_mf5to6.py
168+
env:
169+
REPOS_PATH: ${{ github.workspace }}
170+
171+
- name: Test mf6 models
172+
working-directory: modflow6/autotest
173+
run: pytest -v -n auto --durations 0 test_testmodels_mf6.py
174+
env:
175+
REPOS_PATH: ${{ github.workspace }}
176+
177+
- name: Test dist scripts
164178
working-directory: modflow6/distribution
165179
env:
166180
GITHUB_TOKEN: ${{ github.token }}
@@ -221,17 +235,31 @@ jobs:
221235
222236
- name: Get executables
223237
working-directory: modflow6/autotest
238+
env:
239+
GITHUB_TOKEN: ${{ github.token }}
224240
run: pytest -v --durations 0 get_exes.py
225241

226-
- name: Test modflow6
242+
- name: Test
227243
working-directory: modflow6/autotest
228244
run: |
229245
if [ "${{ github.ref_name }}" == "master" ]; then
230-
pytest -v -n auto --durations 0 -m "not developmode"
246+
pytest -v -n auto --durations 0 -m "not repo and not developmode"
231247
else
232-
pytest -v -n auto --durations 0
248+
pytest -v -n auto --durations 0 -m "not repo"
233249
fi
234250
251+
- name: Test mf5to6 models
252+
working-directory: modflow6/autotest
253+
run: pytest -v -n auto --durations 0 test_testmodels_mf5to6.py
254+
env:
255+
REPOS_PATH: ${{ github.workspace }}
256+
257+
- name: Test mf6 models
258+
working-directory: modflow6/autotest
259+
run: pytest -v -n auto --durations 0 test_testmodels_mf6.py
260+
env:
261+
REPOS_PATH: ${{ github.workspace }}
262+
235263
test_ifort:
236264
name: Test (ifort)
237265
needs:
@@ -258,12 +286,6 @@ jobs:
258286
repository: MODFLOW-USGS/modflow6-testmodels
259287
path: modflow6-testmodels
260288

261-
- name: Checkout modflow6-examples
262-
uses: actions/checkout@v3
263-
with:
264-
repository: MODFLOW-USGS/modflow6-examples
265-
path: modflow6-examples
266-
267289
- name: Setup Micromamba
268290
uses: mamba-org/provision-with-micromamba@main
269291
with:
@@ -282,23 +304,6 @@ jobs:
282304
$mamba_bin = "C:\Users\runneradmin\micromamba-root\envs\modflow6\Scripts"
283305
echo $mamba_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
284306
285-
- name: Cache modflow6 examples
286-
id: cache-examples
287-
uses: actions/cache@v3
288-
with:
289-
path: modflow6-examples/examples
290-
key: modflow6-examples-${{ hashFiles('modflow6-examples/scripts/**') }}
291-
292-
- name: Install extra Python packages
293-
if: steps.cache-examples.outputs.cache-hit != 'true'
294-
working-directory: modflow6-examples/etc
295-
run: pip install -r requirements.pip.txt
296-
297-
- name: Build example models
298-
if: steps.cache-examples.outputs.cache-hit != 'true'
299-
working-directory: modflow6-examples/etc
300-
run: python ci_build_files.py
301-
302307
- name: Update version files
303308
working-directory: modflow6/distribution
304309
run: python update_version.py
@@ -327,46 +332,84 @@ jobs:
327332
- name: Get executables
328333
if: runner.os != 'Windows'
329334
working-directory: modflow6/autotest
335+
env:
336+
GITHUB_TOKEN: ${{ github.token }}
330337
run: pytest -v --durations 0 get_exes.py
331338

332339
- name: Get executables (Windows)
333340
if: runner.os == 'Windows'
334341
working-directory: modflow6/autotest
335342
shell: pwsh
343+
env:
344+
GITHUB_TOKEN: ${{ github.token }}
336345
run: pytest -v --durations 0 get_exes.py
337346

338-
- name: Test programs
347+
- name: Test
339348
if: runner.os != 'Windows'
340349
working-directory: modflow6/autotest
350+
env:
351+
GITHUB_TOKEN: ${{ github.token }}
341352
run: |
342353
if [ "${{ github.ref_name }}" == "master" ]; then
343-
pytest -v -n auto --durations 0 -m "not developmode"
354+
pytest -v -n auto --durations 0 -m "not repo and not developmode"
344355
else
345-
pytest -v -n auto --durations 0
356+
pytest -v -n auto --durations 0 -m "not repo"
346357
fi
347358
348-
- name: Test programs (Windows)
359+
- name: Test (Windows)
349360
if: runner.os == 'Windows'
350361
working-directory: modflow6/autotest
351362
shell: pwsh
363+
env:
364+
GITHUB_TOKEN: ${{ github.token }}
352365
run: |
353366
if ( "${{ github.ref_name }}" -eq "master" ) {
354-
pytest -v -n auto --durations 0 -m "not developmode"
367+
pytest -v -n auto --durations 0 -m "not repo and not developmode"
355368
} else {
356-
pytest -v -n auto --durations 0
369+
pytest -v -n auto --durations 0 -m "not repo"
357370
}
358371
359-
- name: Test scripts
372+
- name: Test mf5to6 models
373+
if: runner.os != 'Windows'
374+
working-directory: modflow6/autotest
375+
run: pytest -v -n auto --durations 0 test_testmodels_mf5to6.py
376+
env:
377+
REPOS_PATH: ${{ github.workspace }}
378+
379+
- name: Test mf5to6 models (Windows)
380+
if: runner.os == 'Windows'
381+
working-directory: modflow6/autotest
382+
shell: pwsh
383+
run: pytest -v -n auto --durations 0 test_testmodels_mf5to6.py
384+
env:
385+
REPOS_PATH: ${{ github.workspace }}
386+
387+
- name: Test mf6 models
388+
if: runner.os != 'Windows'
389+
working-directory: modflow6/autotest
390+
run: pytest -v -n auto --durations 0 test_testmodels_mf6.py
391+
env:
392+
REPOS_PATH: ${{ github.workspace }}
393+
394+
- name: Test mf6 models (Windows)
395+
if: runner.os == 'Windows'
396+
working-directory: modflow6/autotest
397+
shell: pwsh
398+
run: pytest -v -n auto --durations 0 test_testmodels_mf6.py
399+
env:
400+
REPOS_PATH: ${{ github.workspace }}
401+
402+
- name: Test dist scripts
360403
if: runner.os != 'Windows'
361404
working-directory: modflow6/distribution
405+
run: pytest -v --durations 0
362406
env:
363407
GITHUB_TOKEN: ${{ github.token }}
364-
run: pytest -v --durations 0
365408

366-
- name: Test scripts (Windows)
409+
- name: Test dist scripts (Windows)
367410
if: runner.os == 'Windows'
368411
working-directory: modflow6/distribution
369412
shell: pwsh
413+
run: pytest -v --durations 0
370414
env:
371415
GITHUB_TOKEN: ${{ github.token }}
372-
run: pytest -v --durations 0

.github/workflows/docs.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ jobs:
7171
7272
- name: Test building files from dfn's for LaTeX
7373
working-directory: modflow6/autotest
74-
run: |
75-
pytest -v build_mfio_tex.py
74+
run: pytest -v build_mfio_tex.py
7675

7776
- name: Setup GNU Fortran ${{ env.GCC_V }}
7877
uses: awvwgk/setup-fortran@main
@@ -103,17 +102,17 @@ jobs:
103102
104103
- name: Run benchmarks
105104
working-directory: modflow6/distribution
105+
env:
106+
GITHUB_TOKEN: ${{ github.token }}
106107
run: python benchmark.py
107108

108109
- name: Run sphinx
109110
working-directory: modflow6/.build_rtd_docs
110-
run: |
111-
make html
111+
run: make html
112112

113113
- name: Show results
114114
working-directory: modflow6/distribution
115-
run: |
116-
cat run-time-comparison.md
115+
run: cat run-time-comparison.md
117116

118117
- name: Upload comparison
119118
uses: actions/upload-artifact@v3
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: MODFLOW 6 large models
1+
name: MODFLOW 6 example models
22
on:
33
schedule:
44
- cron: '0 6 * * *' # run at 6 AM UTC every day
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
fc: [ ifort, gfortran ]
23-
repo: [ examples, largetestmodels ]
23+
repo: [ examples, testmodels, largetestmodels ]
2424
defaults:
2525
run:
2626
shell: bash -l {0}
@@ -93,15 +93,16 @@ jobs:
9393
9494
- name: Get executables
9595
working-directory: modflow6/autotest
96-
run: |
97-
pytest -v --durations 0 get_exes.py
96+
env:
97+
GITHUB_TOKEN: ${{ github.token }}
98+
run: pytest -v --durations 0 get_exes.py
9899

99100
- name: Update flopy
100101
working-directory: modflow6/autotest
101-
run: |
102-
python update_flopy.py
102+
run: python update_flopy.py
103103

104104
- name: Run tests
105105
working-directory: modflow6/autotest
106-
run: |
107-
pytest -v -n auto --durations 0 test_z03_${{ matrix.repo }}.py
106+
run: pytest -v -n auto --durations 0 test_${{ matrix.repo }}.py
107+
env:
108+
REPOS_PATH: ${{ github.workspace }}

0 commit comments

Comments
 (0)