-
Notifications
You must be signed in to change notification settings - Fork 43
269 lines (229 loc) · 7.68 KB
/
ex-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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: CI
env:
DISTNAME: mf6examples
TAG: current
on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
push:
paths-ignore:
- 'README.md'
- 'DEVELOPER.md'
pull_request:
branches:
- master
- develop
paths-ignore:
- 'README.md'
- 'DEVELOPER.md'
workflow_dispatch:
jobs:
lint:
name: Lint/format example scripts
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout MODFLOW 6 examples
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python packages
working-directory: etc
run: |
python --version
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.pip.txt
- name: Lint
run: ruff check .
- name: Format
run: ruff format . --check
dist:
name: Build example models
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout MODFLOW6 examples
uses: actions/checkout@v4
with:
path: modflow6-examples
- name: Checkout MODFLOW 6
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/modflow6
path: modflow6
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python packages
working-directory: modflow6-examples/etc
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.pip.txt
pip install -r requirements.usgs.txt
python -m ipykernel install --name python_kernel --user
- name: Update FloPy classes
run: python -m flopy.mf6.utils.generate_classes --ref develop --no-backup
- name: Install MODFLOW executables
uses: modflowpy/install-modflow-action@v1
- name: Build MODFLOW 6
working-directory: modflow6
run: |
meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin
meson install -C builddir
meson test --verbose --no-rebuild -C builddir
- name: Install MODFLOW 6
working-directory: modflow6
run: cp bin/mf6 ~/.local/bin/modflow/
- name: Create example models
working-directory: modflow6-examples/autotest
# run the scripts via pytest without running the models, just build input files
run: pytest -v -n=auto --durations=0 test_scripts.py --init
- name: Make zipfile
working-directory: modflow6-examples
run: |
import shutil
shutil.make_archive("${{ env.DISTNAME }}", "zip", "examples")
shell: python
- name: Upload zipfile
uses: actions/upload-artifact@v3
with:
name: ${{ env.DISTNAME }}.zip
path: modflow6-examples/${{ env.DISTNAME }}.zip
docs:
name: Run examples, make docs
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
python: [3.9, "3.10", "3.11", "3.12"]
steps:
- name: Checkout MODFLOW 6 examples
uses: actions/checkout@v4
with:
path: modflow6-examples
- name: Checkout MODFLOW 6
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/modflow6
path: modflow6
- name: Checkout usgslatex
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/usgslatex
path: usgslatex
- name: Install LaTeX and extra fonts
run: |
sudo apt-get update
sudo apt install texlive-latex-extra texlive-science fonts-liberation
- name: Install USGS styles and fonts
working-directory: usgslatex/usgsLaTeX
run: sudo ./install.sh --all-users
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up headless display
uses: pyvista/setup-headless-display-action@v2
- name: Install Python packages
working-directory: modflow6-examples/etc
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.pip.txt
pip install -r requirements.usgs.txt
python -m ipykernel install --name python_kernel --user
- name: Update FloPy classes
run: python -m flopy.mf6.utils.generate_classes --ref develop --no-backup
- name: Install MODFLOW executables
uses: modflowpy/install-modflow-action@v1
- name: Build MODFLOW 6
working-directory: modflow6
run: |
meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin
meson install -C builddir
meson test --verbose --no-rebuild -C builddir
- name: Install MODFLOW 6
working-directory: modflow6
run: cp bin/mf6 ~/.local/bin/modflow/
- name: Run examples, make plots
working-directory: modflow6-examples/autotest
run: pytest -v -n=auto --durations=0 test_scripts.py --plot
- name: Run postprocessing
working-directory: modflow6-examples/scripts
if: matrix.python == '3.9'
run: python process-scripts.py
- name: Build PDF document
working-directory: modflow6-examples/doc
if: matrix.python == '3.9'
run: ./build-pdf.sh
- name: Move PDF document
working-directory: modflow6-examples
if: matrix.python == '3.9'
run: mv doc/${{ env.DISTNAME }}.pdf ${{ env.DISTNAME }}.pdf
- name: Upload PDF document
if: matrix.python == '3.9'
uses: actions/upload-artifact@v3
with:
name: ${{ env.DISTNAME}}.pdf
path: modflow6-examples/${{ env.DISTNAME }}.pdf
# delete the latest if needed and make a new release
release:
name: Make a release
needs: [ dist, docs ]
runs-on: ubuntu-latest
steps:
- name: Checkout MODFLOW6 examples
uses: actions/checkout@v4
- name: Get current time
uses: josStorer/get-current-time@v2
id: time
with:
format: MM/DD/YYYY HH:mm
- name: Download ${{ env.DISTNAME }}.pdf
uses: actions/download-artifact@v3
with:
name: ${{ env.DISTNAME }}.pdf
path: ${{ env.TAG }}
- name: Download ${{ env.DISTNAME }}.zip
uses: actions/download-artifact@v3
with:
name: ${{ env.DISTNAME }}.zip
path: ${{ env.TAG }}
- name: List release assets
run: ls -R ${{ env.TAG }}
- name: Delete latest release
if: |
github.repository_owner == 'MODFLOW-USGS' &&
github.ref_name == 'master' &&
github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release delete $TAG -y --cleanup-tag
- name: Create new release
if: |
github.repository_owner == 'MODFLOW-USGS' &&
github.ref_name == 'master' &&
github.event_name == 'push'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.TAG }}
name: Latest
body: "MODFLOW 6 examples: built ${{ steps.time.outputs.formattedTime }}"
allowUpdates: true
draft: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
if: |
github.repository_owner == 'MODFLOW-USGS' &&
github.ref_name == 'master' &&
github.event_name == 'push'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.TAG }}/*
tag: ${{ env.TAG }}
overwrite: true
file_glob: true