-
Notifications
You must be signed in to change notification settings - Fork 326
156 lines (133 loc) · 4.92 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
name: continuous-integration
# 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:
env:
COVERAGE_THRESHOLD: 60
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- uses: pre-commit/[email protected]
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
include:
- os: macos-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.9"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install -e .[coverage]
python -m pip list
- name: Test Sphinx==4.2
if: matrix.python-version == '3.7'
run: |
python -m pip install sphinx==4.2
python -m pip list
- name: Build docs to store
run: sphinx-build -b html docs/ docs/_build/html --keep-going -w warnings.txt
- name: Check that there are no unexpected Sphinx warnings
if: matrix.python-version == '3.9'
shell: python
run: |
from pathlib import Path
text = Path("./warnings.txt").read_text().strip()
print("\n=== Sphinx Warnings ===\n\n" + text) # Print just for reference so we can look at the logs
unexpected = [ii for ii in text.split("\n") if all(i not in ii for i in ["frame.py", "_static", "parse.py"])]
for ii in unexpected:
print(f"Unexpected warning: \n{unexpected}\n\n")
assert len(unexpected) == 0
- name: Run the tests
run: pytest --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }}
- name: Upload coverage
if: ${{ always() }}
run: codecov
# Run local Lighthouse audit against built site
audit:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install -e .[coverage]
# 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@v9
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:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools nox
- name: Generate a profile
run: |
nox -s profile
continue-on-error: true
- uses: actions/upload-artifact@v3
with:
name: profile-results
path: profile.svg