Skip to content

GAC Test Harness

GAC Test Harness #7403

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Checks
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
# NOTE: the value of `group` should be chosen carefully,
# otherwise we might end up over- or under-canceling workflow runs
# github.head_ref is only defined for pull request events
# so, if it's not present (i.e. event was triggered by push)
# we use github.ref instead
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
# important to make sure that all commands on Windows are run using Bash
# -l: login shell, needed when using Conda
shell: bash -l {0}
env:
# --color=yes needed for colorized output to be shown in GHA logs
# --pyargs watertap is needed to be able to define CLI options in watertap/conftest.py
PYTEST_ADDOPTS: "--color=yes"
PIP_PROGRESS_BAR: "off"
jobs:
code-formatting:
name: Check code is formatted (Black)
# OS and/or Python version don't make a difference, so we choose ubuntu and 3.8 as defaults
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install Black
# unlike the other jobs, we don't need to install WaterTAP and/or all the dev dependencies,
# but we still want to specify the Black version to use in requirements-dev.txt for local development
# so we extract the relevant line and pass it to a simple `pip install`
run: |
black_requirement="$(grep '^black==' requirements-dev.txt)"
pip --no-cache-dir install "$black_requirement"
- name: Run Black to verify that the committed code is formatted
run: |
black --check .
pylint:
name: Code linting (pylint)
runs-on: ubuntu-latest
needs: [code-formatting]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dev dependencies
run: |
pip install -r requirements-dev.txt
pip list
- name: Run pylint
run: |
pylint watertap
tests:
name: Tests (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os-version }}
needs: [code-formatting]
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
os:
- linux
- win64
# - macos
include:
- os: linux
os-version: ubuntu-20.04
- os: win64
os-version: windows-2019
# - os: macos
# os-version: macos-10.15
- python-version: '3.8'
# limit uploading coverage report for a single Python version in the matrix
cov_report: true
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: watertap-dev
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
echo '::group::Output of "conda install" commands'
conda install --quiet --yes pip setuptools wheel pandoc
echo '::endgroup::'
echo '::group::Output of "pip install" commands'
pip install -r requirements-dev.txt
echo '::endgroup::'
echo '::group::Output of "pip install -U ray" command'
pip install -U ray
echo '::endgroup::'
echo '::group::Display installed packages'
conda list
pip list
pip show idaes-pse
echo '::endgroup::'
echo '::group::Output of "idaes get-extensions" command'
idaes get-extensions --verbose
echo '::endgroup::'
- name: Add coverage report pytest options
if: matrix.cov_report
run:
|
echo PYTEST_ADDOPTS="$PYTEST_ADDOPTS --cov-report=xml" >> $GITHUB_ENV
- name: Test with pytest
run: |
pytest --pyargs watertap
- name: Upload coverage report to Codecov
if: matrix.cov_report
uses: codecov/codecov-action@v2
- name: Test documentation code
run: |
make -C docs doctest -d
# TODO: this should be moved to a dedicated job/workflow
# until then, we can leave this here as a reminder
- name: Test documentation links
if: 'false'
run: |
make -C docs linkcheck -d
user-mode-pytest:
name: pytest (user mode) (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os-version }}
needs: [code-formatting]
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.11'
os:
- linux
- win64
include:
- os: linux
os-version: ubuntu-20.04
- os: win64
os-version: windows-2019
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: watertap
python-version: ${{ matrix.python-version }}
- name: Define install URL (default)
env:
_repo_full_name: watertap-org/watertap
_ref_to_install: main
run: |
echo "_install_url=https://github.com/${_repo_full_name}/archive/${_ref_to_install}.zip" >> $GITHUB_ENV
- name: Define install URL (for PRs)
if: github.event.pull_request
env:
_repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
_ref_to_install: ${{ github.event.pull_request.head.sha }}
run:
echo "_install_url=https://github.com/${_repo_full_name}/archive/${_ref_to_install}.zip" >> $GITHUB_ENV
- name: Install watertap and testing dependencies
run: |
echo '::group::Output of "pip install" commands'
pip install "watertap @ ${_install_url}" pytest
echo '::endgroup::'
echo '::group::Display installed packages'
conda list
pip list
pip show idaes-pse
echo '::endgroup::'
echo '::group::Output of "idaes get-extensions" command'
idaes get-extensions --verbose
echo '::endgroup::'
- name: Run pytest
run: |
pytest --pyargs watertap
notebooks:
name: Test notebooks (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os-version }}
needs: [code-formatting]
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.11'
os:
- linux
- win64
include:
- os: linux
os-version: ubuntu-20.04
- os: win64
os-version: windows-2019
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: watertap-dev
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
echo '::group::Output of "conda install" commands'
conda install --quiet --yes pip setuptools wheel pandoc
echo '::endgroup::'
echo '::group::Output of "pip install" commands'
pip install -r requirements-dev.txt
echo '::endgroup::'
echo '::group::Display installed packages'
conda list
pip list
pip show idaes-pse
echo '::endgroup::'
echo '::group::Output of "idaes get-extensions" command'
idaes get-extensions --verbose
echo '::endgroup::'
- name: Run pytest with nbmake
run:
pytest --nbmake **/*.ipynb
macos:
name: macOS setup (EXPERIMENTAL)
runs-on: macos-11
needs: [code-formatting]
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: watertap
python-version: ${{ matrix.python-version }}
- name: Install WaterTAP (dev) without idaes get-extensions
run: |
echo '::group::Output of "conda install" commands'
conda install --quiet --yes pip=21.1 wheel setuptools pandoc
echo '::endgroup::'
echo '::group::Output of "pip install" commands'
pip install -r requirements-dev.txt
echo '::endgroup::'
echo '::group::Display installed packages'
conda list
pip list
pip show pyomo idaes-pse
echo '::endgroup::'
- name: Install Ipopt from conda-forge
run:
conda install --quiet --yes -c conda-forge ipopt=3.14.11
- name: Build Pyomo extensions
run: |
conda install --quiet --yes cmake
# some failures are expected, but this should succeed as long as pynumero is built correctly
pyomo build-extensions || python -c "from pyomo.contrib.pynumero.asl import AmplInterface; exit(0) if AmplInterface.available() else exit(1)"
- name: Run pytest
run: |
pytest --pyargs watertap -k 'not (nf_dspmde.nf_ui or nf_dspmde.nf_with_bypass_ui or mvc.mvc_single_stage_ui)'