forked from IDAES/idaes-pse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to GitHub Actions CI: integration tests on PR approval, …
…code coverage (IDAES#110) * Create dedicated actions for common tasks * Streamline PR workflow using actions in steps and more specific triggers * Move integration tests to dedicated workflow running on key label added * Add test coverage report creation and upload to Codecov as parallel job * Add dedicated workflow to run tests on protected branches * Add test coverage report creation and upload for main workflow * Remove Codecov token as it's not needed for public repos with GHA * Add Python 3.8 to the test matrix * Extract default Python version to workflow-level env variable * Fix typo * Incorporate coverage report into single unified pytest job * Add requirements-dev file needed to run pylint with --cov flag * Ensure bash is used on Windows for uploading coverage report to Codecov * Extract pytest to local action and restore '.' pip install target
1 parent
b96613e
commit cb635bd
Showing
10 changed files
with
327 additions
and
193 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Build Sphinx docs | ||
description: Requires the setup-idaes action to be run before this | ||
# TODO add options as inputs as needed | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Build Sphinx docs (HTML) | ||
shell: bash | ||
run: | | ||
cd docs/ | ||
python build.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Run pylint | ||
description: Run static analysis using pylint | ||
# TODO add inputs (options) as needed | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install pylint dependencies | ||
shell: bash | ||
run: | | ||
PIP_INSTALL="pip --no-cache-dir install --progress-bar off" | ||
$PIP_INSTALL --upgrade pip setuptools wheel | ||
# TODO the pylint version will have to be pinned | ||
# TODO installing idaes is necessary in our case because we import some idaes code in pylint plugins | ||
$PIP_INSTALL pylint -r requirements.txt | ||
# don't think we need to install the extensions, though | ||
- name: Run pylint (errors only) | ||
shell: bash | ||
run: | | ||
pylint -E --ignore-patterns="test_.*" idaes || true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Run pytest | ||
description: Run tests with pytest | ||
inputs: | ||
extra-args: | ||
description: Extra CLI arguments to pass to the pytest command (in addition to those specified here) | ||
required: false | ||
default: '' | ||
markexpr: | ||
description: Mark expression to pass to pylint's -m flag | ||
required: false | ||
default: '' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install dependencies needed for running tests | ||
shell: bash | ||
run: | | ||
python -m pip install pytest coverage pytest-cov | ||
- name: Run pytest | ||
shell: bash | ||
run: | | ||
pytest idaes/ -m '${{ inputs.markexpr }}' ${{ inputs.extra-args }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Set up IDAES | ||
description: Install IDAES and extensions | ||
inputs: | ||
install-target: | ||
description: 'Command-line arguments and options to pass to the install command, e.g. pip install' | ||
required: true | ||
install-command: | ||
description: 'Command to use to install `install-target`' | ||
required: false | ||
default: pip --no-cache-dir install --progress-bar off | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Update pip and other packaging tools | ||
shell: bash | ||
run: | | ||
${{ inputs.install-command }} pip setuptools wheel | ||
- name: Install idaes and dependencies | ||
shell: bash | ||
run: | | ||
${{ inputs.install-command }} ${{ inputs.install-target}} | ||
idaes --version | ||
- name: Install extensions | ||
shell: bash | ||
run: | | ||
idaes get-extensions --verbose | ||
# add bin directory to $PATH (only valid for subsequent steps) | ||
echo "$(idaes bin-directory)" >> $GITHUB_PATH | ||
- name: Test access to executables | ||
shell: bash | ||
run: | | ||
if [ "$RUNNER_OS" == "Windows" ]; then | ||
ipopt.exe -v | ||
else | ||
ipopt -v | ||
fi |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: | ||
# TODO this could also be run when pushing to main, but could end up clogging the CI when merging multiple PRs | ||
- rel_* | ||
schedule: | ||
# run daily at 5:00 am UTC (12 am ET/9 pm PT) | ||
- cron: '0 5 * * *' | ||
repository_dispatch: | ||
# to run this, send a POST API call at repos/IDAES/idaes-pse/dispatches with the specified event_type | ||
# e.g. `gh repos/IDAES/idaes-pse/dispatches -F event_type=run_tests` | ||
types: [run_tests] | ||
workflow_dispatch: | ||
inputs: | ||
git-ref: | ||
description: Git hash (optional) | ||
required: false | ||
|
||
env: | ||
# default Python version to use for checks that do not require multiple versions | ||
DEFAULT_PYTHON_VERSION: '3.7' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
pytest: | ||
name: All tests (py${{ matrix.python-version }}/${{ matrix.os }}) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: | ||
- '3.6' | ||
- '3.7' | ||
- '3.8' | ||
os: | ||
- ubuntu-18.04 | ||
- windows-latest | ||
steps: | ||
- name: Display debug info | ||
run: | | ||
echo '${{ toJSON(matrix) }}' | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up idaes | ||
uses: ./.github/actions/setup-idaes | ||
with: | ||
install-target: '.' | ||
- name: Run pytest (all) | ||
uses: ./.github/actions/pytest | ||
with: | ||
# empty markexpr will cause all tests to be collected | ||
markexpr: '' | ||
extra-args: --cov | ||
- name: Upload coverage report to Codecov | ||
run: | | ||
bash <(curl -s https://codecov.io/bash) | ||
build-docs: | ||
name: Build Sphinx docs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | ||
- name: Set up idaes | ||
uses: ./.github/actions/setup-idaes | ||
with: | ||
install-target: -r requirements-dev.txt | ||
- name: Build Sphinx docs | ||
uses: ./.github/actions/build-docs | ||
- name: Publish built docs | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: idaes-pse-docs-html | ||
path: docs/build/html/ | ||
retention-days: 7 | ||
pylint: | ||
name: pylint (errors only) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | ||
- name: Run pylint | ||
uses: ./.github/actions/pylint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: PR approved | ||
|
||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
check-skip: | ||
name: Check if integration tests should run | ||
# NOTE: the name of the special label is hardcoded here | ||
# it would be better to extract it to a more global location, e.g. the workflow-level env context, | ||
# but the env context is not available in job-level if expressions (only step-level ones) | ||
if: contains(github.event.label.name, 'approved') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Notify | ||
run: echo "The integration tests will run" | ||
pytest: | ||
name: Integration tests (py${{ matrix.python-version }}/${{ matrix.os }}) | ||
runs-on: ${{ matrix.os }} | ||
needs: [check-skip] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: | ||
- '3.6' | ||
- '3.7' | ||
- '3.8' | ||
os: | ||
- ubuntu-18.04 | ||
- windows-latest | ||
steps: | ||
- name: Display debug info | ||
run: | | ||
echo '${{ toJSON(matrix) }}' | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up idaes | ||
uses: ./.github/actions/setup-idaes | ||
with: | ||
install-target: '.' | ||
- name: Run pytest (integration) | ||
uses: ./.github/actions/pytest | ||
with: | ||
markexpr: integration | ||
extra-args: --cov | ||
- name: Upload coverage report to Codecov | ||
run: | | ||
bash <(curl -s https://codecov.io/bash) |
Oops, something went wrong.