-
Notifications
You must be signed in to change notification settings - Fork 138
211 lines (173 loc) · 5.86 KB
/
lint-test.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
# SPDX-License-Identifier: MIT
name: Lint & Test
on:
push:
branches:
- 'master'
- 'v[0-9]+.[0-9]+.x' # matches to backport branches, e.g. v3.6.x
- 'run-ci/*'
tags:
pull_request:
merge_group:
types: [checks_requested]
permissions:
read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run pre-commit
id: pre-commit
uses: pre-commit/[email protected]
docs:
# unlike the other workflows, we are using version 20.04 here as
# readthedocs uses 20.04 for building our docs, and we want to be explicit
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/setup-env
with:
python-version: 3.8
- name: Run sphinx-build
run: nox -s docs -- --keep-going -W -w $GITHUB_STEP_SUMMARY
pyright:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
experimental: [false]
fail-fast: false
continue-on-error: ${{ matrix.experimental }}
steps:
- uses: actions/checkout@v4
- name: Set up environment
id: setup-env
uses: ./.github/actions/setup-env
env:
PDM_USE_VENV: true
PDM_VENV_IN_PROJECT: true
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pdm install -d -Gspeed -Gdocs -Gvoice
- name: Add .venv/bin to PATH
run: dirname "$(pdm info --python)" >> $GITHUB_PATH
- name: Set pyright version
run: |
PYRIGHT_VERSION="$(pdm run python -c 'import pyright; print(pyright.__pyright_version__)')"
echo "PYRIGHT_VERSION=$PYRIGHT_VERSION" >> $GITHUB_ENV
- name: Run pyright (Linux)
uses: jakebailey/[email protected]
id: pyright-linux
with:
version: ${{ env.PYRIGHT_VERSION }}
python-version: ${{ steps.setup-env.outputs.python-version }}
python-platform: "Linux"
annotate: ${{ matrix.python-version == '3.8' }} # only add comments for one version
warnings: true
- name: Run pyright (Windows)
uses: jakebailey/[email protected]
if: always() && (steps.pyright-linux.outcome == 'success' || steps.pyright-linux.outcome == 'failure')
with:
version: ${{ env.PYRIGHT_VERSION }}
python-version: ${{ steps.setup-env.outputs.python-version }}
python-platform: "Windows"
annotate: false # only add comments for one platform (see above)
warnings: true
misc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up environment
id: setup
uses: ./.github/actions/setup-env
with:
python-version: 3.8
- name: Run slotscheck
if: (success() || failure()) && steps.setup.outcome == 'success'
run: nox -s slotscheck
- name: Run check-manifest
if: (success() || failure()) && steps.setup.outcome == 'success'
run: nox -s check-manifest
# This only runs if the previous steps were successful, no point in running it otherwise
- name: Try building package
run: |
pdm install -dG build
pdm run python -m build
ls -la dist/
pdm run twine check --strict dist/*
# run the libcst parsers and check for changes
- name: libcst codemod
run: |
nox -s codemod -- run-all
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Please run 'nox -s codemod -- run-all' locally and commit the changes." >&2;
echo "::group::git diff"
git diff
echo "::endgroup::"
exit 1;
else
exit 0;
fi
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
experimental: [false]
fail-fast: true
continue-on-error: ${{ matrix.experimental }}
env:
GITHUB_STEP_SUMMARY_HEADER: "<details><summary>#name#</summary>\n<pre>"
GITHUB_STEP_SUMMARY_FOOTER: "</pre></details>\n"
steps:
- uses: actions/checkout@v4
- name: Set up environment
id: setup-env
uses: ./.github/actions/setup-env
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pdm install -dG test # needed for coverage
- name: Test package install
run: |
python -m pip install .
- name: Run pytest
id: run_tests
# use non-utc timezone, to test time/date-dependent features properly
env:
TZ: "America/New_York"
run: |
echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/Test Summary/" >> $GITHUB_STEP_SUMMARY
nox --force-python ${{ steps.setup-env.outputs.python-version }} -s test -- --color=no --cov-report= | tee -a $GITHUB_STEP_SUMMARY
echo "$GITHUB_STEP_SUMMARY_FOOTER" >> $GITHUB_STEP_SUMMARY
- name: Print Coverage Output
if: always() && (steps.run_tests.outcome == 'success' || steps.run_tests.outcome == 'failure')
run: |
echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/Coverage Summary/" >> $GITHUB_STEP_SUMMARY
pdm run coverage report | tee -a $GITHUB_STEP_SUMMARY
echo "$GITHUB_STEP_SUMMARY_FOOTER" >> $GITHUB_STEP_SUMMARY
# thanks to aiohttp for this part of the workflow
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- lint
- docs
- pyright
- misc
- pytest
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}