Skip to content

CI

CI #1405

Workflow file for this run

name: CI
on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
push:
branches:
- master
- develop
paths-ignore:
- 'README.md'
- 'DEVELOPER.md'
pull_request:
branches:
- master
- develop
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@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- 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(branch="develop", 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
env:
script-directory: scripts
etc-directory: etc
defaults:
run:
shell: bash
steps:
- name: Checkout MODFLOW6 examples repo
uses: actions/checkout@v3
- 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@v3
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: 3.9
- 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(branch="develop", 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
run: |
pytest -v -n=auto --durations=0 --run=True ci_build_files.py
working-directory: ${{env.etc-directory}}
- name: Run processing script
run: |
python process-scripts.py
working-directory: ${{env.script-directory}}
- name: Build mf6examples LaTeX document
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
run: |
ls -l ./doc/
mv ./doc/mf6examples.pdf mf6examples.pdf
ls -l ./
- name: Upload build artifacts for current release
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@v3
- 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