-
Notifications
You must be signed in to change notification settings - Fork 236
224 lines (210 loc) · 8.07 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
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
concurrency:
# NOTE: the value of `group` should be chosen carefully,
# otherwise we might end up over- or under-canceling workflow runs
# e.g. if we want to have Codecov results for each commit on `main`,
# we should use something `github.sha` instead of `github.ref_name`
# to avoid over-canceling runs from `main`
# in which case we'd need to access the PR number from somewhere else rather than `github.ref_name`
# to avoid under-canceling runs from PRs
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
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:
code-formatting:
name: Check code formatting (Black)
# OS and/or Python version don't make a difference, so we choose ubuntu and 3.10 for performance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install Black
# unlike the other jobs, we don't need to install IDAES 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: |
# we store the version
black_requirement="$(grep 'black==' requirements-dev.txt)"
pip --no-cache-dir install --progress-bar off "$black_requirement"
- name: Run Black to verify that the committed code is formatted
run: |
black --check .
spell-check:
name: Check Spelling
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Run Spell Checker
uses: crate-ci/typos@master
with:
config: ./.github/workflows/typos.toml
pytest:
# description: Run pytest with dev dependencies
name: pytest (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.runner-image }}
needs: [code-formatting, spell-check]
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os:
- linux
- win64
include:
- os: linux
runner-image: ubuntu-20.04
- os: win64
runner-image: windows-2022
- 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
needs: [code-formatting, spell-check]
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
runs-on: ubuntu-latest
needs: [code-formatting, spell-check]
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=R --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"
echo '
## Pylint failures
For more information, refer to the [Pylint section](https://github.com/IDAES/idaes-pse/wiki/IDAES-Check-Suite#pylint) of the [IDAES check suite Wiki page](https://github.com/IDAES/idaes-pse/wiki/IDAES-Check-Suite).
' >> "$GITHUB_STEP_SUMMARY"
python .pylint/render_report.py --base-url="$base_url" --markdown-output-path="$GITHUB_STEP_SUMMARY" --pylint-data-path="$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"
compat:
name: Compatibility tests
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: Create empty pytest.ini file
run: |
echo "" > pytest.ini
- name: Install and run compatibility tests
run: |
pip install "git+https://github.com/IDAES/[email protected]"
pytest --pyargs idaes_compatibility