CI #2276
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: 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 |