rtd #2230
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |