-
Notifications
You must be signed in to change notification settings - Fork 7
313 lines (277 loc) · 9.78 KB
/
nightly-build.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: MODFLOW 6 nightly build
on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
# - cron: '*/10 * * * *' # run every 10 minutes
# - cron: '20 */1 * * *' # run every hour at 20 minutes past the hour
push:
branches:
- master
jobs:
build_for_os:
name: compile on linux, macos, and windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact_name: linux.zip
body_name: bodyFileLinux
- os: macos-latest
artifact_name: mac.zip
body_name: bodyFileMac
- os: windows-latest
artifact_name: win64.zip
body_name: bodyFileWindows
steps:
- uses: actions/checkout@v2
- name: setup-conda
uses: s-weigand/setup-conda@v1.0.5
with:
auto-update-conda: true
miniconda-version: "latest"
- name: Install python packages
run: |
conda info
conda install pip requests appdirs nose
# use pip to install numpy and matplotlib because of a windows issue
pip install numpy matplotlib
pip install https://github.com/modflowpy/flopy/zipball/develop
pip install https://github.com/modflowpy/pymake/zipball/master
- name: Setup symbolic link to gfortran on Linux
if: runner.os == 'Linux'
run: |
sudo ln -fs /usr/bin/gfortran-9 /usr/local/bin/gfortran
sudo ln -fs /usr/bin/gcc-9 /usr/local/bin/gcc
sudo ln -fs /usr/bin/g++-9 /usr/local/bin/g++
- name: Install and setup symbolic link to gfortran on MacOS
shell: bash
if: runner.os == 'macOS'
run: |
brew cask info gfortran
brew cask install gfortran
ls -l /usr/local/gfortran/bin/
sudo ln -fs /usr/local/gfortran/bin/gfortran /usr/local/bin/gfortran
sudo ln -fs /usr/local/gfortran/bin/gcc /usr/local/bin/gcc
sudo ln -fs /usr/local/gfortran/bin/g++ /usr/local/bin/g++
- name: Print GNU compiler versions
shell: bash
run: |
gfortran --version
gcc --version
g++ --version
- name: Clone MODFLOW 6 repo
run: |
git clone https://github.com/MODFLOW-USGS/modflow6.git modflow6
shell: bash
- name: Determine MODFLOW 6 branch
run: |
pwd
cd ./modflow6/
pwd
git branch
cd ../
pwd
ls ./
- name: Update flopy MODFLOW 6 classes
run: |
cd ./modflow6/autotest
python update_flopy.py
cd ../../
- name: Print python package versions
shell: python
run: |
import sys
import nose
import numpy as np
import matplotlib as mpl
import flopy
import pymake
flopypth = flopy.__path__[0]
pymakepth = pymake.__path__[0]
print("python version: {}".format(sys.version))
print("nosetest version: {}".format(nose.__version__))
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print("pymake version: {}".format(pymake.__version__))
print("")
print("flopy is installed in: {}".format(flopypth))
print("pymake is installed in: {}".format(pymakepth))
- name: Build and zip applications
shell: bash
run: |
cd ./modflow6/
nosetests -v -w ./distribution build_nightly.py
cd ../
- name: Move the build zip file
shell: bash
run: |
mv ./modflow6/distribution/temp/${{ matrix.artifact_name }} ./${{ matrix.artifact_name }}
ls -l ./
- name: Build bodyFile with gfortran information
shell: python
run: |
import sys
import subprocess
argv = ["gfortran", "--version"]
with subprocess.Popen(argv,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=".") as process:
output, unused_err = process.communicate(timeout=10)
buff = output.decode("utf-8")
version = buff.splitlines()[0].split()[-1]
major = version.split(".")[0]
osname = sys.platform.lower()
if osname == "win32":
fpth = "bodyFileWindows"
msg = "Windows executables are statically linked and can be run " + \
"without gfortran being installed. In order to use the MODFLOW 6 " + \
"dynamic-link library (libmf6.dll) on Windows, the Mingw-w64 " + \
"version of gfortran version {} ".format(version) + \
"will need to be installed locally.\n\n"
elif osname == "darwin":
fpth = "bodyFileMac"
msg = "On MacOS, the gfortran compiler used to compile the " + \
"MODFLOW 6 executables and shared object (libmf6.so) will need " + \
"to be installed locally. The MODFLOW 6 executables and shared " + \
"object were compiled on MacOS using Homebrew gfortran " + \
"version {}.\n\n".format(version)
else:
fpth = "bodyFileLinux"
msg = "On Linux, the gfortran compiler used to compile the " + \
"MODFLOW 6 executables and shared object (libmf6.so) will need " + \
"to be installed locally. The MODFLOW 6 executables and shared " + \
"object were compiled on Linux using gfortran " + \
"version {}.\n\n".format(version)
f = open(fpth, "w")
f.write(msg)
f.close()
# Build LaTeX document
- name: Copy the modflow6/docs directory
if: runner.os == 'Linux'
shell: python
run: |
import shutil
src = "/home/runner/work/modflow6-nightly-build/modflow6-nightly-build/modflow6/doc/"
dst = "./doc/"
shutil.copytree(src, dst)
- name: Install TeX Live
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt install texlive-latex-extra texlive-science
- name: Build mf6io latex document
if: runner.os == 'Linux'
shell: python
run: |
import sys
import subprocess
ws = "./modflow6/doc/mf6io/"
bibnam = "mf6io.nightlybuild"
texnam = bibnam + ".tex"
cmds = [
["pdflatex", texnam],
["bibtex", bibnam],
["pdflatex", texnam],
["pdflatex", texnam],
]
for cmd in cmds:
print("running command...'{}'".format(" ".join(cmd)))
with subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=ws) as process:
stdout, stderr = process.communicate(timeout=10)
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: runner.os == 'Linux'
shell: bash
run: |
ls -la ./modflow6/doc/mf6io/
mv ./modflow6/doc/mf6io/mf6io.nightlybuild.pdf mf6io.pdf
ls -la ./
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
name: nightly
path: |
./${{ matrix.artifact_name }}
./${{ matrix.body_name }}
- name: Upload additional Build Artifacts
if: runner.os == 'Linux'
uses: actions/upload-artifact@v2
with:
name: nightly
path: |
./mf6io.pdf
# make the release if previous job was successful
release:
name: Make a nightly release
needs: build_for_os
runs-on: ubuntu-latest
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v2
with:
name: nightly
path: ./nightly/
- name: List files in the artifact directory
shell: bash
run: |
pwd
ls -l ./nightly/
- name: Concatenate os specific bodyFiles
shell: bash
run: |
pwd
cat ./nightly/bodyFileWindows ./nightly/bodyFileMac ./nightly/bodyFileLinux > bodyFile
ls -l ./
rm ./nightly/bodyFile*
ls -l ./nightly/
- name: Get Current Time
uses: 1466587594/get-current-time@v1.0.0
id: current-time
with:
format: YYYYMMDD
- name: Use current time
env:
TIME: "${{ steps.current-time.outputs.time }}"
F_TIME: "${{ steps.current-time.outputs.formattedTime }}"
run: echo $TIME $F_TIME
- name: Delete Older Releases
uses: dev-drprasad/delete-older-releases@v0.1.0
with:
keep_latest: 30
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create a Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.current-time.outputs.formattedTime }}
name: ${{ steps.current-time.outputs.formattedTime }} nightly build
bodyFile: bodyFile
allowUpdates: true
draft: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload compiled executables to the latest GitHub release
uses: svenstaro/upload-release-action@2.0.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./nightly/*
tag: ${{ steps.current-time.outputs.formattedTime }}
overwrite: true
file_glob: true
- name: Delete Artifact
uses: GeekyEggo/delete-artifact@v1.0.0
with:
name: nightly