Skip to content

Commit 258c913

Browse files
authored
refactor(distribution): automate release procedure (#1069)
* 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 258c913

28 files changed

Lines changed: 3337 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: 99 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ on:
55
- master
66
- develop
77
- ci-diagnose*
8+
paths-ignore:
9+
- '**.md'
10+
- 'doc/**'
11+
- '.github/workflows/release.yml'
812
pull_request:
913
branches:
1014
- master
1115
- develop
16+
paths-ignore:
17+
- '**.md'
18+
- 'doc/**'
19+
- '.github/workflows/release.yml'
1220
jobs:
1321
lint:
1422
name: Lint (fprettify)
@@ -57,11 +65,14 @@ jobs:
5765
cache-downloads: true
5866
cache-env: true
5967

60-
- name: Meson setup/compile
68+
- name: Meson setup
6169
run: |
6270
meson setup builddir -Ddebug=false -Dwerror=true
71+
72+
- name: Meson compile
73+
run: |
6374
meson compile -C builddir
64-
75+
6576
- name: Meson test
6677
run: |
6778
meson test --verbose --no-rebuild -C builddir
@@ -94,7 +105,13 @@ jobs:
94105
repository: MODFLOW-USGS/modflow6-testmodels
95106
path: modflow6-testmodels
96107

97-
- name: Setup gfortran ${{ env.GCC_V }}
108+
- name: Checkout modflow6-examples
109+
uses: actions/checkout@v3
110+
with:
111+
repository: MODFLOW-USGS/modflow6-examples
112+
path: modflow6-examples
113+
114+
- name: Setup GNU Fortran ${{ env.GCC_V }}
98115
uses: awvwgk/setup-fortran@main
99116
with:
100117
compiler: gcc
@@ -107,6 +124,26 @@ jobs:
107124
cache-downloads: true
108125
cache-env: true
109126

127+
- name: Cache modflow6 examples
128+
id: cache-examples
129+
uses: actions/cache@v3
130+
with:
131+
path: modflow6-examples/examples
132+
key: modflow6-examples-${{ hashFiles('modflow6-examples/scripts/**') }}
133+
134+
- name: Install extra Python packages
135+
if: steps.cache-examples.outputs.cache-hit != 'true'
136+
working-directory: modflow6-examples/etc
137+
run: |
138+
pip install -r requirements.pip.txt
139+
140+
- name: Build example models
141+
if: steps.cache-examples.outputs.cache-hit != 'true'
142+
working-directory: modflow6-examples/etc
143+
run: |
144+
python ci_build_files.py
145+
ls -lh ../examples/
146+
110147
- name: Build modflow6
111148
working-directory: modflow6
112149
run: |
@@ -124,11 +161,18 @@ jobs:
124161
run: |
125162
pytest -v --durations 0 get_exes.py
126163
127-
- name: Run tests
164+
- name: Test programs
128165
working-directory: modflow6/autotest
129166
run: |
130167
pytest -v -n auto --durations 0
131168
169+
- name: Test scripts
170+
working-directory: modflow6/distribution
171+
env:
172+
GITHUB_TOKEN: ${{ github.token }}
173+
run: |
174+
pytest -v --durations 0
175+
132176
test_gfortran_previous:
133177
name: Test gfortran (${{ matrix.GCC_V }}, ${{ matrix.os }})
134178
needs:
@@ -158,7 +202,7 @@ jobs:
158202
repository: MODFLOW-USGS/modflow6-testmodels
159203
path: modflow6-testmodels
160204

161-
- name: Setup gfortran ${{ matrix.GCC_V }}
205+
- name: Setup GNU Fortran ${{ matrix.GCC_V }}
162206
uses: awvwgk/setup-fortran@main
163207
with:
164208
compiler: gcc
@@ -188,10 +232,10 @@ jobs:
188232
run: |
189233
pytest -v --durations 0 get_exes.py
190234
191-
- name: Run tests
235+
- name: Test modflow6
192236
working-directory: modflow6/autotest
193237
run: |
194-
pytest -v -n auto --durations 0
238+
pytest -v -n auto --durations 0
195239
196240
test_ifort:
197241
name: Test (ifort)
@@ -219,24 +263,54 @@ jobs:
219263
repository: MODFLOW-USGS/modflow6-testmodels
220264
path: modflow6-testmodels
221265

266+
- name: Checkout modflow6-examples
267+
uses: actions/checkout@v3
268+
with:
269+
repository: MODFLOW-USGS/modflow6-examples
270+
path: modflow6-examples
271+
222272
- name: Setup Micromamba
223273
uses: mamba-org/provision-with-micromamba@main
224274
with:
225275
environment-file: modflow6/environment.yml
226276
cache-downloads: true
227277
cache-env: true
228278

229-
- name: Setup ifort
279+
- name: Setup Intel Fortran
230280
uses: modflowpy/install-intelfortran-action@v1
231281

232-
- name: Add Micromamba Scripts dir to path
282+
- name: Fix Micromamba path (Windows)
233283
if: runner.os == 'Windows'
234284
shell: pwsh
235285
run: |
236286
# https://github.com/modflowpy/install-intelfortran-action#conda-scripts
237287
$mamba_bin = "C:\Users\runneradmin\micromamba-root\envs\modflow6\Scripts"
238288
echo $mamba_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
239289
290+
- name: Cache modflow6 examples
291+
id: cache-examples
292+
uses: actions/cache@v3
293+
with:
294+
path: modflow6-examples/examples
295+
key: modflow6-examples-${{ hashFiles('modflow6-examples/scripts/**') }}
296+
297+
- name: Install extra Python packages
298+
if: steps.cache-examples.outputs.cache-hit != 'true'
299+
working-directory: modflow6-examples/etc
300+
run: |
301+
pip install -r requirements.pip.txt
302+
303+
- name: Build example models
304+
if: steps.cache-examples.outputs.cache-hit != 'true'
305+
working-directory: modflow6-examples/etc
306+
run: |
307+
python ci_build_files.py
308+
ls -lh ../examples/
309+
310+
- name: Update version files
311+
working-directory: modflow6/distribution
312+
run: python update_version.py
313+
240314
- name: Build modflow6
241315
if: runner.os != 'Windows'
242316
working-directory: modflow6
@@ -245,7 +319,7 @@ jobs:
245319
meson install -C builddir
246320
meson test --verbose --no-rebuild -C builddir
247321
248-
- name: Build modflow6
322+
- name: Build modflow6 (Windows)
249323
if: runner.os == 'Windows'
250324
working-directory: modflow6
251325
shell: pwsh
@@ -265,175 +339,39 @@ jobs:
265339
run: |
266340
pytest -v --durations 0 get_exes.py
267341
268-
- name: Get executables
342+
- name: Get executables (Windows)
269343
if: runner.os == 'Windows'
270344
working-directory: modflow6/autotest
271345
shell: pwsh
272346
run: |
273347
pytest -v --durations 0 get_exes.py
274-
275-
- name: Run tests
348+
349+
- name: Test programs
276350
if: runner.os != 'Windows'
277351
working-directory: modflow6/autotest
278352
run: |
279353
pytest -v -n auto --durations 0
280354
281-
- name: Run tests
355+
- name: Test programs (Windows)
282356
if: runner.os == 'Windows'
283357
working-directory: modflow6/autotest
284358
shell: pwsh
285359
run: |
286360
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
329361
330-
- name: Test makefiles
362+
- name: Test scripts
363+
if: runner.os != 'Windows'
331364
working-directory: modflow6/distribution
365+
env:
366+
GITHUB_TOKEN: ${{ github.token }}
332367
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
368+
pytest -v --durations 0
372369
373-
- name: Test makefiles
370+
- name: Test scripts (Windows)
371+
if: runner.os == 'Windows'
374372
working-directory: modflow6/distribution
373+
shell: pwsh
374+
env:
375+
GITHUB_TOKEN: ${{ github.token }}
375376
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
377+
pytest -v --durations 0

0 commit comments

Comments
 (0)