-
Notifications
You must be signed in to change notification settings - Fork 320
235 lines (226 loc) · 8.08 KB
/
tests.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
name: continuous-integration
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
# README
# ======
#
# All the jobs are defined with `matrix` for OS and Python version, even if we
# only run them on one combination of OS/Python. The reason for this is you get
# a nice side-effect that the OS and Python version of the job are listed in
# parentheses next to the job name in the Actions UI.
# This prevents workflows from being run twice on PRs
# ref: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
on:
push:
branches:
- main
pull_request:
workflow_call:
jobs:
lint:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- uses: pre-commit/[email protected]
# run our test suite on various combinations of OS / Python / Sphinx version
run-pytest:
needs: [lint]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
sphinx-version: ["rls"]
include:
# macos test
- os: macos-latest
python-version: "3.12"
sphinx-version: "rls"
# windows test
- os: windows-latest
python-version: "3.12"
sphinx-version: "rls"
# old Sphinx test
- os: ubuntu-latest
python-version: "3.9"
sphinx-version: "old"
# dev Sphinx test
- os: ubuntu-latest
python-version: "3.12"
sphinx-version: "dev"
# needed to cache the browsers for the accessibility tests
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
SPHINX_VERSION: ${{ matrix.sphinx-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
# waiting for https://github.com/nikeee/setup-pandoc/pull/8
# using 12rambau fork until then
- uses: 12rambau/setup-pandoc@test
- name: Install dependencies
# if Sphinx version not specified in matrix, the constraints in the
# pyproject.toml file determine Sphinx version
shell: bash
# setting shell to BASH and using PYTHONUTF8 env var makes the editable
# install work on Windows even though there are emoji in our README
run: ./tools/github_actions_install.sh test
- name: Show installed versions
run: python -m pip list
- name: Compile MO files
run: |
pip install nox
nox -s compile
- name: Run tests
run: pytest -m "not a11y" --color=yes --cov --cov-report=xml
- name: Upload to Codecov
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev'
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# note I am setting this on top of the Python cache as I could not find
# how to set the hash key on the python one
- name: Set up browser cache (for accessibility tests)
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-pw-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pw-
- name: Run accessibility tests with playwright
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
run: |
nox -s a11y
continue-on-error: true
# Build our site on the 3 major OSes and check for Sphinx warnings
build-site:
needs: [lint]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12"]
sphinx-version: [""]
include:
- os: ubuntu-latest
python-version: "3.9"
sphinx-version: "old"
# crash with myst parser
# will be restored when myst will be dropped from our documentation
# - os: ubuntu-latest
# python-version: "3.12"
# sphinx-version: "dev"
env:
SPHINX_VERSION: ${{ matrix.sphinx-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# waiting for https://github.com/nikeee/setup-pandoc/pull/8
# using 12rambau fork until then
- uses: 12rambau/setup-pandoc@test
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
shell: bash
run: ./tools/github_actions_install.sh doc
- name: Show installed versions
run: python -m pip list
- name: Build docs
run: sphinx-build -b html docs/ docs/_build/html --keep-going -w warnings.txt
- name: Check for unexpected Sphinx warnings
run: python tests/utils/check_warnings.py
# Run local Lighthouse audit against built site
audit:
needs: [build-site]
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
run: ./tools/github_actions_install.sh doc
shell: bash
- name: Show installed versions
run: python -m pip list
# We want to run the audit on a simplified documentation build so that
# the audit results aren't affected by non-theme things like extensions.
# Here we copy over just the kitchen sink into an empty docs site with
# only the theme loaded so extensions don't play a role in audit scores.
- name: Copy kitchen sink to a tiny site and build it
run: |
mkdir audit/
mkdir audit/site
cp -r docs/examples/kitchen-sink audit/site/kitchen-sink
printf "Test\n====\n\n.. toctree::\n\n kitchen-sink/index\n" > audit/site/index.rst
echo 'html_theme = "pydata_sphinx_theme"' > audit/site/conf.py
echo '.. toctree::\n :glob:\n\n *' >> audit/site/index.rst
sphinx-build audit/site audit/_build
# The lighthouse audit runs directly on the HTML files, no serving needed
- name: Audit with Lighthouse
uses: treosh/lighthouse-ci-action@v11
with:
configPath: ".github/workflows/lighthouserc.json"
temporaryPublicStorage: true
uploadArtifacts: true
runs: 3 # Multiple runs to reduce variance
# Generate a profile of the code and upload as an artifact
profile:
needs: [build-site, run-pytest]
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
run: ./tools/github_actions_install.sh test nox
shell: bash
- name: Show installed versions
run: python -m pip list
- name: Generate a profile
run: nox -s profile
continue-on-error: true
- uses: actions/upload-artifact@v4
with:
name: profile-results
path: profile.svg