Skip to content

Commit 46ee983

Browse files
authored
MAINT: Refactor workflows to reduce test dependencies (#1136)
1 parent a6329b6 commit 46ee983

File tree

4 files changed

+95
-66
lines changed

4 files changed

+95
-66
lines changed

.github/workflows/tests.yml

+90-48
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: continuous-integration
22

3+
# README
4+
# ======
5+
#
6+
# All the jobs are defined with `matrix` for OS and Python version, even if we
7+
# only run them on one combination of OS/Python. The reason for this is you get
8+
# a nice side-effect that the OS and Python version of the job are listed in
9+
# parentheses next to the job name in the Actions UI.
10+
311
# This prevents workflows from being run twice on PRs
412
# ref: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
513
on:
@@ -14,86 +22,123 @@ env:
1422

1523
jobs:
1624
lint:
17-
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest]
28+
python-version: ["3.11"]
29+
runs-on: ${{ matrix.os }}
1830
steps:
1931
- uses: actions/checkout@v3
20-
- uses: actions/setup-python@v4
32+
- name: Setup Python
33+
uses: actions/setup-python@v4
2134
with:
22-
python-version: "3.9"
35+
python-version: ${{ matrix.python-version }}
2336
cache: "pip"
2437
cache-dependency-path: "pyproject.toml"
2538
- uses: pre-commit/[email protected]
2639

27-
tests:
28-
runs-on: ${{ matrix.os }}
40+
# run our test suite on various combinations of OS / Python / Sphinx version
41+
run-pytest:
2942
strategy:
3043
fail-fast: false
3144
matrix:
3245
os: [ubuntu-latest]
33-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
46+
python-version: ["3.8", "3.9", "3.10", "3.11"]
3447
include:
48+
# legacy test
49+
- os: ubuntu-latest
50+
python-version: "3.7"
51+
sphinx-version: "4.2"
52+
# macos test
3553
- os: macos-latest
36-
python-version: "3.9"
54+
python-version: "3.11"
55+
# windows test
3756
- os: windows-latest
38-
python-version: "3.9"
39-
57+
python-version: "3.11"
58+
runs-on: ${{ matrix.os }}
4059
steps:
4160
- uses: actions/checkout@v3
42-
- name: Set up Python ${{ matrix.python-version }}
61+
- name: Setup Python
4362
uses: actions/setup-python@v4
4463
with:
4564
python-version: ${{ matrix.python-version }}
4665
cache: "pip"
4766
cache-dependency-path: "pyproject.toml"
48-
4967
- name: Install dependencies
68+
# if Sphinx version not specified in matrix, the constraints in the
69+
# pyproject.toml file determine Sphinx version
70+
if: false == matrix.sphinx-version
71+
shell: bash
72+
# setting shell to BASH and using PYTHONUTF8 env var makes the editable
73+
# install work on Windows even though there are emoji in our README
5074
run: |
75+
export PYTHONUTF8=1
5176
python -m pip install --upgrade pip wheel setuptools
52-
python -m pip install -e .[coverage]
53-
python -m pip list
54-
55-
- name: Test Sphinx==4.2
56-
if: matrix.python-version == '3.7'
77+
python -m pip install -e .[test]
78+
- name: Install dependencies (legacy Sphinx)
79+
# here we override the pyproject.toml constraints to get a specific
80+
# Sphinx version.
81+
if: matrix.sphinx-version
5782
run: |
58-
python -m pip install sphinx==4.2
59-
python -m pip list
83+
python -m pip install --upgrade pip wheel setuptools
84+
python -m pip install -e .[test] sphinx==${{ matrix.sphinx-version }}
85+
- name: Show installed versions
86+
run: python -m pip list
87+
- name: Run tests
88+
run: pytest --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }}
6089

61-
- name: Build docs to store
90+
# Build our site on the 3 major OSes and check for Sphinx warnings
91+
build-site:
92+
strategy:
93+
fail-fast: false
94+
matrix:
95+
os: [ubuntu-latest, macos-latest, windows-latest]
96+
python-version: ["3.11"]
97+
runs-on: ${{ matrix.os }}
98+
steps:
99+
- uses: actions/checkout@v3
100+
- name: Setup Python
101+
uses: actions/setup-python@v4
102+
with:
103+
python-version: ${{ matrix.python-version }}
104+
cache: "pip"
105+
cache-dependency-path: "pyproject.toml"
106+
- name: Install dependencies
107+
shell: bash
108+
# setting shell to BASH and using PYTHONUTF8 env var makes the editable
109+
# install work on Windows even though there are emoji in our README
110+
run: |
111+
export PYTHONUTF8=1
112+
python -m pip install --upgrade pip wheel setuptools
113+
python -m pip install -e .[doc]
114+
- name: Show installed versions
115+
run: python -m pip list
116+
- name: Build docs
62117
run: sphinx-build -b html docs/ docs/_build/html --keep-going -w warnings.txt
63-
64-
- name: Check that there are no unexpected Sphinx warnings
65-
if: matrix.python-version == '3.9'
118+
- name: Check for unexpected Sphinx warnings
66119
run: python tests/check_warnings.py
67120

68-
- name: Run the tests
69-
run: pytest --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }}
70-
71-
- name: Upload coverage
72-
if: ${{ always() }}
73-
run: codecov
74-
75121
# Run local Lighthouse audit against built site
76122
audit:
77-
runs-on: ubuntu-latest
78123
strategy:
79124
matrix:
80-
python-version: ["3.8"]
81-
125+
os: [ubuntu-latest]
126+
python-version: ["3.11"]
127+
runs-on: ${{ matrix.os }}
82128
steps:
83129
- uses: actions/checkout@v3
84-
85-
- name: Set up Python ${{ matrix.python-version }}
130+
- name: Setup Python
86131
uses: actions/setup-python@v4
87132
with:
88133
python-version: ${{ matrix.python-version }}
89134
cache: "pip"
90135
cache-dependency-path: "pyproject.toml"
91-
92136
- name: Install dependencies
93137
run: |
94138
python -m pip install --upgrade pip wheel setuptools
95-
python -m pip install -e .[coverage]
96-
139+
python -m pip install -e .[doc]
140+
- name: Show installed versions
141+
run: python -m pip list
97142
# We want to run the audit on a simplified documentation build so that
98143
# the audit results aren't affected by non-theme things like extensions.
99144
# Here we copy over just the kitchen sink into an empty docs site with
@@ -107,7 +152,6 @@ jobs:
107152
echo 'html_theme = "pydata_sphinx_theme"' > audit/site/conf.py
108153
echo '.. toctree::\n :glob:\n\n *' >> audit/site/index.rst
109154
sphinx-build audit/site audit/_build
110-
111155
# The lighthouse audit runs directly on the HTML files, no serving needed
112156
- name: Audit with Lighthouse
113157
uses: treosh/lighthouse-ci-action@v9
@@ -119,30 +163,28 @@ jobs:
119163

120164
# Generate a profile of the code and upload as an artifact
121165
profile:
122-
runs-on: ubuntu-latest
123166
strategy:
124167
matrix:
125-
python-version: ["3.8"]
126-
168+
os: [ubuntu-latest]
169+
python-version: ["3.11"]
170+
runs-on: ${{ matrix.os }}
127171
steps:
128172
- uses: actions/checkout@v3
129-
130-
- name: Set up Python ${{ matrix.python-version }}
173+
- name: Setup Python
131174
uses: actions/setup-python@v4
132175
with:
133176
python-version: ${{ matrix.python-version }}
134177
cache: "pip"
135178
cache-dependency-path: "pyproject.toml"
136-
137179
- name: Install dependencies
138180
run: |
139181
python -m pip install --upgrade pip wheel setuptools nox
140-
182+
python -m pip install -e .[test]
183+
- name: Show installed versions
184+
run: python -m pip list
141185
- name: Generate a profile
142-
run: |
143-
nox -s profile
186+
run: nox -s profile
144187
continue-on-error: true
145-
146188
- uses: actions/upload-artifact@v3
147189
with:
148190
name: profile-results

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
# a list of builtin themes.
6969
#
7070
html_theme = "pydata_sphinx_theme"
71-
html_logo = "logo.svg"
71+
html_logo = "_static/logo.svg"
7272
html_favicon = "_static/logo.svg"
7373
html_sourcelink_suffix = ""
7474

pyproject.toml

+3-8
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ doc = [
4747
"numpydoc",
4848
"myst-nb",
4949
"linkify-it-py", # for link shortening
50-
"pytest",
51-
"pytest-regressions",
5250
"rich",
5351
"sphinxext-rediraffe",
5452
"sphinx-sitemap",
@@ -67,22 +65,19 @@ doc = [
6765
# it at the same time as MyST-NB.
6866
"nbsphinx",
6967
"ipyleaflet",
68+
"colorama",
7069
]
7170
test = [
7271
"pytest",
73-
"pydata-sphinx-theme[doc]",
74-
]
75-
coverage = [
7672
"pytest-cov",
73+
"pytest-regressions",
7774
"codecov",
78-
"colorama",
79-
"pydata-sphinx-theme[test]",
8075
]
8176
dev = [
8277
"pyyaml",
8378
"pre-commit",
8479
"nox",
85-
"pydata-sphinx-theme[coverage]",
80+
"pydata-sphinx-theme[doc,test]",
8681
]
8782

8883
[project.entry-points]

tests/test_build.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -779,19 +779,11 @@ def test_deprecated_build_html(sphinx_build_factory, file_regression):
779779
assert not sphinx_build.html_tree("page2.html").select("div.bd-sidebar-secondary")
780780

781781

782-
def test_ablog(sphinx_build_factory):
783-
"""Ensure that we are over-riding the ABlog default FontAwesome config."""
784-
785-
confoverrides = {"extensions": ["ablog"]}
786-
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
787-
assert sphinx_build.app.config.fontawesome_included is True
788-
789-
790782
def test_empty_templates(sphinx_build_factory):
791783
"""If a template is empty (e.g., via a config), it should be removed."""
792784
# When configured to be gone, the template should be removed w/ its parent.
793785
# ABlog needs to be added so we can test that template rendering works w/ it.
794-
confoverrides = {"html_show_sourcelink": False, "extensions": ["ablog"]}
786+
confoverrides = {"html_show_sourcelink": False}
795787
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
796788
toc_items = sphinx_build.html_tree("page1.html").select(".toc-item")
797789
assert not any(ii.select(".tocsection.sourcelink") for ii in toc_items)

0 commit comments

Comments
 (0)