@@ -2,13 +2,134 @@ name: Build
22
33on :
44 push :
5+ branches :
6+ - main
57 pull_request :
8+ branches :
9+ - main
610 workflow_dispatch :
711 schedule :
812 - cron : ' 0 0 1,16 * *'
913
1014jobs :
15+ check_conventions :
16+ runs-on : ubuntu-latest
17+ strategy :
18+ fail-fast : false
19+ matrix :
20+ nox-sessions :
21+ - ' black check_yaml check_json check_toml check_eof check_trailing_space check_lf'
22+ python-version : ['3.x']
23+ node-version : ['16.x']
24+ include :
25+ - nox-sessions : ' mypy pylint'
26+ python-version : ' 3.8'
27+ - nox-sessions : ' mypy pylint'
28+ python-version : ' 3.9'
29+ - nox-sessions : ' mypy pylint'
30+ python-version : ' 3.10'
31+ - nox-sessions : ' mypy pylint'
32+ python-version : ' 3.11'
33+ steps :
34+ - uses : actions/checkout@v3
35+ - name : Setup Node.js
36+ if : contains(matrix, 'node-version')
37+ uses : actions/setup-node@v3
38+ with :
39+ node-version : ${{ matrix.node-version }}
40+ - name : Setup Python ${{ matrix.python-version }}
41+ uses : actions/setup-python@v4
42+ id : python-setup
43+ with :
44+ python-version : ${{ matrix.python-version }}
45+ - name : Cache node.js modules
46+ if : contains(matrix, 'node-version')
47+ uses : actions/cache@v3
48+ with :
49+ path : " **/node_modules"
50+ key : ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
51+ - name : Cache nox environments
52+ if : contains(matrix, 'node-version')
53+ uses : actions/cache@v3
54+ with :
55+ path : |
56+ .nox/black
57+ .nox/check_*
58+ key : nox-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('requirements/dev-black.txt', 'requirements/dev-pre_commit_hooks.txt') }}
59+ - run : npm install
60+ if : contains(matrix, 'node-version')
61+ - run : npm run check
62+ if : contains(matrix, 'node-version')
63+ - run : pipx run nox -s ${{ matrix.nox-sessions }}
64+
1165 build :
66+ needs : [check_conventions]
67+ strategy :
68+ fail-fast : false
69+ matrix :
70+ os :
71+ - ' ubuntu-latest'
72+ - ' windows-latest'
73+ - ' macos-latest'
74+ python-version :
75+ - ' 3.x'
76+ node-version :
77+ - ' 16.x'
78+ runs-on : ${{ matrix.os }}
79+ steps :
80+ - uses : actions/checkout@v3
81+ with :
82+ # Need full history to determine version number.
83+ fetch-depth : 0
84+ - name : Use Node.js ${{ matrix.node-version }}
85+ uses : actions/setup-node@v3
86+ with :
87+ node-version : ${{ matrix.node-version }}
88+ - name : Set up Python ${{ matrix.python-version }}
89+ uses : actions/setup-python@v4
90+ with :
91+ python-version : ${{ matrix.python-version }}
92+ - name : Cache node.js modules
93+ uses : actions/cache@v3
94+ with :
95+ path : " **/node_modules"
96+ key : ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
97+ - run : npm install
98+ - name : Check for dirty working directory
99+ run : git diff --exit-code
100+ - run : python -m pip install nox
101+ - name : Build distributions
102+ id : dist
103+ run : nox -s dist
104+ - name : Install wheel
105+ run : python -m pip install "${{ steps.dist.outputs.wheel }}"
106+ - name : Upload wheels as artifacts
107+ uses : actions/upload-artifact@v3
108+ with :
109+ name : python-packages-${{ runner.os }}
110+ path : |
111+ dist/*.whl
112+ dist/*.tar.*
113+ - name : Setup Graphviz
114+ uses : ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9 # v1.2.0
115+ with :
116+ macos-skip-brew-update : ' true'
117+ - name : Build docs
118+ run : nox -s docs
119+ - name : Upload doc builds as artifacts
120+ uses : actions/upload-artifact@v3
121+ with :
122+ name : doc-builds-${{ runner.os }}
123+ path : docs/_build/
124+ - name : upload docs to github pages
125+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && runner.os == 'Linux'
126+ uses : peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 # pinned to v3.9.0
127+ with :
128+ github_token : ${{ secrets.GITHUB_TOKEN }}
129+ publish_dir : ./docs/_build/html
130+
131+ test :
132+ needs : [check_conventions]
12133 strategy :
13134 fail-fast : false
14135 matrix :
@@ -21,131 +142,119 @@ jobs:
21142 - ' 3.9'
22143 - ' 3.10'
23144 - ' 3.11'
145+ sphinx-version :
146+ - ' sphinx4'
147+ - ' sphinx5'
148+ - ' sphinx6'
24149 node-version :
25150 - ' 16.x'
26151 runs-on : ${{ matrix.os }}
27152 steps :
28- - uses : actions/checkout@v3
29- with :
30- # Need full history to determine version number.
31- fetch-depth : 0
32- - name : Use Node.js ${{ matrix.node-version }}
33- uses : actions/setup-node@v3
34- with :
35- node-version : ${{ matrix.node-version }}
36- - name : Set up Python ${{ matrix.python-version }}
37- uses : actions/setup-python@v4
38- with :
39- python-version : ${{ matrix.python-version }}
40- - uses : actions/cache@v3
41- with :
42- path : " **/node_modules"
43- key : ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
44- - name : Setup Graphviz
45- uses : ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9 # v1.2.0
46- with :
47- macos-skip-brew-update : ' true'
48- - run : npm install
49- - run : npm run check
50- - name : Install Python packaging, linting, & testing tools
51- run : python -m pip install -r dev-requirements.txt -r requirements.txt -r tests/requirements.txt
52- - run : mypy
53- - run : pylint sphinx_immaterial/
54- - run : black . --color --diff --check
55- - name : Check for dirty working directory
56- run : git diff --exit-code
57- - name : Show package version
58- run : python setup.py --version
59- - name : Build wheel
60- run : python setup.py sdist bdist_wheel
61- - name : Upload wheels as artifacts
62- uses : actions/upload-artifact@v3
63- if : ${{ matrix.python-version == '3.10' }}
64- with :
65- name : python-packages-${{ runner.os }}
66- path : |
67- dist/*.whl
68- dist/*.tar.*
69- - name : Install wheel and docs' dependencies
70- run : pip install dist/*.whl -r docs/requirements.txt
71- shell : bash
72- - name : Run Python tests
73- run : pytest
74- - name : Build html docs
75- working-directory : docs
76- run : sphinx-build . _build/html -W --keep-going -T
77- - name : Build dirhtml docs
78- working-directory : docs
79- run : sphinx-build . _build/dirhtml -W --keep-going -T -b dirhtml
80- - name : Build latex docs
81- working-directory : docs
82- run : sphinx-build -b latex . _build/latex -W --keep-going -T
83- - name : Upload doc builds as artifacts
84- if : ${{ matrix.python-version == '3.10' }}
85- uses : actions/upload-artifact@v3
86- with :
87- name : doc-builds-${{ runner.os }}
88- path : docs/_build/
89- - name : upload docs to github pages
90- # if: ${{ github.event_name == 'release'}}
91- if : ${{ matrix.python-version == '3.10' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && runner.os == 'Linux' }}
92- uses : peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 # pinned to v3.9.0
93- with :
94- github_token : ${{ secrets.GITHUB_TOKEN }}
95- publish_dir : ./docs/_build/html
153+ - uses : actions/checkout@v3
154+ - uses : actions/setup-node@v3
155+ with :
156+ node-version : ${{ matrix.node-version }}
157+ - name : Setup python
158+ uses : actions/setup-python@v4
159+ with :
160+ python-version : ${{ matrix.python-version }}
161+ - name : Cache node.js modules
162+ uses : actions/cache@v3
163+ with :
164+ path : " **/node_modules"
165+ key : ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
166+ - run : npm install
167+ - name : Build CSS and JS bundles
168+ run : npm run build
169+ - name : Setup Graphviz
170+ uses : ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9 # v1.2.0
171+ with :
172+ macos-skip-brew-update : ' true'
173+ - name : Run Python tests
174+ env :
175+ COVERAGE_FILE : .coverage.${{ github.run_id }}.${{ github.run_attempt }}.${{ runner.os }}.${{ matrix.python-version }}.${{ matrix.sphinx-version }}
176+ # `coverage run` cmd adds the working dir to python path, so no need to install pkg here
177+ run : pipx run nox -s "tests-${{ matrix.python-version }}(${{ matrix.sphinx-version }})"
178+ - name : Upload coverage data
179+ uses : actions/upload-artifact@v3
180+ with :
181+ name : coverage-data-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.sphinx-version }}
182+ path : .coverage*
183+
184+ coverage-report :
185+ needs : [test]
186+ runs-on : ubuntu-latest
187+ steps :
188+ - uses : actions/checkout@v3
189+ - name : Download all artifacts
190+ uses : actions/download-artifact@v3
191+ with :
192+ path : ci-artifacts
193+ - run : mv ci-artifacts/**/.coverage* ./
194+ - name : Setup python
195+ uses : actions/setup-python@v4
196+ with :
197+ python-version : ' 3.x'
198+ - name : Create coverage report
199+ run : pipx run nox -s coverage
200+ - name : Upload comprehensive coverage HTML report
201+ uses : actions/upload-artifact@v3
202+ with :
203+ name : coverage-report
204+ path : htmlcov/
205+ - name : Post coverage summary
206+ run : cat .coverage_.md >> $GITHUB_STEP_SUMMARY
96207
97208 compare-wheels :
98209 runs-on : ubuntu-latest
99- needs :
100- - build
210+ needs : [build]
101211 steps :
102- - name : Download Linux package
103- uses : actions/download-artifact@v3
104- with :
105- name : python-packages-Linux
106- path : dist-Linux
107- - name : Download macOS package
108- uses : actions/download-artifact@v3
109- with :
110- name : python-packages-macOS
111- path : dist-macOS
112- - name : Download Windows package
113- uses : actions/download-artifact@v3
114- with :
115- name : python-packages-Windows
116- path : dist-Windows
117- - name : Unzip wheels
118- run : |
119- for os in Linux Windows macOS; do
120- unzip -d pkg-$os dist-$os/*.whl
121- done
122- - name : Compare macOS wheel to Linux wheel
123- run : diff -ur --color=always pkg-Linux pkg-macOS
124- - name : Compare Windows wheel to Linux wheel
125- run : diff -ur --color=always pkg-Windows pkg-Windows
212+ - name : Download Linux package
213+ uses : actions/download-artifact@v3
214+ with :
215+ name : python-packages-Linux
216+ path : dist-Linux
217+ - name : Download macOS package
218+ uses : actions/download-artifact@v3
219+ with :
220+ name : python-packages-macOS
221+ path : dist-macOS
222+ - name : Download Windows package
223+ uses : actions/download-artifact@v3
224+ with :
225+ name : python-packages-Windows
226+ path : dist-Windows
227+ - name : Unzip wheels
228+ run : |
229+ for os in Linux Windows macOS; do
230+ unzip -d pkg-$os dist-$os/*.whl
231+ done
232+ - name : Compare macOS wheel to Linux wheel
233+ run : diff -ur --color=always pkg-Linux pkg-macOS
234+ - name : Compare Windows wheel to Linux wheel
235+ run : diff -ur --color=always pkg-Windows pkg-Windows
126236
127237 python-publish-package :
128238 # Only publish package on push to tag or default branch.
129239 if : ${{ github.event_name == 'push' && github.repository == 'jbms/sphinx-immaterial' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') }}
130240 runs-on : ubuntu-latest
131- needs :
132- - build
241+ needs : [build, test]
133242 steps :
134- - uses : actions/download-artifact@v3
135- with :
136- name : python-packages-Linux
137- path : dist
138- - name : Publish to PyPI (test server)
139- uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
140- continue-on-error : true
141- with :
142- user : __token__
143- password : ${{ secrets.pypi_test_token }}
144- repository_url : https://test.pypi.org/legacy/
145- if : ${{ ! startsWith(github.ref, 'refs/tags/v') }}
146- - name : Publish to PyPI (main server)
147- uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
148- with :
149- user : __token__
150- password : ${{ secrets.pypi_token }}
151- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
243+ - uses : actions/download-artifact@v3
244+ with :
245+ name : python-packages-Linux
246+ path : dist
247+ - name : Publish to PyPI (test server)
248+ uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
249+ continue-on-error : true
250+ with :
251+ user : __token__
252+ password : ${{ secrets.pypi_test_token }}
253+ repository_url : https://test.pypi.org/legacy/
254+ if : ${{ ! startsWith(github.ref, 'refs/tags/v') }}
255+ - name : Publish to PyPI (main server)
256+ uses : pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
257+ with :
258+ user : __token__
259+ password : ${{ secrets.pypi_token }}
260+ if : ${{ startsWith(github.ref, 'refs/tags/v') }}
0 commit comments