forked from watertap-org/watertap
-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (233 loc) · 8.64 KB
/
checks.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# 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]
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 --pyargs watertap"
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@v2
- uses: actions/setup-python@v2
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 --progress-bar off "$black_requirement"
- name: Run Black to verify that the committed code is formatted
run: |
black --check .
tests:
name: Tests (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os-version }}
# TODO: Grab cloud database password from encrypted repo secrets
# TODO: and place in environment so tests can use it.
# env:
# EDB_CLOUD_PASSWORD: ${{ secrets.EDB_CLOUD_PASSWORD }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
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
- os: linux
# supercharge/mongodb-github-action is a container action, that's only available for Linux
mongodb_server: true
steps:
- uses: actions/checkout@v2
- 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 --progress-bar off -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: Set up MongoDB server
if: matrix.mongodb_server
uses: supercharge/mongodb-github-action@3f91157600649d0002802978c8b6fb6ee659a2dd
# with:
# everything else being equal, we test against 4.03 since it's the latest available
# through Conda, which makes installation significantly easier for users
# mongodb-version: "4.03"
- name: Test connection to MongoDB instance
if: matrix.mongodb_server
env:
_tests_that_should_not_be_skipped: db_api
_pytest_output_to_inspect: .pytest-edb-mongodb.log
run: |
# load EDB
edb load -b
# run subset of tests that should not be skipped if the MongoDB instance is accessible to the EDB
pytest -k "$_tests_that_should_not_be_skipped" --verbose --capture=tee-sys | tee "$_pytest_output_to_inspect"
echo '::group::pytest output to be inspected for skipped files'
cat "$_pytest_output_to_inspect"
echo '::endgroup::'
echo '::group::output of grep searching for skipped tests in pytest output'
bash -c 'grep "SKIPPED" "$_pytest_output_to_inspect" ; test $? -eq 1'
echo '::endgroup::'
- name: Require EDB tests to connect to MongoDB if server is set up
if: matrix.mongodb_server
run:
|
echo PYTEST_ADDOPTS="$PYTEST_ADDOPTS --edb-no-mock" >> $GITHUB_ENV
- name: Test EDB client
run: pytest -k test_edb_client
- 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
- 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 }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.10'
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 --progress-bar off "watertap[testing] @ ${_install_url}"
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
macos:
name: macOS setup (EXPERIMENTAL)
runs-on: macos-11
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
steps:
- uses: actions/checkout@v2
- 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 --progress-bar off -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
- 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