Repository navigation
203 lines (173 loc) · 6.37 KB
/
Copy pathdocs.yml
File metadata and controls
203 lines (173 loc) · 6.37 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
name: Docs
on:
pull_request:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: read
env:
JUSTFILE: ${{ github.workspace }}/pipeline.just
concurrency:
group: docs-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build Python API docs
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load CI versions
uses: ./.github/actions/load-ci-versions
with:
required: CI_RUST CI_PYTHON
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.CI_RUST }}
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.CI_PYTHON }}
cache: pip
cache-dependency-path: |
bindings/python/docs/requirements.txt
bindings/python/pyproject.toml
- name: Create virtual environment
run: |
python -m venv .venv
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV"
echo "PYTHON_PATH=$GITHUB_WORKSPACE/.venv/bin/python" >> "$GITHUB_ENV"
echo "PYO3_PYTHON=$GITHUB_WORKSPACE/.venv/bin/python" >> "$GITHUB_ENV"
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
- name: Install documentation dependencies
working-directory: bindings/python
run: |
"$PYTHON_PATH" -m pip install --upgrade pip
"$PYTHON_PATH" -m pip install -r docs/requirements.txt
- name: Install maturin and Python build dependencies
run: |
"$PYTHON_PATH" -m pip install -r requirements.txt
- name: Setup just
uses: extractions/setup-just@v3
- name: Build documentation
run: just --justfile "$JUSTFILE" build-python-docs
- name: Upload Python documentation
uses: actions/upload-artifact@v4
with:
name: python-docs
path: bindings/python/docs/_build
include-hidden-files: true
if-no-files-found: error
retention-days: 7
build-site:
name: Build docs site
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load CI versions
uses: ./.github/actions/load-ci-versions
with:
required: CI_PYTHON
- name: Install Doxygen and Graphviz
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends doxygen graphviz
- name: Setup wasm toolchain
uses: ./.github/actions/setup-wasm-toolchain
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.CI_PYTHON }}
- name: Create virtual environment
run: |
python -m venv .venv
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV"
echo "PYTHON_PATH=$GITHUB_WORKSPACE/.venv/bin/python" >> "$GITHUB_ENV"
echo "PYO3_PYTHON=$GITHUB_WORKSPACE/.venv/bin/python" >> "$GITHUB_ENV"
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
- name: Setup just
uses: extractions/setup-just@v3
- name: Download Python documentation
uses: actions/download-artifact@v4
with:
name: python-docs
path: bindings/python/docs/_build
- name: Build documentation site
run: just --justfile "$JUSTFILE" assemble-docs-site
# assemble-docs-site writes the complete publishable tree, so the
# artifact is the site itself: target/docs-site is the only uploaded
# path and therefore the artifact root, and the deploy job publishes
# its contents verbatim.
- name: Upload documentation site
uses: actions/upload-artifact@v4
with:
name: docs-site
path: target/docs-site
# The generated references contain dot-prefixed files, which the
# upload skips by default and the deploy would then publish without.
include-hidden-files: true
if-no-files-found: error
# Long enough to redeploy an existing artifact after a failed deploy.
retention-days: 7
deploy:
name: Deploy docs site to Cloudflare Pages
runs-on: ubuntu-22.04
# Publish only from the canonical repository's main branch; never from
# pull requests or forks (they lack the Cloudflare secrets anyway).
if: >-
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
&& github.ref == 'refs/heads/main'
&& github.repository == 'openpitkit/pit'
# build-site combines the Python artifact and the other generated references.
needs: [build-site]
permissions:
contents: read
deployments: write
steps:
# The artifact carries the whole site, so nothing from the repository
# is published here; the checkout survives only to supply the pinned
# CI versions and the action that loads them in the next step.
- name: Checkout CI versions
uses: actions/checkout@v4
with:
sparse-checkout: .github
- name: Load CI versions
uses: ./.github/actions/load-ci-versions
with:
required: CI_WRANGLER
- name: Download documentation site
uses: actions/download-artifact@v4
with:
name: docs-site
path: docs-site
- name: Check Cloudflare configuration
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
missing=0
if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then
echo "::error::CLOUDFLARE_ACCOUNT_ID secret is not configured"
missing=1
fi
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
echo "::error::CLOUDFLARE_API_TOKEN secret is not configured"
missing=1
fi
exit "$missing"
- name: Deploy docs to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: ${{ env.CI_WRANGLER }}
command: >-
pages deploy docs-site --project-name=openpit-docs