Run examples #733
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: Run examples | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
schedule: | |
# run daily at 5:00 am UTC (12 am ET/9 pm PT) | |
- cron: '0 5 * * *' | |
concurrency: | |
# NOTE: the value of `group` should be chosen carefully, | |
# otherwise we might end up over- or under-canceling workflow runs | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
env: | |
IDAES_CONDA_ENV_NAME_DEV: examples-pse-dev | |
IDAES_PSE_REQUIREMENT: idaes-pse[prerelease] @ https://github.com/IDAES/idaes-pse/archive/main.zip | |
defaults: | |
run: | |
# -l needed to work properly with Conda | |
shell: bash -l {0} | |
jobs: | |
examples: | |
name: Build examples (py${{ matrix.python-version }}/${{ matrix.os }}) | |
runs-on: ${{ matrix.os-runner }} | |
strategy: | |
# if fail-fast == true (the default), jobs for the remaining values in the matrix are cancelled | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.7' | |
- '3.8' | |
- '3.9' | |
os: | |
- linux | |
- windows | |
include: | |
- os: linux | |
os-runner: ubuntu-18.04 | |
- os: windows | |
os-runner: windows-2019 | |
skip-wsl-only: true | |
steps: | |
- name: Set up Conda environment | |
uses: conda-incubator/[email protected] | |
with: | |
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }} | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v2 | |
- name: Skip notebooks that require WSL to run on Windows | |
if: matrix.skip-wsl-only | |
run: | | |
rm -r src/Examples/DAE/petsc*.ipynb | |
- name: Skip notebooks that require Alamo | |
run: | | |
rm src/Examples/SurrMod/FlowsheetOptimization/ALAMO_flowsheet_optimization.ipynb | |
- name: Add configured version of idaes-pse to requirements | |
run: | | |
echo "$IDAES_PSE_REQUIREMENT" >> requirements.txt | |
- name: Set up IDAES | |
uses: ./.github/actions/setup-idaes | |
with: | |
install-target: -r requirements.txt | |
- name: Run pytest (unit) | |
run: | | |
pytest --verbose -m unit tests/ | |
- name: Run pytest (not unit, including running notebooks) | |
run: | | |
pytest --verbose -m 'not unit' tests/ | |
- name: Save build error logs | |
uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: build-error-logs | |
path: ci-test-errors.txt | |
build-examples-docs: | |
name: Build examples docs (py${{ matrix.python-version }}) | |
runs-on: ubuntu-18.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.7' | |
- '3.8' | |
- '3.9' | |
steps: | |
- name: Set up Conda environment | |
uses: conda-incubator/[email protected] | |
with: | |
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }} | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v2 | |
- name: Skip notebooks that require Alamo | |
run: | | |
rm src/Examples/SurrMod/FlowsheetOptimization/ALAMO_flowsheet_optimization.ipynb | |
- name: Add configured version of idaes-pse to requirements | |
run: | | |
echo "$IDAES_PSE_REQUIREMENT" >> requirements.txt | |
- name: Set up IDAES | |
uses: ./.github/actions/setup-idaes | |
with: | |
install-target: -r requirements.txt | |
- name: Install pandoc | |
run: | | |
sudo apt-get install --quiet --yes pandoc | |
- name: Check installed versions | |
run: | | |
idaes --version | |
pandoc --version | |
- name: Build notebook index | |
run: | | |
python build.py -v --config ./build-ci.yml -x | |
- name: Convert notebooks and build docs | |
run: | | |
# copy files and dirs from 'docs/' to 'docs_test/' to avoid Sphinx errors and warnings | |
mkdir ./docs_test && cp -r ./docs/{conf.py,index.rst,_images,_static,_templates} ./docs_test/ | |
ls -lah ./docs_test | |
python build.py -v --config ./build-ci.yml -cd | |
- name: Save build outputs | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: examples-pse-build-docs-${{ matrix.python-version }} | |
path: | | |
sphinx-errors.txt | |
docs_test/_build/html/ | |
- name: Check for broken links in HTML docs | |
run: | | |
# linkchecker refuses to load files from its own installation directory if they are world-writable | |
linkchecker_pkg_dir=$(python -c 'import linkcheck as l, pathlib as p; print(p.Path(l.__file__).parent.resolve())') | |
chmod -R o-w "$linkchecker_pkg_dir" | |
linkchecker --no-warnings ./docs_test/_build/html/ | |
pylint: | |
name: Check for errors using pylint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install pylint and dependencies | |
run: | | |
python -m pip install --progress-bar=off -r requirements.txt pylint | |
- name: Run pylint | |
env: | |
PYLINT_OPTIONS: --errors-only | |
PYLINT_TARGETS: build.py build_util | |
run: | | |
pylint $PYLINT_OPTIONS $PYLINT_TARGETS |