Consolidate a few more Params #203
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: Checks | |
on: | |
push: | |
# FIXME uncomment to restrict workflow to only run on pushes to main | |
# using push rather than pull_request is a workaround needed because PR triggers are not available for private repos on a free plan | |
# branches: | |
# - main | |
repository_dispatch: | |
# to run this, send a POST API call at repos/<user>/<repo>/dispatches with the specified event_type | |
# e.g. `gh repos/project-pareto/project-pareto/dispatches -F event_type=ci_run_checks` | |
types: [ci_run_checks] | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
# ready_for_review occurs when a draft PR is turned to non-draft | |
- ready_for_review | |
# synchronize occurs whenever commits are pushed to the PR branch | |
- synchronize | |
defaults: | |
run: | |
# the -l flag is needed for the Conda environment to be activated properly | |
shell: bash -l {0} | |
env: | |
# needed for colorized output to be shown in GHA logs | |
PYTEST_ADDOPTS: "--color=yes" | |
PIP_PROGRESS_BAR: "off" | |
jobs: | |
pytest: | |
name: Tests (py${{ matrix.python-version }}/${{ matrix.os }}/${{ matrix.install-mode }}) | |
runs-on: ${{ matrix.os-version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
os: | |
# - linux | |
- win64 | |
# - macos | |
install-mode: | |
- user | |
- dev | |
include: | |
# - os: macos | |
# os-version: macos-10.15 | |
# - os: linux | |
# os-version: ubuntu-20.04 | |
- os: win64 | |
os-version: windows-2019 | |
- install-mode: dev | |
pip-install-target: -r requirements-dev.txt | |
- install-mode: user | |
pip-install-target: >- | |
"project-pareto[testing] @ git+${{ format('{0}/{1}@{2}', github.server_url, github.repository, github.ref) }}" | |
- install-mode: dev | |
python-version: '3.9' | |
cov-report: true | |
steps: | |
- uses: actions/checkout@v4 | |
if: matrix.install-mode == 'dev' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up package (install-mode=${{ matrix.install-mode }}) | |
run: | | |
pip --no-cache-dir install ${{ matrix.pip-install-target }} | |
idaes get-extensions --verbose | |
- name: Add pytest options to enable coverage report | |
if: matrix.cov-report | |
run: echo PYTEST_ADDOPTS="$PYTEST_ADDOPTS --cov --cov-report=xml" >> $GITHUB_ENV | |
- name: Run pytest | |
run: | | |
pytest --pyargs pareto -v | |
- name: Run toy case study | |
run: | | |
python -m pareto.tests.toy_case_study | |
- name: Upload coverage report as job artifact | |
if: matrix.cov-report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage.xml | |
if-no-files-found: error | |
upload-codecov: | |
name: Upload coverage to Codecov | |
needs: [pytest] | |
runs-on: ubuntu-latest | |
steps: | |
# the checkout step is needed to have access to codecov.yml | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-report | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
# NOTE: secrets are not available for pull_request workflows | |
# However, as of 2024-02-10, Codecov is still allowing tokenless upload from PRs | |
# but does require token for other workflows e.g. merge to `main` | |
# see https://github.com/codecov/codecov-action/issues/1274#issuecomment-1934437359 | |
token: ${{ secrets.CODECOV_TOKEN }} | |
black: | |
name: Run Black to verify that committed code is formatted | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install (dev mode) | |
run: | | |
pip --no-cache-dir install --progress-bar off -r requirements-dev.txt | |
- name: Run Black to verify that committed code is formatted | |
run: | | |
black --check . |