Repository navigation
190 lines (167 loc) · 7.06 KB
/
Copy pathdocs.yml
File metadata and controls
190 lines (167 loc) · 7.06 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
name: Docs
on:
workflow_call:
workflow_dispatch:
pull_request:
paths:
- "docs/**"
- ".github/workflows/docs.yml"
- ".readthedocs.yaml"
- "README.md"
- "pyproject.toml"
- "nampy/**"
push:
# Do not add a paths filter here: release tags must always validate docs.
branches:
- main
tags:
- "v*"
concurrency:
group: docs-${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
execute-notebooks:
name: Execute teaching notebooks
runs-on: ubuntu-latest
env:
OPENBLAS_NUM_THREADS: "1"
OMP_NUM_THREADS: "1"
MPLCONFIGDIR: /tmp/nampy-matplotlib
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install CPU package and notebook dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -c .github/constraints-ci.txt -r .github/requirements-ci-cpu-torch.txt
python -m pip install -c .github/constraints-ci.txt -e ".[docs]"
- name: Execute from clean kernels
run: |
python docs/scripts/execute_notebooks.py
- uses: actions/upload-artifact@v4
with:
name: executed-documentation-notebooks
path: |
docs/notebooks/*.ipynb
build-docs:
needs: execute-notebooks
name: Build docs (Sphinx)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- name: Install system dependencies
run: >-
sudo apt-get update && sudo apt-get install -y --no-install-recommends
pandoc libcairo2 librsvg2-bin latexmk texlive-luatex texlive-latex-extra
texlive-science texlive-fonts-recommended fonts-freefont-otf xindy
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install package and documentation dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -c .github/constraints-ci.txt -r .github/requirements-ci-cpu-torch.txt
python -m pip install -c .github/constraints-ci.txt -e ".[docs]"
# upload-artifact@v4 roots this artifact at docs/notebooks, so the
# notebooks are stored without that directory. Download them back
# there; path: docs would unpack a second copy at the docs root.
- uses: actions/download-artifact@v4
with:
name: executed-documentation-notebooks
path: docs/notebooks
- name: Check short examples and explanation contracts
env:
OPENBLAS_NUM_THREADS: "1"
OMP_NUM_THREADS: "1"
run: |
python -m pip install pytest
python docs/scripts/check_short_examples.py
python -m pytest -q tests/docs tests/neural/test_documented_component_contracts.py tests/neural/test_explanation_tables.py tests/public_api/test_gamlss_estimator.py tests/neural/test_igann_reference.py::test_registered_igann_native_binary_and_generic_multiclass_classification
- name: Execute flagship documentation examples
env:
OPENBLAS_NUM_THREADS: "1"
OMP_NUM_THREADS: "1"
MPLBACKEND: "Agg"
MPLCONFIGDIR: /tmp/nampy-matplotlib
run: |
python docs/scripts/generate_first_gam_assets.py
python docs/_scripts/generate_landing_gam_results.py
python docs/_scripts/generate_landing_nam_results.py
python docs/scripts/generate_detailed_assets.py
python docs/scripts/generate_practical_assets.py
- name: Build Sphinx documentation
run: python -m sphinx -E -a -b html docs docs/_build/html -W --keep-going
- name: Build EPUB and compile PDF
run: |
python -m sphinx -b epub -d docs/_build/ebook-doctrees docs docs/_build/epub -W --keep-going
python -m sphinx -M latexpdf docs docs/_build/pdf -d docs/_build/ebook-doctrees -W --keep-going
python docs/scripts/build_reference_manual.py --output docs/_build/reference-manual
- name: Upload PDF manual
uses: actions/upload-artifact@v4
with:
name: docs-pdf
path: |
docs/_build/pdf/latex/NAMpy.pdf
docs/_build/reference-manual/NAMpy-reference.pdf
if-no-files-found: error
retention-days: 90
compression-level: 0
- name: Publish the current PDF and EPUB
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ github.token }}
run: |
pdf=docs/_build/pdf/latex/NAMpy.pdf
reference=docs/_build/reference-manual/NAMpy-reference.pdf
epub=$(find docs/_build/epub -maxdepth 1 -name '*.epub' -print -quit)
test -f "$pdf"
test -f "$reference"
test -n "$epub"
manual=$(mktemp -d)
cp "$pdf" "$manual/NAMpy.pdf"
cp "$reference" "$manual/NAMpy-reference.pdf"
cp "$epub" "$manual/NAMpy.epub"
if gh release view docs-latest >/dev/null 2>&1; then
gh release upload docs-latest --clobber "$manual/NAMpy.pdf" "$manual/NAMpy-reference.pdf" "$manual/NAMpy.epub"
else
gh release create docs-latest \
--title "Current documentation" \
--notes "PDF and EPUB for the documentation on main. Replaced when that documentation is published." \
--target "$GITHUB_SHA" \
--latest=false \
"$manual/NAMpy.pdf" "$manual/NAMpy-reference.pdf" "$manual/NAMpy.epub"
fi
- name: Check published visual content and source provenance
run: python -m pytest -q tests/docs/test_learning_assets.py tests/docs/test_tutorial_downloads.py
- name: Check links, redirects, navigation, and notebook records
run: python docs/scripts/check_documentation.py
- name: Check sidebar navigation in Chromium
run: |
python -m pip install playwright
python -m playwright install --with-deps chromium
python docs/scripts/check_sidebar_navigation.py
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: docs-html
path: docs/_build/html/
# Publishing is performed by the Read the Docs webhook, as in DeepTab.
- name: Report latest documentation publication
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: echo "Docs passed CI. Read the Docs will publish the latest version."
- name: Report versioned documentation publication
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: echo "Docs passed CI for ${GITHUB_REF_NAME}. Read the Docs will publish the tag when tag builds are enabled."