-
Notifications
You must be signed in to change notification settings - Fork 54
162 lines (156 loc) · 5.24 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
name: Checks
on:
push:
branches:
- master
- '*_rel'
repository_dispatch:
# to run this, send a POST API call at repos/<user>/<repo>/dispatches with the specified event_type
# e.g. `gh repos/CCSI-Toolset/FOQUS/dispatches -F event_type=ci_run_tests`
types: [ci_run_tests]
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:
FOQUS_CONDA_ENV_NAME_DEV: ccsi-foqus-dev
PYTEST_BASETEMP: .pytest
jobs:
code-formatting:
name: Code formatting (Black)
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 FOQUS 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 .
pytest:
name: pytest (py${{ matrix.python-version }}/${{ matrix.os }})
needs: [code-formatting]
runs-on: ${{ matrix.os-version }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
# - '3.10'
os:
- linux
- win64
- macos
include:
- os: macos
os-version: macos-12
- os: linux
os-version: ubuntu-20.04
- os: win64
os-version: windows-2019
- python-version: "3.8" # avoid uploading coverage for full matrix
use_coverage: true
- python-version: "3.8" # this is to avoid installing optional dependencies in all environments
optional-dependencies: tensorflow sympy torch scikit-learn
env:
# uncomment this to debug Qt initialization errors
# QT_DEBUG_PLUGINS: '1'
MPLBACKEND: AGG
steps:
- uses: actions/checkout@v2
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.FOQUS_CONDA_ENV_NAME_DEV }}
python-version: ${{ matrix.python-version }}
- name: Set up FOQUS
uses: ./.github/actions/setup-foqus
with:
pip-install-target: -r requirements-dev.txt ${{ matrix.optional-dependencies }}
- name: Set common pytest flags
run:
echo 'PYTEST_ADDOPTS=--pyargs foqus_lib --verbose --color=yes --basetemp "${{ env.PYTEST_BASETEMP }}"' >> $GITHUB_ENV
- name: Set up GUI test environment (Linux)
if: contains(matrix.os, 'linux')
run: |
echo "QT_QPA_PLATFORM=minimal" >> $GITHUB_ENV
- name: Run pytest (default options)
if: "! matrix.use_coverage"
run: |
pytest foqus_lib/
- name: Run pytest (coverage)
if: matrix.use_coverage
run: |
pytest foqus_lib/ --cov=./ --cov-report=xml --cov-report=term
- name: Upload pytest artifacts
uses: actions/upload-artifact@v2
if: always()
with:
# TODO decide if we need a separate upload for each Python version
name: pytest-dir-${{ matrix.os }}-py${{ matrix.python-version }}
path: ${{ env.PYTEST_BASETEMP }}
retention-days: 7
- name: Upload coverage report to Codecov
if: matrix.use_coverage
uses: codecov/codecov-action@v2
pylint:
name: pylint (py${{ matrix.python-version }})
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
# - '3.10'
steps:
- uses: actions/checkout@v2
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.FOQUS_CONDA_ENV_NAME_DEV }}
python-version: ${{ matrix.python-version }}
- name: Set up FOQUS
uses: ./.github/actions/setup-foqus
with:
pip-install-target: -r requirements-dev.txt
- name: Run pylint
run: |
pylint --rcfile=.pylint/pylintrc --disable=W,C,R,I foqus_lib/
docs:
name: Build docs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.FOQUS_CONDA_ENV_NAME_DEV }}
python-version: ${{ matrix.python-version }}
- name: Set up FOQUS
uses: ./.github/actions/setup-foqus
with:
pip-install-target: -r requirements-dev.txt
- name: Build docs
run: |
cd docs/
make CLOPTS="-qW --keep-going" clean dummy