Repository navigation
234 lines (205 loc) · 7.36 KB
/
Copy pathci.yml
File metadata and controls
234 lines (205 loc) · 7.36 KB
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
name: continuous-integration
on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.11"
- uses: pre-commit/action@v3.0.1
tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
sphinx-version: ["~=7.0", "~=8.0", "~=9.0"]
extras: ["testing"]
include:
- os: windows-latest
python-version: "3.11"
sphinx-version: "~=7.0"
extras: "testing"
- os: windows-latest
python-version: "3.13"
sphinx-version: "~=8.0"
extras: "testing"
- os: windows-latest
python-version: "3.14"
sphinx-version: "~=9.0"
extras: "testing"
runs-on: ${{ matrix.os }}
name: Tests (py${{ matrix.python-version }}, Sphinx${{ matrix.sphinx-version }}, on ${{ matrix.os }})
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade "sphinx${{ matrix.sphinx-version }}" -e .[${{ matrix.extras}}]
- name: Run pytest
run: |
pytest --cov=sphinx_design --cov-report=xml --cov-report=term-missing
- name: Upload to Codecov
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' && matrix.python-version == '3.13' && matrix.sphinx-version == '~=8.0' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: pytests
flags: pytests
files: ./coverage.xml
# coverage is informational: an upload failure must not fail CI
fail_ci_if_error: false
docs-build-format:
runs-on: ubuntu-latest
strategy:
matrix:
format: [html, latex, man]
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[rtd]
- name: Install SVG conversion tools (for sphinx.ext.imgconverter)
if: matrix.format == 'latex'
run: sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends imagemagick librsvg2-bin
- name: Build documentation
run: sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }}
docs-build-pdf:
# compiling the LaTeX sources catches what the sphinx build alone cannot:
# missing LaTeX packages and icon names unknown to fontawesome5.sty
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[rtd]
- name: Install SVG conversion tools (for sphinx.ext.imgconverter)
run: sudo apt-get update -q && sudo apt-get install -y -q --no-install-recommends imagemagick librsvg2-bin
- name: Build LaTeX sources
run: sphinx-build -nW --keep-going -b latex docs/ docs/_build/latex
- name: Compile PDF
uses: xu-cheng/latex-action@v4
with:
# TeX Live 2026's colortbl loops with Sphinx <9.1.1 table colorrows
# (sphinx-doc/sphinx#14465) — drop this pin once on sphinx >=9.1.1
texlive_version: "2025"
working_directory: docs/_build/latex
root_file: sphinxdesign.tex
- name: Upload PDF
uses: actions/upload-artifact@v7
with:
name: docs-pdf
path: docs/_build/latex/sphinxdesign.pdf
build:
# builds with the project's own [build-system] backend pin, the same way a release does,
# so a packaging problem shows up on the PR rather than when a tag is pushed
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Install build tools
run: python -m pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- name: Check the distributions
run: python -m twine check --strict dist/*
- name: Check the tag matches the built version
if: startsWith(github.ref, 'refs/tags/v')
# compares parsed versions, so a tag such as v0.8.0-rc1 matches the normalized 0.8.0rc1;
# packaging is installed with build and twine
shell: python
run: |
import os, pathlib, sys
from packaging.version import InvalidVersion, Version
ref = os.environ["GITHUB_REF_NAME"]
try:
tag = Version(ref.removeprefix("v"))
except InvalidVersion:
sys.exit(f"tag {ref} is not a valid version")
dist = pathlib.Path("dist")
versions = {p.name.split("-")[1] for p in dist.glob("*.whl")}
versions |= {p.name.removesuffix(".tar.gz").rsplit("-", 1)[1] for p in dist.glob("*.tar.gz")}
if not versions or {Version(v) for v in versions} != {tag}:
sys.exit(f"tag {ref} does not match the built version(s) {sorted(versions)}")
print(f"tag {ref} matches the built version(s) {sorted(versions)}")
- name: Upload the distributions
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
retention-days: 7
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- pre-commit
- tests
- docs-build-format
- docs-build-pdf
- build
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
publish:
# PyPI trusted publishing: the PyPI publisher is registered for this workflow file (ci.yml)
# and the `pypi` environment, so do not rename either
name: Publish to PyPI
# `check` fails when any job it needs fails, so every job gating a merge also gates a release;
# `build` is listed too because it produces the `dist` artifact this job uploads
needs: [check, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sphinx-design
permissions:
id-token: write # the only permission this job has
steps:
- name: Download the distributions
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
# uploads attestations by default
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1