-
Notifications
You must be signed in to change notification settings - Fork 43
288 lines (247 loc) · 8.24 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: CI
on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
push:
branches:
- master
- develop
- ci-*
- PRT
paths-ignore:
- 'README.md'
- 'DEVELOPER.md'
pull_request:
branches:
- master
- develop
- PRT
paths-ignore:
- 'README.md'
- 'DEVELOPER.md'
jobs:
zip_files:
name: zip input files
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
script-directory: scripts
etc-directory: etc
defaults:
run:
shell: bash
steps:
- name: Checkout MODFLOW6 examples repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Print python version
run: |
python --version
- name: Install Python packages
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.pip.txt
pip install -r requirements.usgs.txt
working-directory: ${{env.etc-directory}}
- name: Update flopy MODFLOW 6 classes
run: |
import flopy
flopy.mf6.utils.generate_classes(owner="aprovost-usgs", ref="PRT", backup=False)
shell: python
- name: Install MODFLOW executables release
uses: modflowpy/install-modflow-action@v1
- name: Install MODFLOW nightly-build executables
uses: modflowpy/install-modflow-action@v1
with:
repo: modflow6-nightly-build
- name: Run scripts without model runs
run: |
pytest -v -n=auto --durations=0 ci_build_files.py
working-directory: ${{env.etc-directory}}
- name: zip input files
run: |
import shutil
shutil.make_archive("modflow6-examples", "zip", "examples")
shell: python
- name: Upload build artifacts for current release
uses: actions/upload-artifact@v3
with:
name: zip_files
path: |
./modflow6-examples.zip
build:
name: current-build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: [3.8, 3.9, "3.10", "3.11"]
env:
script-directory: scripts
etc-directory: etc
defaults:
run:
shell: bash
steps:
- name: Checkout MODFLOW6 examples repo
uses: actions/checkout@v4
- name: Install TeX Live and additional TrueType fonts
run: |
sudo apt-get update
sudo apt install texlive-latex-extra texlive-science fonts-liberation
- name: Checkout usgslatex
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/usgslatex
path: usgslatex
- name: Install USGS LaTeX style files and Univers font
working-directory: usgslatex/usgsLaTeX
run: sudo ./install.sh --all-users
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Python packages
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.pip.txt
pip install -r requirements.usgs.txt
working-directory: ${{env.etc-directory}}
- name: Update flopy MODFLOW 6 classes
run: |
import flopy
flopy.mf6.utils.generate_classes(owner="aprovost-usgs", ref="PRT", backup=False)
shell: python
- name: Install MODFLOW executables release
uses: modflowpy/install-modflow-action@v1
- name: Install MODFLOW 6 PRT build
uses: modflowpy/install-modflow-action@v1
with:
owner: aprovost-usgs
repo: modflow6
- name: Run scripts
run: pytest -v -n=auto --durations=0 --run=True ci_build_files.py
working-directory: ${{env.etc-directory}}
- name: Run processing script
if: matrix.python == '3.9'
run: python process-scripts.py
working-directory: ${{env.script-directory}}
- name: Build mf6examples LaTeX document
if: matrix.python == '3.9'
shell: python
run: |
import sys
import subprocess
ws = "./doc/"
bibnam = "mf6examples"
texnam = bibnam + ".tex"
args = (
("pdflatex", texnam),
("bibtex", bibnam),
("pdflatex", texnam),
("pdflatex", texnam),
)
for arg in args:
print("running command...'{}'".format(" ".join(arg)))
with subprocess.Popen(arg,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=ws) as process:
stdout, stderr = process.communicate(timeout=120)
if stdout:
stdout = stdout.decode()
print(stdout)
if stderr:
print("\n\nError condition occurred:\n")
stderr = stderr.decode()
print(stderr)
- name: Rename and move the LaTeX document
if: matrix.python == '3.9'
run: |
ls -l ./doc/
mv ./doc/mf6examples.pdf mf6examples.pdf
ls -l ./
- name: Upload build artifacts for current release
if: matrix.python == '3.9'
uses: actions/upload-artifact@v3
with:
name: current
path: |
./mf6examples.pdf
# make the release if the "build" job was successful
release:
name: Make the release
needs: [ zip_files, build ]
runs-on: ubuntu-latest
steps:
- name: Checkout MODFLOW6 examples repo
uses: actions/checkout@v4
- name: Get Current Time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: MM/DD/YYYY HH:mm
- name: Set current time as environmental variable
env:
TIME: "${{ steps.current-time.outputs.time }}"
F_TIME: "${{ steps.current-time.outputs.formattedTime }}"
run: |
echo "F_TIME=${{ steps.current-time.outputs.formattedTime }}" >> $GITHUB_ENV
echo "TIME=${{ steps.current-time.outputs.time }}" >> $GITHUB_ENV
echo $TIME
echo $F_TIME
echo "MODFLOW 6 examples: built at ${F_TIME}"
- name: Download mf6examples.pdf build artifact
uses: actions/download-artifact@v3
with:
name: current
path: ./current/
- name: Download zip_file build artifact
uses: actions/download-artifact@v3
with:
name: zip_files
path: ./current/
- name: List files in the artifact directory
run: |
pwd
ls -R ./current/
- name: create bodyFile
run: |
echo "MODFLOW 6 examples: built "${F_TIME} > bodyFile
cat bodyFile
ls -l .
- name: Delete the latest release
if: github.repository_owner == 'MODFLOW-USGS' && github.event_name == 'push' && github.ref_name == 'master'
uses: ame-yu/action-delete-latest-release@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create/Update the current release
if: github.repository_owner == 'MODFLOW-USGS' && github.event_name == 'push' && github.ref_name == 'master'
uses: ncipollo/release-action@v1
with:
tag: current
name: current build
bodyFile: ./bodyFile
allowUpdates: true
draft: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MODFLOW 6 examples to the current GitHub release
if: github.repository_owner == 'MODFLOW-USGS' && github.event_name == 'push' && github.ref_name == 'master'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./current/*
tag: current
overwrite: true
file_glob: true
- name: Delete all Artifacts
if: github.repository_owner == 'MODFLOW-USGS' && github.event_name == 'push' && github.ref_name == 'master'
uses: GeekyEggo/delete-artifact@v2
with:
name: |
zip_files
current