-
Notifications
You must be signed in to change notification settings - Fork 255
269 lines (238 loc) · 9.44 KB
/
build-docs.yml
File metadata and controls
269 lines (238 loc) · 9.44 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
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
261
262
263
264
265
266
267
268
269
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: "CI: Build and update docs"
on:
workflow_call:
inputs:
build-ctk-ver:
type: string
required: true
component:
description: "Component(s) to build docs for"
required: false
default: "all"
type: string
# below are the acceptable options:
# - cuda-core
# - cuda-bindings
# - cuda-python
# - cuda-pathfinder
# - all
git-tag:
description: "Target git tag to build docs for"
required: false
default: ""
type: string
run-id:
description: "The GHA run ID that generated validated artifacts"
required: false
default: ${{ github.run_id }}
type: string
is-release:
description: "Are we building release docs?"
required: false
default: false
type: boolean
jobs:
build:
name: Build docs
# The build stage could fail but we want the CI to keep moving.
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: validate build-ctk
run: |
if [ ! "${{ inputs.build-ctk-ver }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]; then
echo "error: `build-ctk-ver` ${{ inputs.build-ctk-ver }} version does not match MAJOR.MINOR.MICRO" >&2
exit 1
fi
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ inputs.git-tag }}
# TODO: This workflow runs on GH-hosted runner and cannot use the proxy cache
- name: Set up miniforge
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
activate-environment: cuda-python-docs
environment-file: ./cuda_python/docs/environment-docs.yml
miniforge-version: latest
conda-remove-defaults: "true"
python-version: 3.12
- name: Check conda env
run: |
conda info
conda list
conda config --show-sources
conda config --show
# WAR: Building the doc currently requires CTK installed (NVIDIA/cuda-python#326,327)
- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
with:
host-platform: linux-64
cuda-version: ${{ inputs.build-ctk-ver }}
- name: Set environment variables
run: |
PYTHON_VERSION_FORMATTED="312" # see above
REPO_DIR=$(pwd)
if [[ ${{ inputs.is-release }} == "true" ]]; then
FILE_HASH="*"
COMMIT_HASH="${{ inputs.git-tag }}"
else
FILE_HASH="${{ github.sha }}"
COMMIT_HASH="${{ github.sha }}"
fi
# make outputs from the previous job as env vars
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64"
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${FILE_HASH}" >> $GITHUB_ENV
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build-ctk-ver }}-linux-64"
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${FILE_HASH}" >> $GITHUB_ENV
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
- name: Download cuda-python build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: cuda-python-wheel
path: .
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}
- name: Display structure of downloaded cuda-python artifacts
run: |
pwd
ls -lahR .
- name: Download cuda-pathfinder build artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: cuda-pathfinder-wheel
path: ./cuda_pathfinder
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}
- name: Display structure of downloaded cuda-pathfinder artifacts
run: |
pwd
ls -lahR cuda_pathfinder
- name: Download cuda.bindings build artifacts
if: ${{ !inputs.is-release }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
- name: Download cuda.bindings build artifacts
if: ${{ inputs.is-release }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
pattern: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
merge-multiple: true
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}
- name: Display structure of downloaded cuda.bindings artifacts
run: |
pwd
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
- name: Download cuda.core build artifacts
if: ${{ !inputs.is-release }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
- name: Download cuda.core build artifacts
if: ${{ inputs.is-release }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
pattern: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
merge-multiple: true
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
run-id: ${{ inputs.run-id }}
github-token: ${{ github.token }}
- name: Display structure of downloaded cuda.core build artifacts
run: |
pwd
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
- name: Install all packages
run: |
pushd cuda_pathfinder
pip install *.whl
popd
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
pip install *.whl
popd
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
pip install *.whl
popd
pip install cuda_python*.whl
# This step sets the PR_NUMBER/BUILD_LATEST/BUILD_PREVIEW env vars.
- name: Get PR number
if: ${{ !inputs.is-release }}
uses: ./.github/actions/get_pr_number
- name: Set up artifact directories
run: |
mkdir -p artifacts/docs
# create an empty folder for removal use
mkdir -p artifacts/empty_docs
- name: Build all docs
if: ${{ inputs.component == 'all' }}
run: |
pushd cuda_python/docs/
if [[ "${{ inputs.is-release }}" == "false" ]]; then
./build_all_docs.sh latest-only
else
./build_all_docs.sh
# At release time, we don't want to update the latest docs
rm -rf build/html/latest
fi
ls -l build
popd
mv cuda_python/docs/build/html/* artifacts/docs/
- name: Build component docs
if: ${{ inputs.component != 'all' }}
run: |
COMPONENT=$(echo "${{ inputs.component }}" | tr '-' '_')
pushd ${COMPONENT}/docs/
if [[ "${{ inputs.is-release }}" == "false" ]]; then
./build_docs.sh latest-only
else
./build_docs.sh
# At release time, we don't want to update the latest docs
rm -rf build/html/latest
fi
ls -l build
popd
if [[ "${{ inputs.component }}" != "cuda-python" ]]; then
TARGET="${{ inputs.component }}"
mkdir -p artifacts/docs/${TARGET}
else
TARGET=""
fi
mv ${COMPONENT}/docs/build/html/* artifacts/docs/${TARGET}
# TODO: Consider removing this step?
- name: Upload doc artifacts
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
with:
path: artifacts/
retention-days: 3
- name: Deploy or clean up doc preview
if: ${{ !inputs.is-release }}
uses: ./.github/actions/doc_preview
with:
source-folder: ${{ (github.ref_name != 'main' && 'artifacts/docs') ||
'artifacts/empty_docs' }}
pr-number: ${{ env.PR_NUMBER }}
- name: Deploy doc update
if: ${{ github.ref_name == 'main' || inputs.is-release }}
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
with:
git-config-name: cuda-python-bot
git-config-email: cuda-python-bot@users.noreply.github.com
folder: artifacts/docs/
target-folder: docs/
commit-message: "Deploy ${{ (inputs.is-release && 'release') || 'latest' }} docs: ${{ env.COMMIT_HASH }}"
clean: false