Skip to content

Commit 401501b

Browse files
Merge pull request #223 from bertiniteam/ci/factor-out-docs-workflow
Ci/factor out docs workflow
2 parents 158d468 + ebc4301 commit 401501b

3 files changed

Lines changed: 190 additions & 104 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,38 @@ on:
44
push:
55
branches:
66
- '**'
7+
paths-ignore:
8+
- 'python/docs/**'
9+
- 'doc_resources/**'
10+
- 'Doxyfile'
11+
- '**/*.md'
12+
- '.github/workflows/build_docs.yml'
713
pull_request:
14+
paths-ignore:
15+
- 'python/docs/**'
16+
- 'doc_resources/**'
17+
- 'Doxyfile'
18+
- '**/*.md'
19+
- '.github/workflows/build_docs.yml'
820
workflow_call:
21+
inputs:
22+
minimal:
23+
description: 'Build only the ubuntu-latest / python-3.11 wheel; skip C++ tests, Windows, macOS, and wheel tests.'
24+
required: false
25+
type: boolean
26+
default: false
927
workflow_dispatch:
1028
inputs:
1129
full_matrix:
1230
description: 'Run full OS and Python matrix'
1331
required: false
1432
type: boolean
1533
default: false
34+
minimal:
35+
description: 'Build only the ubuntu-latest / python-3.11 wheel; skip C++ tests, Windows, macOS, and wheel tests.'
36+
required: false
37+
type: boolean
38+
default: false
1639

1740
concurrency:
1841
group: build-${{ github.ref }}
@@ -34,7 +57,10 @@ jobs:
3457
# Mac available to the maintainer). Intel macOS support is paused
3558
# pending a reproducer or an upstream fix. Re-add "macos-15-intel"
3659
# below when ready to revisit.
37-
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" || "${{ github.ref }}" == refs/tags/* || "${{ inputs.full_matrix }}" == "true" || "${{ github.event.pull_request.base.ref }}" == "develop" || "${{ github.event.pull_request.base.ref }}" == "main" ]]; then
60+
if [[ "${{ inputs.minimal }}" == "true" ]]; then
61+
echo 'os=["ubuntu-latest"]' >> $GITHUB_OUTPUT
62+
echo 'python_versions=["3.11"]' >> $GITHUB_OUTPUT
63+
elif [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" || "${{ github.ref }}" == refs/tags/* || "${{ inputs.full_matrix }}" == "true" || "${{ github.event.pull_request.base.ref }}" == "develop" || "${{ github.event.pull_request.base.ref }}" == "main" ]]; then
3864
echo 'os=["ubuntu-latest","macos-14"]' >> $GITHUB_OUTPUT
3965
echo 'python_versions=["3.9","3.10","3.11","3.12","3.13"]' >> $GITHUB_OUTPUT
4066
else
@@ -44,6 +70,7 @@ jobs:
4470
4571
test_cpp_unix:
4672
name: C++ tests on ${{ matrix.os }}
73+
if: ${{ inputs.minimal != true }}
4774
needs: [set_matrix]
4875
runs-on: ${{ matrix.os }}
4976
strategy:
@@ -107,6 +134,7 @@ jobs:
107134

108135
test_cpp_windows:
109136
name: C++ tests on Windows
137+
if: ${{ inputs.minimal != true }}
110138
runs-on: windows-latest
111139
env:
112140
CONDA_PKGS_DIRS: ${{ github.workspace }}\conda_pkgs
@@ -275,7 +303,8 @@ jobs:
275303
if-no-files-found: error
276304

277305
build_windows_wheels:
278-
name: Windows Python-${{ matrix.python-version }} wheels
306+
name: Windows Python-${{ matrix.python-version }} wheels
307+
if: ${{ inputs.minimal != true }}
279308
runs-on: windows-latest
280309
env:
281310
CONDA_PKGS_DIRS: ${{ github.workspace }}\conda_pkgs
@@ -338,6 +367,7 @@ jobs:
338367

339368
test_wheels_linux_macos:
340369
name: Test wheels on ${{ matrix.os }} / py${{ matrix.python-version }}
370+
if: ${{ inputs.minimal != true }}
341371
needs: [set_matrix, build_macos_ubuntu_wheels]
342372
runs-on: ${{ matrix.os }}
343373
strategy:
@@ -371,6 +401,7 @@ jobs:
371401
372402
test_wheels_windows:
373403
name: Test wheel on windows-${{ matrix.python-version }}
404+
if: ${{ inputs.minimal != true }}
374405
needs: [build_windows_wheels]
375406
runs-on: windows-latest
376407
strategy:

.github/workflows/build_docs.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Build and deploy documentation 📝
2+
3+
on:
4+
workflow_call:
5+
# When called from publish.yml, the caller's build_and_test job has
6+
# already produced the wheel artifact this workflow needs. The internal
7+
# build_and_test job below is skipped in that case.
8+
inputs:
9+
deploy:
10+
description: 'Deploy to GitHub Pages after building'
11+
required: false
12+
type: boolean
13+
default: true
14+
workflow_dispatch:
15+
inputs:
16+
deploy:
17+
description: 'Deploy to GitHub Pages after building'
18+
required: false
19+
type: boolean
20+
default: true
21+
22+
concurrency:
23+
group: docs-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build_and_test:
28+
name: Build wheel (for docs)
29+
# Only run when triggered manually. workflow_call invocations assume the
30+
# caller already ran build_and_test in the same workflow run, so the
31+
# wheel artifact is already available.
32+
if: github.event_name == 'workflow_dispatch'
33+
uses: ./.github/workflows/build_and_test.yml
34+
with:
35+
# Docs only need the ubuntu-latest / python-3.11 wheel; skip the full
36+
# OS/Python matrix and the wheel/C++ test jobs.
37+
minimal: true
38+
39+
build_docs:
40+
name: Build docs
41+
needs: [build_and_test]
42+
# `build_and_test` is skipped when invoked via workflow_call; treat that
43+
# as success so build_docs runs in both modes.
44+
if: |
45+
always() &&
46+
(needs.build_and_test.result == 'success' || needs.build_and_test.result == 'skipped')
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v5
50+
with:
51+
# gitpython (used by python/docs/source/conf.py to derive version)
52+
# needs the full history; the default depth=1 leaves it unable to
53+
# resolve HEAD's commit object on some refs.
54+
fetch-depth: 0
55+
56+
- name: Set up Python
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: '3.11'
60+
61+
- name: Compute build metadata
62+
id: meta
63+
run: |
64+
SHA=$(git rev-parse HEAD)
65+
SHORT=$(git rev-parse --short HEAD)
66+
DATE=$(date -u +'%Y-%m-%d %H:%M UTC')
67+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
68+
echo "short=$SHORT" >> "$GITHUB_OUTPUT"
69+
echo "date=$DATE" >> "$GITHUB_OUTPUT"
70+
echo "Build metadata: $SHORT ($SHA) at $DATE"
71+
72+
- name: Install system dependencies (Doxygen)
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y doxygen graphviz
76+
77+
- name: Fetch doxygen-awesome-css
78+
run: |
79+
curl -sSL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v2.3.4.tar.gz | tar -xz
80+
mv doxygen-awesome-css-2.3.4 doxygen-awesome-css
81+
82+
- name: Build C++ docs (Doxygen)
83+
env:
84+
PROJECT_NUMBER: "${{ steps.meta.outputs.short }} (${{ steps.meta.outputs.date }})"
85+
run: |
86+
mkdir -p build/docs/cpp site
87+
# Append PROJECT_NUMBER override via stdin; Doxygen reads stdin
88+
# config when invoked with `-` and merges with the file.
89+
(cat Doxyfile; echo "PROJECT_NUMBER = $PROJECT_NUMBER") | doxygen -
90+
mv build/docs/cpp site/cpp
91+
92+
- name: Install Python deps for Sphinx
93+
# The bertini2 wheel bundles the eigenpy C++ libraries it links
94+
# against; no Python `eigenpy` install is required to import bertini
95+
# for sphinx autodoc.
96+
run: |
97+
python -m pip install --upgrade pip
98+
pip install \
99+
sphinx sphinx-rtd-theme sphinxcontrib-bibtex gitpython \
100+
scikit-build-core build numpy
101+
102+
- name: Download built wheel
103+
uses: actions/download-artifact@v5
104+
with:
105+
name: wheels-ubuntu-latest-3.11
106+
path: dist/
107+
108+
- name: Install bertini from built wheel
109+
run: pip install --no-index --find-links dist/ bertini2
110+
111+
- name: Build Python docs (Sphinx)
112+
working-directory: python/docs
113+
env:
114+
BERTINI_GIT_SHA: ${{ steps.meta.outputs.sha }}
115+
BERTINI_BUILD_DATE: ${{ steps.meta.outputs.date }}
116+
run: |
117+
sphinx-build -b html -W --keep-going source ../../site/python
118+
119+
- name: Add landing page
120+
env:
121+
COMMIT_SHA: ${{ steps.meta.outputs.sha }}
122+
COMMIT_SHORT: ${{ steps.meta.outputs.short }}
123+
BUILD_DATE: ${{ steps.meta.outputs.date }}
124+
run: |
125+
sed \
126+
-e "s|__COMMIT_SHA__|${COMMIT_SHA}|g" \
127+
-e "s|__COMMIT_SHORT__|${COMMIT_SHORT}|g" \
128+
-e "s|__BUILD_DATE__|${BUILD_DATE}|g" \
129+
doc_resources/landing/index.html > site/index.html
130+
cp doc_resources/landing/style.css site/style.css
131+
132+
- name: Upload Pages artifact
133+
uses: actions/upload-pages-artifact@v3
134+
with:
135+
path: site
136+
137+
deploy_docs:
138+
name: Deploy to GitHub Pages
139+
needs:
140+
- build_docs
141+
if: needs.build_docs.result == 'success' && inputs.deploy
142+
runs-on: ubuntu-latest
143+
permissions:
144+
pages: write
145+
id-token: write
146+
environment:
147+
name: github-pages
148+
url: ${{ steps.deployment.outputs.page_url }}
149+
steps:
150+
- name: Deploy
151+
id: deployment
152+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -143,109 +143,12 @@ jobs:
143143
files: |
144144
dist/*.*
145145
146-
build_docs:
147-
name: Build docs
146+
build_and_deploy_docs:
147+
name: Build and deploy docs
148148
if: needs.check_version.outputs.is_prerelease == 'false'
149149
needs: [check_version, build_and_test]
150-
runs-on: ubuntu-latest
151-
steps:
152-
- uses: actions/checkout@v5
153-
with:
154-
# gitpython (used by python/docs/source/conf.py to derive version)
155-
# needs the full history; the default depth=1 leaves it unable to
156-
# resolve HEAD's commit object on some refs.
157-
fetch-depth: 0
158-
159-
- name: Set up Python
160-
uses: actions/setup-python@v5
161-
with:
162-
python-version: '3.11'
163-
164-
- name: Compute build metadata
165-
id: meta
166-
run: |
167-
SHA=$(git rev-parse HEAD)
168-
SHORT=$(git rev-parse --short HEAD)
169-
DATE=$(date -u +'%Y-%m-%d %H:%M UTC')
170-
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
171-
echo "short=$SHORT" >> "$GITHUB_OUTPUT"
172-
echo "date=$DATE" >> "$GITHUB_OUTPUT"
173-
echo "Build metadata: $SHORT ($SHA) at $DATE"
174-
175-
- name: Install system dependencies (Doxygen)
176-
run: |
177-
sudo apt-get update
178-
sudo apt-get install -y doxygen graphviz
179-
180-
- name: Fetch doxygen-awesome-css
181-
run: |
182-
curl -sSL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v2.3.4.tar.gz | tar -xz
183-
mv doxygen-awesome-css-2.3.4 doxygen-awesome-css
184-
185-
- name: Build C++ docs (Doxygen)
186-
env:
187-
PROJECT_NUMBER: "${{ steps.meta.outputs.short }} (${{ steps.meta.outputs.date }})"
188-
run: |
189-
mkdir -p build/docs/cpp site
190-
# Append PROJECT_NUMBER override via stdin; Doxygen reads stdin
191-
# config when invoked with `-` and merges with the file.
192-
(cat Doxyfile; echo "PROJECT_NUMBER = $PROJECT_NUMBER") | doxygen -
193-
mv build/docs/cpp site/cpp
194-
195-
- name: Install Python deps for Sphinx
196-
run: |
197-
python -m pip install --upgrade pip
198-
pip install \
199-
sphinx sphinx-rtd-theme sphinxcontrib-bibtex gitpython \
200-
scikit-build-core build numpy eigenpy==3.11.0
201-
202-
- name: Download built wheel
203-
uses: actions/download-artifact@v5
204-
with:
205-
name: wheels-ubuntu-latest-3.11
206-
path: dist/
207-
208-
- name: Install bertini from built wheel
209-
run: pip install --no-index --find-links dist/ bertini2
210-
211-
- name: Build Python docs (Sphinx)
212-
working-directory: python/docs
213-
env:
214-
BERTINI_GIT_SHA: ${{ steps.meta.outputs.sha }}
215-
BERTINI_BUILD_DATE: ${{ steps.meta.outputs.date }}
216-
run: |
217-
sphinx-build -b html -W --keep-going source ../../site/python
218-
219-
- name: Add landing page
220-
env:
221-
COMMIT_SHA: ${{ steps.meta.outputs.sha }}
222-
COMMIT_SHORT: ${{ steps.meta.outputs.short }}
223-
BUILD_DATE: ${{ steps.meta.outputs.date }}
224-
run: |
225-
sed \
226-
-e "s|__COMMIT_SHA__|${COMMIT_SHA}|g" \
227-
-e "s|__COMMIT_SHORT__|${COMMIT_SHORT}|g" \
228-
-e "s|__BUILD_DATE__|${BUILD_DATE}|g" \
229-
doc_resources/landing/index.html > site/index.html
230-
cp doc_resources/landing/style.css site/style.css
231-
232-
- name: Upload Pages artifact
233-
uses: actions/upload-pages-artifact@v3
234-
with:
235-
path: site
236-
237-
deploy_docs:
238-
name: Deploy to GitHub Pages
239-
needs:
240-
- build_docs
241-
runs-on: ubuntu-latest
150+
uses: ./.github/workflows/build_docs.yml
242151
permissions:
152+
contents: read
243153
pages: write
244-
id-token: write
245-
environment:
246-
name: github-pages
247-
url: ${{ steps.deployment.outputs.page_url }}
248-
steps:
249-
- name: Deploy
250-
id: deployment
251-
uses: actions/deploy-pages@v4
154+
id-token: write

0 commit comments

Comments
 (0)