forked from NEMRI-org/primo-optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (127 loc) · 4.33 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Checks
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
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:
# needed for colorized output to be shown in GHA logs
PYTEST_ADDOPTS: "--color=yes"
PIP_PROGRESS_BAR: "off"
BING_API_KEY: ${{ secrets.BING_API_KEY }}
CENSUS_KEY: ${{ secrets.CENSUS_KEY }}
jobs:
pytest:
name: Tests (py${{ matrix.python-version }}/${{ matrix.os }}/${{ matrix.install-mode }})
runs-on: ${{ matrix.os-version }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
os:
- linux
- win64
install-mode:
- dev
include:
- os: linux
os-version: ubuntu-latest
- os: win64
os-version: windows-latest
- install-mode: dev
pip-install-target: -r requirements-dev.txt
- install-mode: dev
python-version: '3.9'
os: linux
cov-report: true
steps:
- uses: actions/checkout@v4
if: matrix.install-mode == 'dev'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up package (install-mode=${{ matrix.install-mode }})
run: |
pip --no-cache-dir install ${{ matrix.pip-install-target }}
playwright install
- name: Add pytest options to enable coverage report
if: matrix.cov-report
run: echo PYTEST_ADDOPTS="$PYTEST_ADDOPTS --cov --cov-report=xml" >> $GITHUB_ENV
- name: Run pytest
# Skip tests that require API Keys (Secrets) when pull request is opened
run: |
if [ ${{ github.event_name }} == 'pull_request' ]; then
pytest -v -m "not secrets and not scip and not widgets"
else
pytest -v -m "not scip and not widgets"
fi
- name: Upload coverage report as job artifact
if: matrix.cov-report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
if-no-files-found: error
upload-codecov:
name: Upload coverage to Codecov
needs: [pytest]
runs-on: ubuntu-latest
steps:
# the checkout step is needed to have access to codecov.yml
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: coverage-report
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
# NOTE: secrets are not available for pull_request workflows
# However, as of 2024-02-10, Codecov is still allowing tokenless upload from PRs
# but does require token for other workflows e.g. merge to `main`
# see https://github.com/codecov/codecov-action/issues/1274#issuecomment-1934437359
token: ${{ secrets.CODECOV_TOKEN }}
black:
name: Run Black to verify that committed code is formatted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install (dev mode)
run: |
pip --no-cache-dir install --progress-bar off -r requirements-dev.txt
- name: Run Black to verify that committed code is formatted
run: |
black --check .
isort:
name: Run isort to verify that committed code has imports alphabetically sorted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install (dev mode)
run: |
pip --no-cache-dir install --progress-bar off -r requirements-dev.txt
- name: Run isort
run: |
isort --check primo