-
Notifications
You must be signed in to change notification settings - Fork 43
194 lines (175 loc) · 6.27 KB
/
ex-rtd.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
name: rtd
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:
inputs:
ref:
description: 'The tag, branch or commit hash to trigger an RTD build for. Branches and tags must be fully formed, e.g. refs/heads/<branch> or refs/tags/<tag> respectively.'
required: false
type: string
default: 'refs/heads/develop'
mf6_ref:
description: 'The tag, branch or commit hash to build MF6 from. Branches and tags must be fully formed, e.g. refs/heads/<branch> or refs/tags/<tag> respectively.'
required: false
type: string
default: 'refs/heads/develop'
jobs:
set_options:
name: Set release options
if: github.ref_name != 'master'
runs-on: ubuntu-22.04
outputs:
ref: ${{ steps.set_ref.outputs.ref }}
sha: ${{ steps.set_sha.outputs.sha }}
mf6_ref: ${{ steps.set_mf6_ref.outputs.ref }}
steps:
- name: Set ref
id: set_ref
run: |
# if ref was provided explicitly via workflow_dispatch, use it
if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.ref }}") ]]; then
ref="${{ inputs.ref }}"
echo "using ref $ref from workflow_dispatch"
else
# otherwise use the current branch
ref="${{ github.ref }}"
echo "using current ref $ref"
fi
echo "ref=$ref" >> $GITHUB_OUTPUT
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ steps.set_ref.outputs.ref }}
- name: Set sha
id: set_sha
run: |
if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.ref }}") ]]; then
sha=$(git rev-parse ${{ steps.set_ref.outputs.ref }})
else
sha="${{ github.sha }}"
fi
echo "sha=$sha" >> $GITHUB_OUTPUT
- name: Set MF6 ref
id: set_mf6_ref
run: |
# if ref was provided explicitly via workflow_dispatch, use it
if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.mf6_ref }}") ]]; then
ref="${{ inputs.mf6_ref }}"
else
# otherwise use the develop branch
ref="refs/heads/develop"
fi
echo "using mf6 ref $ref"
echo "ref=$ref" >> $GITHUB_OUTPUT
build:
name: Build artifacts for RTD
needs: set_options
runs-on: ubuntu-latest
strategy:
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Checkout MODFLOW6 examples
uses: actions/checkout@v4
with:
path: modflow6-examples
ref: ${{ needs.set_options.outputs.ref }}
- name: Checkout MODFLOW 6
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/modflow6
path: modflow6
ref: ${{ needs.set_options.outputs.mf6_ref }}
- name: Install LaTeX and extra fonts
run: |
sudo apt-get update
sudo apt install texlive-latex-extra texlive-science fonts-liberation
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get install ttf-mscorefonts-installer
sudo rm -rf ~/.cache/matplotlib
- name: Install pandoc
run: |
wget https://github.com/jgm/pandoc/releases/download/2.11.2/pandoc-2.11.2-linux-amd64.tar.gz
sudo tar xvzf pandoc-2.11.2-linux-amd64.tar.gz --strip-components=1 -C /usr/local
pandoc --version
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- 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 ${{ needs.set_options.outputs.mf6_ref }} --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
cp bin/* ~/.local/bin/modflow/
- name: Run notebooks, make plots
working-directory: modflow6-examples/autotest
run: pytest -v -n=auto --durations=0 test_notebooks.py --plot
- name: Run postprocessing
working-directory: modflow6-examples/scripts
run: python process-scripts.py
- name: Create Markdown tables
working-directory: modflow6-examples/etc
run: python ci_create_examples_rst.py
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: rtd-files-for-${{ needs.set_options.outputs.sha }}
path: |
modflow6-examples/.doc/introduction.md
modflow6-examples/.doc/examples.rst
modflow6-examples/.doc/_examples
modflow6-examples/.doc/_images
modflow6-examples/.doc/_notebooks
trigger:
name: Trigger RTD build
needs:
- set_options
- build
runs-on: ubuntu-latest
if: |
github.repository_owner == 'MODFLOW-USGS' &&
(
github.ref_name == 'master' ||
github.ref_name == 'develop'
) && (
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
)
steps:
- name: Checkout MODFLOW6 examples repo
uses: actions/checkout@v4
- name: Trigger RTD build
uses: dfm/rtds-action@v1
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ needs.set_options.outputs.ref }}