forked from IDAES/idaes-pse
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (142 loc) · 5.05 KB
/
core.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Tests
on:
push:
branches:
- main
- '*_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=ci_run_tests`
types: [ci_run_tests]
workflow_dispatch:
inputs:
git-ref:
description: Git hash (optional)
required: false
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
env:
# default Python version to use for checks that do not require multiple versions
DEFAULT_PYTHON_VERSION: '3.8'
IDAES_CONDA_ENV_NAME_DEV: idaes-pse-dev
PYTEST_ADDOPTS: "--color=yes"
defaults:
run:
# -l: login shell, needed when using Conda run:
shell: bash -l {0}
jobs:
pytest:
# description: Run pytest with dev dependencies
name: pytest (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
os:
- ubuntu-18.04
- windows-latest
include:
- python-version: '3.8'
# only generate coverage report for a single python version in the matrix
# to avoid overloading Codecov
cov-report: true
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/display-debug-info
- name: Set up Conda environment
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }}
python-version: ${{ matrix.python-version }}
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: -r requirements-dev.txt
- name: Add pytest CLI options for coverage
if: matrix.cov-report
run: |
echo PYTEST_ADDOPTS="$PYTEST_ADDOPTS --cov --cov-report=xml" >> "$GITHUB_ENV"
- name: Run pytest (not integration)
run: |
pytest -m "not integration"
- name: Upload coverage report to Codecov
if: matrix.cov-report
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
build-docs:
name: Build Sphinx docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Conda environment
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }}
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
run: |
which python
cd docs/
python build.py --timeout 600
- 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
env:
pylint_target_dir: idaes/
pylint_output_path: pylint.json
pylint_todo_sentinel: PYLINT-TODO
steps:
- uses: actions/checkout@v2
# NOTE: using Conda instead of actions/setup-python in this job is not strictly necessary
# as it doesn't need to run on Windows or use the setup-idaes local action,
# but we do it for consistency with the other jobs
- name: Set up Conda environment
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }}
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: -r requirements-dev.txt
- name: Run pylint
run: |
echo "::group::Display pylint version"
pip show pylint astroid
echo "::endgroup::"
pylint --rcfile=./.pylint/pylintrc --disable=W,C,R,I --output-format=idaes_reporters.MultiReporter "$pylint_target_dir"
- name: Generate pylint report on failure
if: failure()
run: |
base_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/blame/$GITHUB_SHA"
python .pylint/render_report.py --base-url="$base_url" "$pylint_output_path"
- name: Show PYLINT-TODO comments left in the codebase
if: always()
run: |
# use a bash array to save options containing quotes to a variable, then use the double-quoted array expansion "${arr[@]}"
grep_opts=( --recursive --include '*.py' --color=always --after-context=2 --line-number --initial-tab )
grep "$pylint_todo_sentinel" "${grep_opts[@]}" "$pylint_target_dir" || echo "No \"$pylint_todo_sentinel\" comments found in $pylint_target_dir"