forked from jbms/sphinx-immaterial
-
Notifications
You must be signed in to change notification settings - Fork 1
260 lines (253 loc) · 8.63 KB
/
build.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 1,16 * *'
jobs:
check_conventions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nox-sessions:
- 'black check_yaml check_json check_toml check_eof check_trailing_space check_lf'
python-version: ['3.x']
node-version: ['16.x']
include:
- nox-sessions: 'mypy pylint'
python-version: '3.8'
- nox-sessions: 'mypy pylint'
python-version: '3.9'
- nox-sessions: 'mypy pylint'
python-version: '3.10'
- nox-sessions: 'mypy pylint'
python-version: '3.11'
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
if: contains(matrix, 'node-version')
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
id: python-setup
with:
python-version: ${{ matrix.python-version }}
- name: Cache node.js modules
if: contains(matrix, 'node-version')
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Cache nox environments
if: contains(matrix, 'node-version')
uses: actions/cache@v3
with:
path: |
.nox/black
.nox/check_*
key: nox-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('requirements/dev-black.txt', 'requirements/dev-pre_commit_hooks.txt') }}
- run: npm install
if: contains(matrix, 'node-version')
- run: npm run check
if: contains(matrix, 'node-version')
- run: pipx run nox -s ${{ matrix.nox-sessions }}
build:
needs: [check_conventions]
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
python-version:
- '3.x'
node-version:
- '16.x'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
# Need full history to determine version number.
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache node.js modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- run: npm install
- name: Check for dirty working directory
run: git diff --exit-code
- run: python -m pip install nox
- name: Build distributions
id: dist
run: nox -s dist
- name: Install wheel
run: python -m pip install "${{ steps.dist.outputs.wheel }}"
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: python-packages-${{ runner.os }}
path: |
dist/*.whl
dist/*.tar.*
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9 # v1.2.0
with:
macos-skip-brew-update: 'true'
- name: Build docs
run: nox -s docs
- name: Upload doc builds as artifacts
uses: actions/upload-artifact@v4
with:
name: doc-builds-${{ runner.os }}
path: docs/_build/
- name: upload docs to github pages
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && runner.os == 'Linux'
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 # pinned to v3.9.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
test:
needs: [check_conventions]
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
sphinx-version:
- 'sphinx4'
- 'sphinx5'
- 'sphinx6'
node-version:
- '16.x'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache node.js modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- run: npm install
- name: Build CSS and JS bundles
run: npm run build
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9 # v1.2.0
with:
macos-skip-brew-update: 'true'
- name: Run Python tests
env:
COVERAGE_FILE: .coverage.${{ github.run_id }}.${{ github.run_attempt }}.${{ runner.os }}.${{ matrix.python-version }}.${{ matrix.sphinx-version }}
# `coverage run` cmd adds the working dir to python path, so no need to install pkg here
run: pipx run nox -s "tests-${{ matrix.python-version }}(${{ matrix.sphinx-version }})"
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.sphinx-version }}
path: .coverage*
coverage-report:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ci-artifacts
- run: mv ci-artifacts/**/.coverage* ./
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Create coverage report
run: pipx run nox -s coverage
- name: Upload comprehensive coverage HTML report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
- name: Post coverage summary
run: cat .coverage_.md >> $GITHUB_STEP_SUMMARY
compare-wheels:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download Linux package
uses: actions/download-artifact@v4
with:
name: python-packages-Linux
path: dist-Linux
- name: Download macOS package
uses: actions/download-artifact@v4
with:
name: python-packages-macOS
path: dist-macOS
- name: Download Windows package
uses: actions/download-artifact@v4
with:
name: python-packages-Windows
path: dist-Windows
- name: Unzip wheels
run: |
for os in Linux Windows macOS; do
unzip -d pkg-$os dist-$os/*.whl
done
- name: Compare macOS wheel to Linux wheel
run: diff -ur --color=always pkg-Linux pkg-macOS
- name: Compare Windows wheel to Linux wheel
run: diff -ur --color=always pkg-Windows pkg-Windows
python-publish-package:
# Only publish package on push to tag or default branch.
if: ${{ github.event_name == 'push' && github.repository == 'jbms/sphinx-immaterial' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
needs: [build, test]
steps:
- uses: actions/download-artifact@v4
with:
name: python-packages-Linux
path: dist
- name: Publish to PyPI (test server)
uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
continue-on-error: true
with:
user: __token__
password: ${{ secrets.pypi_test_token }}
repository_url: https://test.pypi.org/legacy/
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
- name: Publish to PyPI (main server)
uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
with:
user: __token__
password: ${{ secrets.pypi_token }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}