Skip to content

Commit abd68ab

Browse files
committed
refactor(distribution): automate release procedure
* use pathlib in distribution scripts * construct relative paths from script locn, not cwd * synchronize version file updates with file lock * rename mkdist.py -> build_dist.py * rename evaluate_run_times.py -> benchmark.py * rename make_release.py -> update_version.py * introduce build_docs.py * add argparse CLI for each script * add tests/test configuration for scripts * add post-build checks for distribution * move .fprettify from distribution/ to proj root * add release.yml to automate release procedure * add release documentation to distribution/README.md * add path argument too mk_runtimecomp.py * deduplicate mf6 -v version string output * add bin/sh header to Unix example scripts * update version string substituted into docs (<version>---Release Candidate -> <version>rc) * test distribution scripts in CI test job * cache example models in CI test job * ignore ci.yml on md/docs changes
1 parent f971c50 commit abd68ab

28 files changed

Lines changed: 3323 additions & 2346 deletions

.build_rtd_docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
pth = os.path.join("..", "distribution")
3939
args = (
4040
"python",
41-
"make_release.py",
41+
"update_version.py",
4242
)
4343
# run the command
4444
proc = Popen(args, stdout=PIPE, stderr=PIPE, cwd=pth)

.github/common/fortran-format-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ for path in "${SEARCHPATHS[@]}"; do
2626

2727
((checkcount++))
2828

29-
if [[ ! -z $(fprettify -d -c ./distribution/.fprettify.yaml "${file}" 2>&1) ]]; then
29+
if [[ ! -z $(fprettify -d -c .fprettify.yaml "${file}" 2>&1) ]]; then
3030
fformatfails+=("${file}")
3131
fi
3232
done

.github/workflows/ci.yml

Lines changed: 97 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ on:
55
- master
66
- develop
77
- ci-diagnose*
8+
paths-ignore:
9+
- '**.md'
10+
- 'doc/**'
811
pull_request:
912
branches:
1013
- master
1114
- develop
15+
paths-ignore:
16+
- '**.md'
17+
- 'doc/**'
1218
jobs:
1319
lint:
1420
name: Lint (fprettify)
@@ -57,11 +63,14 @@ jobs:
5763
cache-downloads: true
5864
cache-env: true
5965

60-
- name: Meson setup/compile
66+
- name: Meson setup
6167
run: |
6268
meson setup builddir -Ddebug=false -Dwerror=true
69+
70+
- name: Meson compile
71+
run: |
6372
meson compile -C builddir
64-
73+
6574
- name: Meson test
6675
run: |
6776
meson test --verbose --no-rebuild -C builddir
@@ -94,7 +103,13 @@ jobs:
94103
repository: MODFLOW-USGS/modflow6-testmodels
95104
path: modflow6-testmodels
96105

97-
- name: Setup gfortran ${{ env.GCC_V }}
106+
- name: Checkout modflow6-examples
107+
uses: actions/checkout@v3
108+
with:
109+
repository: MODFLOW-USGS/modflow6-examples
110+
path: modflow6-examples
111+
112+
- name: Setup GNU Fortran ${{ env.GCC_V }}
98113
uses: awvwgk/setup-fortran@main
99114
with:
100115
compiler: gcc
@@ -107,6 +122,26 @@ jobs:
107122
cache-downloads: true
108123
cache-env: true
109124

125+
- name: Cache modflow6 examples
126+
id: cache-examples
127+
uses: actions/cache@v3
128+
with:
129+
path: modflow6-examples/examples
130+
key: modflow6-examples-${{ hashFiles('modflow6-examples/scripts/**') }}
131+
132+
- name: Install extra Python packages
133+
if: steps.cache-examples.outputs.cache-hit != 'true'
134+
working-directory: modflow6-examples/etc
135+
run: |
136+
pip install -r requirements.pip.txt
137+
138+
- name: Build example models
139+
if: steps.cache-examples.outputs.cache-hit != 'true'
140+
working-directory: modflow6-examples/etc
141+
run: |
142+
python ci_build_files.py
143+
ls -lh ../examples/
144+
110145
- name: Build modflow6
111146
working-directory: modflow6
112147
run: |
@@ -124,11 +159,18 @@ jobs:
124159
run: |
125160
pytest -v --durations 0 get_exes.py
126161
127-
- name: Run tests
162+
- name: Test programs
128163
working-directory: modflow6/autotest
129164
run: |
130165
pytest -v -n auto --durations 0
131166
167+
- name: Test scripts
168+
working-directory: modflow6/distribution
169+
env:
170+
GITHUB_TOKEN: ${{ github.token }}
171+
run: |
172+
pytest -v --durations 0
173+
132174
test_gfortran_previous:
133175
name: Test gfortran (${{ matrix.GCC_V }}, ${{ matrix.os }})
134176
needs:
@@ -158,7 +200,7 @@ jobs:
158200
repository: MODFLOW-USGS/modflow6-testmodels
159201
path: modflow6-testmodels
160202

161-
- name: Setup gfortran ${{ matrix.GCC_V }}
203+
- name: Setup GNU Fortran ${{ matrix.GCC_V }}
162204
uses: awvwgk/setup-fortran@main
163205
with:
164206
compiler: gcc
@@ -188,10 +230,10 @@ jobs:
188230
run: |
189231
pytest -v --durations 0 get_exes.py
190232
191-
- name: Run tests
233+
- name: Test modflow6
192234
working-directory: modflow6/autotest
193235
run: |
194-
pytest -v -n auto --durations 0
236+
pytest -v -n auto --durations 0
195237
196238
test_ifort:
197239
name: Test (ifort)
@@ -219,24 +261,54 @@ jobs:
219261
repository: MODFLOW-USGS/modflow6-testmodels
220262
path: modflow6-testmodels
221263

264+
- name: Checkout modflow6-examples
265+
uses: actions/checkout@v3
266+
with:
267+
repository: MODFLOW-USGS/modflow6-examples
268+
path: modflow6-examples
269+
222270
- name: Setup Micromamba
223271
uses: mamba-org/provision-with-micromamba@main
224272
with:
225273
environment-file: modflow6/environment.yml
226274
cache-downloads: true
227275
cache-env: true
228276

229-
- name: Setup ifort
277+
- name: Setup Intel Fortran
230278
uses: modflowpy/install-intelfortran-action@v1
231279

232-
- name: Add Micromamba Scripts dir to path
280+
- name: Fix Micromamba path (Windows)
233281
if: runner.os == 'Windows'
234282
shell: pwsh
235283
run: |
236284
# https://github.com/modflowpy/install-intelfortran-action#conda-scripts
237285
$mamba_bin = "C:\Users\runneradmin\micromamba-root\envs\modflow6\Scripts"
238286
echo $mamba_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
239287
288+
- name: Cache modflow6 examples
289+
id: cache-examples
290+
uses: actions/cache@v3
291+
with:
292+
path: modflow6-examples/examples
293+
key: modflow6-examples-${{ hashFiles('modflow6-examples/scripts/**') }}
294+
295+
- name: Install extra Python packages
296+
if: steps.cache-examples.outputs.cache-hit != 'true'
297+
working-directory: modflow6-examples/etc
298+
run: |
299+
pip install -r requirements.pip.txt
300+
301+
- name: Build example models
302+
if: steps.cache-examples.outputs.cache-hit != 'true'
303+
working-directory: modflow6-examples/etc
304+
run: |
305+
python ci_build_files.py
306+
ls -lh ../examples/
307+
308+
- name: Update version files
309+
working-directory: modflow6/distribution
310+
run: python update_version.py
311+
240312
- name: Build modflow6
241313
if: runner.os != 'Windows'
242314
working-directory: modflow6
@@ -245,7 +317,7 @@ jobs:
245317
meson install -C builddir
246318
meson test --verbose --no-rebuild -C builddir
247319
248-
- name: Build modflow6
320+
- name: Build modflow6 (Windows)
249321
if: runner.os == 'Windows'
250322
working-directory: modflow6
251323
shell: pwsh
@@ -265,175 +337,39 @@ jobs:
265337
run: |
266338
pytest -v --durations 0 get_exes.py
267339
268-
- name: Get executables
340+
- name: Get executables (Windows)
269341
if: runner.os == 'Windows'
270342
working-directory: modflow6/autotest
271343
shell: pwsh
272344
run: |
273345
pytest -v --durations 0 get_exes.py
274-
275-
- name: Run tests
346+
347+
- name: Test programs
276348
if: runner.os != 'Windows'
277349
working-directory: modflow6/autotest
278350
run: |
279351
pytest -v -n auto --durations 0
280352
281-
- name: Run tests
353+
- name: Test programs (Windows)
282354
if: runner.os == 'Windows'
283355
working-directory: modflow6/autotest
284356
shell: pwsh
285357
run: |
286358
pytest -v -n auto --durations 0
287-
288-
test_makefiles_gfortran:
289-
name: Test makefiles (gfortran ${{ matrix.gcc_v }}, ${{ matrix.os }})
290-
needs:
291-
- lint
292-
- build
293-
runs-on: ${{ matrix.os }}
294-
strategy:
295-
fail-fast: false
296-
matrix:
297-
os: [ ubuntu-22.04, macos-12, windows-2022]
298-
gcc_v: [ 12 ]
299-
defaults:
300-
run:
301-
shell: bash -l {0}
302-
env:
303-
FC: gfortran
304-
steps:
305-
306-
- name: Checkout modflow6
307-
uses: actions/checkout@v3
308-
with:
309-
path: modflow6
310-
311-
- name: Checkout modflow6-testmodels
312-
uses: actions/checkout@v3
313-
with:
314-
repository: MODFLOW-USGS/modflow6-testmodels
315-
path: modflow6-testmodels
316-
317-
- name: Setup gfortran ${{ matrix.gcc_v }}
318-
uses: awvwgk/setup-fortran@main
319-
with:
320-
compiler: gcc
321-
version: ${{ matrix.gcc_v }}
322-
323-
- name: Setup Micromamba
324-
uses: mamba-org/provision-with-micromamba@main
325-
with:
326-
environment-file: modflow6/environment.yml
327-
cache-downloads: true
328-
cache-env: true
329359
330-
- name: Test makefiles
360+
- name: Test scripts
361+
if: runner.os != 'Windows'
331362
working-directory: modflow6/distribution
363+
env:
364+
GITHUB_TOKEN: ${{ github.token }}
332365
run: |
333-
pytest -v -n auto build_makefiles.py
334-
335-
test_makefiles_ifort:
336-
name: Test makefiles (ifort, ${{ matrix.os }})
337-
needs:
338-
- lint
339-
- build
340-
runs-on: ${{ matrix.os }}
341-
strategy:
342-
fail-fast: false
343-
matrix:
344-
os: [ ubuntu-latest, macos-latest ]
345-
defaults:
346-
run:
347-
shell: bash -l {0}
348-
env:
349-
FC: ifort
350-
steps:
351-
352-
- name: Checkout modflow6
353-
uses: actions/checkout@v3
354-
with:
355-
path: modflow6
356-
357-
- name: Checkout modflow6-testmodels
358-
uses: actions/checkout@v3
359-
with:
360-
repository: MODFLOW-USGS/modflow6-testmodels
361-
path: modflow6-testmodels
362-
363-
- name: Setup ifort
364-
uses: modflowpy/install-intelfortran-action@v1
365-
366-
- name: Setup Micromamba
367-
uses: mamba-org/provision-with-micromamba@main
368-
with:
369-
environment-file: modflow6/environment.yml
370-
cache-downloads: true
371-
cache-env: true
366+
pytest -v --durations 0
372367
373-
- name: Test makefiles
368+
- name: Test scripts (Windows)
369+
if: runner.os == 'Windows'
374370
working-directory: modflow6/distribution
371+
shell: pwsh
372+
env:
373+
GITHUB_TOKEN: ${{ github.token }}
375374
run: |
376-
pytest -v -n auto build_makefiles.py
377-
378-
test_nightly_build_gfortran:
379-
name: Test nightly build (gfortran 12)
380-
needs:
381-
- lint
382-
- build
383-
runs-on: ${{ matrix.os }}
384-
strategy:
385-
fail-fast: false
386-
matrix:
387-
include:
388-
- os: ubuntu-22.04
389-
ostag: linux
390-
- os: macos-12
391-
ostag: mac
392-
- os: windows-2022
393-
ostag: win64
394-
env:
395-
GCC_V: 12
396-
defaults:
397-
run:
398-
shell: bash -l {0}
399-
steps:
400-
401-
- name: Checkout modflow6
402-
uses: actions/checkout@v3
403-
404-
- name: Setup gfortran ${{ env.GCC_V }}
405-
uses: awvwgk/setup-fortran@main
406-
with:
407-
compiler: gcc
408-
version: ${{ env.GCC_V }}
409-
410-
- name: Setup Micromamba
411-
uses: mamba-org/provision-with-micromamba@main
412-
with:
413-
cache-downloads: true
414-
cache-env: true
415-
416-
- name: Print Python package versions
417-
run: |
418-
pip list
419-
420-
- name: Update flopy
421-
working-directory: autotest
422-
run: |
423-
python update_flopy.py
424-
425-
- name: Run nightly build script
426-
working-directory: distribution
427-
run: |
428-
python build_nightly.py
429-
430-
- name: Make sure zip file exists
431-
working-directory: distribution
432-
run: |
433-
path="temp_zip/${{ matrix.ostag }}.zip"
434-
if [ -e "$path" ]; then
435-
echo "Zipfile found: $path"
436-
else
437-
echo "Zipfile not found: $path"
438-
exit 1
439-
fi
375+
pytest -v --durations 0

0 commit comments

Comments
 (0)