Skip to content

Commit db22412

Browse files
committed
add a doc build workflow
1 parent 4135a2f commit db22412

File tree

6 files changed

+262
-116
lines changed

6 files changed

+262
-116
lines changed

.github/workflows/gh-build-and-test.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192
runner: H100
193193
name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }})
194194
# The build stage could fail but we want the CI to keep moving.
195-
if: ${{ (github.repository_owner == 'nvidia') && always() }}
195+
if: ${{ github.repository_owner == 'nvidia' && always() }}
196196
permissions:
197197
id-token: write # This is required for configure-aws-credentials
198198
contents: read # This is required for actions/checkout
@@ -209,7 +209,7 @@ jobs:
209209
needs:
210210
- build
211211
steps:
212-
- name: Run nvidia-smi to make sure GPU is working
212+
- name: Ensure GPU is working
213213
shell: bash --noprofile --norc -xeuo pipefail {0}
214214
run: nvidia-smi
215215

@@ -322,3 +322,15 @@ jobs:
322322
# pip install "cupy-cuda${TEST_CUDA_MAJOR}x"
323323
pytest -rxXs tests/
324324
popd
325+
326+
doc:
327+
permissions:
328+
id-token: write # This is required for configure-aws-credentials
329+
contents: read # This is required for actions/checkout
330+
needs:
331+
- build
332+
secrets: inherit
333+
uses:
334+
.github/workflows/gh-build-docs.yml
335+
with:
336+
build_ctk_ver: ${{ needs.build.outputs.BUILD_CTK_VER }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
- build_ctk_ver:
5+
type: string
6+
required: true
7+
8+
jobs:
9+
doc:
10+
name: Build & publish docs
11+
# The build stage could fail but we want the CI to keep moving.
12+
if: ${{ github.repository_owner == 'nvidia' && always() }}
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash -el {0}
17+
steps:
18+
- name: Checkout ${{ github.event.repository.name }}
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up miniforge
24+
uses: conda-incubator/setup-miniconda@v3
25+
with:
26+
activate-environment: cuda-python-docs
27+
environment-file: ./cuda_python/docs/environment-docs.yml
28+
miniforge-version: latest
29+
conda-remove-defaults: "true"
30+
python-version: 3.12
31+
32+
- name: Set environment variables
33+
run: |
34+
PYTHON_VERSION_FORMATTED="312" # see above
35+
REPO_DIR=$(pwd)
36+
37+
# make outputs from the previous job as env vars
38+
echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64-${{ github.sha }}" >> $GITHUB_ENV
39+
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
40+
echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64-${{ github.sha }}" >> $GITHUB_ENV
41+
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
42+
43+
- name: Download cuda.bindings build artifacts
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
47+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
48+
49+
- name: Display structure of downloaded cuda.bindings artifacts
50+
run: |
51+
pwd
52+
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
53+
54+
- name: Download cuda.core build artifacts
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
58+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
59+
60+
- name: Display structure of downloaded cuda.core build artifacts
61+
run: |
62+
pwd
63+
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
64+
65+
- name: Install all packages
66+
run: |
67+
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
68+
pip install *.whl
69+
popd
70+
71+
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
72+
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]
73+
popd
74+
75+
- name: Build all docs
76+
run: |
77+
cd cuda_python/docs/
78+
./build_all_docs.sh latest-only
79+
ls -l build

cuda_bindings/docs/build_docs.sh

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,50 @@
22

33
set -ex
44

5-
# SPHINX_CUDA_BINDINGS_VER is used to create a subdir under build/html
6-
# (the Makefile file for sphinx-build also honors it if defined).
7-
# If there's a post release (ex: .post1) we don't want it to show up in the
8-
# version selector or directory structure.
9-
if [[ -z "${SPHINX_CUDA_BINDINGS_VER}" ]]; then
10-
export SPHINX_CUDA_BINDINGS_VER=$(python -c "from importlib.metadata import version; \
11-
ver = '.'.join(str(version('cuda-python')).split('.')[:3]); \
12-
print(ver)" \
13-
| awk -F'+' '{print $1}')
14-
fi
15-
16-
# build the docs (in parallel)
17-
SPHINXOPTS="-j 4" make html
18-
19-
# for debugging/developing (conf.py), please comment out the above line and
20-
# use the line below instead, as we must build in serial to avoid getting
21-
# obsecure Sphinx errors
22-
#SPHINXOPTS="-v" make html
23-
24-
# to support version dropdown menu
25-
cp ./versions.json build/html
26-
27-
# to have a redirection page (to the latest docs)
28-
cp source/_templates/main.html build/html/index.html
29-
30-
# ensure that the latest docs is the one we built
31-
cp -r build/html/${SPHINX_CUDA_BINDINGS_VER} build/html/latest
32-
33-
# ensure that the Sphinx reference uses the latest docs
34-
cp build/html/latest/objects.inv build/html
5+
build_docs() {
6+
if [[ "$#" == "0" ]]; then
7+
LATEST_ONLY="1"
8+
elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then
9+
LATEST_ONLY="0"
10+
else
11+
echo "usage: ./build_docs.sh [latest-only]"
12+
exit 1
13+
fi
14+
15+
# SPHINX_CUDA_BINDINGS_VER is used to create a subdir under build/html
16+
# (the Makefile file for sphinx-build also honors it if defined).
17+
# If there's a post release (ex: .post1) we don't want it to show up in the
18+
# version selector or directory structure.
19+
if [[ -z "${SPHINX_CUDA_BINDINGS_VER}" ]]; then
20+
export SPHINX_CUDA_BINDINGS_VER=$(python -c "from importlib.metadata import version; \
21+
ver = '.'.join(str(version('cuda-python')).split('.')[:3]); \
22+
print(ver)" \
23+
| awk -F'+' '{print $1}')
24+
fi
25+
26+
# build the docs (in parallel)
27+
SPHINXOPTS="-j 4" make html
28+
29+
# for debugging/developing (conf.py), please comment out the above line and
30+
# use the line below instead, as we must build in serial to avoid getting
31+
# obsecure Sphinx errors
32+
#SPHINXOPTS="-v" make html
33+
34+
# to support version dropdown menu
35+
cp ./versions.json build/html
36+
37+
# to have a redirection page (to the latest docs)
38+
cp source/_templates/main.html build/html/index.html
39+
40+
# ensure that the latest docs is the one we built
41+
if [[ $LATEST_ONLY == "0" ]]; then
42+
cp -r build/html/${SPHINX_CUDA_BINDINGS_VER} build/html/latest
43+
else
44+
mv build/html/${SPHINX_CUDA_BINDINGS_VER} build/html/latest
45+
fi
46+
47+
# ensure that the Sphinx reference uses the latest docs
48+
cp build/html/latest/objects.inv build/html
49+
}
50+
51+
build_docs $@

cuda_core/docs/build_docs.sh

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,49 @@
22

33
set -ex
44

5-
# SPHINX_CUDA_CORE_VER is used to create a subdir under build/html
6-
# (the Makefile file for sphinx-build also honors it if defined)
7-
if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then
8-
export SPHINX_CUDA_CORE_VER=$(python -c "from importlib.metadata import version; print(version('cuda-core'))" \
9-
| awk -F'+' '{print $1}')
10-
fi
11-
12-
# build the docs (in parallel)
13-
SPHINXOPTS="-j 4" make html
14-
15-
# for debugging/developing (conf.py), please comment out the above line and
16-
# use the line below instead, as we must build in serial to avoid getting
17-
# obsecure Sphinx errors
18-
#SPHINXOPTS="-v" make html
19-
20-
# to support version dropdown menu
21-
cp ./versions.json build/html
22-
23-
# to have a redirection page (to the latest docs)
24-
cp source/_templates/main.html build/html/index.html
25-
26-
# ensure that the latest docs is the one we built
27-
cp -r build/html/${SPHINX_CUDA_CORE_VER} build/html/latest
28-
29-
# ensure that the Sphinx reference uses the latest docs
30-
cp build/html/latest/objects.inv build/html
31-
32-
# clean up previously auto-generated files
33-
rm -rf source/generated/
5+
build_docs() {
6+
if [[ "$#" == "0" ]]; then
7+
LATEST_ONLY="1"
8+
elif [[ "$#" == "1" && "$1" == "latest-only" ]]; then
9+
LATEST_ONLY="0"
10+
else
11+
echo "usage: ./build_docs.sh [latest-only]"
12+
exit 1
13+
fi
14+
15+
# SPHINX_CUDA_CORE_VER is used to create a subdir under build/html
16+
# (the Makefile file for sphinx-build also honors it if defined)
17+
if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then
18+
export SPHINX_CUDA_CORE_VER=$(python -c "from importlib.metadata import version; print(version('cuda-core'))" \
19+
| awk -F'+' '{print $1}')
20+
fi
21+
22+
# build the docs (in parallel)
23+
SPHINXOPTS="-j 4" make html
24+
25+
# for debugging/developing (conf.py), please comment out the above line and
26+
# use the line below instead, as we must build in serial to avoid getting
27+
# obsecure Sphinx errors
28+
#SPHINXOPTS="-v" make html
29+
30+
# to support version dropdown menu
31+
cp ./versions.json build/html
32+
33+
# to have a redirection page (to the latest docs)
34+
cp source/_templates/main.html build/html/index.html
35+
36+
# ensure that the latest docs is the one we built
37+
if [[ $LATEST_ONLY == "0" ]]; then
38+
cp -r build/html/${SPHINX_CUDA_CORE_VER} build/html/latest
39+
else
40+
mv build/html/${SPHINX_CUDA_CORE_VER} build/html/latest
41+
fi
42+
43+
# ensure that the Sphinx reference uses the latest docs
44+
cp build/html/latest/objects.inv build/html
45+
46+
# clean up previously auto-generated files
47+
rm -rf source/generated/
48+
}
49+
50+
build_docs $@

cuda_python/docs/build_all_docs.sh

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@
22

33
set -ex
44

5-
# build cuda-python docs
6-
rm -rf build
7-
./build_docs.sh
5+
build_all_docs() {
6+
# build cuda-python docs
7+
rm -rf build
8+
./build_docs.sh $@
9+
10+
# build cuda-bindings docs
11+
CUDA_BINDINGS_PATH=build/html/cuda-bindings
12+
mkdir -p $CUDA_BINDINGS_PATH
13+
pushd .
14+
cd ../../cuda_bindings/docs
15+
rm -rf build
16+
./build_docs.sh $@
17+
cp -r build/html/* "$(dirs -l +1)"/$CUDA_BINDINGS_PATH
18+
popd
19+
20+
# build cuda-core docs
21+
CUDA_CORE_PATH=build/html/cuda-core
22+
mkdir -p $CUDA_CORE_PATH
23+
pushd .
24+
cd ../../cuda_core/docs
25+
rm -rf build
26+
./build_docs.sh $@
27+
cp -r build/html/* "$(dirs -l +1)"/$CUDA_CORE_PATH
28+
popd
29+
}
830

9-
# build cuda-bindings docs
10-
CUDA_BINDINGS_PATH=build/html/cuda-bindings
11-
mkdir -p $CUDA_BINDINGS_PATH
12-
pushd .
13-
cd ../../cuda_bindings/docs
14-
rm -rf build
15-
./build_docs.sh
16-
cp -r build/html/* "$(dirs -l +1)"/$CUDA_BINDINGS_PATH
17-
popd
18-
19-
# build cuda-core docs
20-
CUDA_CORE_PATH=build/html/cuda-core
21-
mkdir -p $CUDA_CORE_PATH
22-
pushd .
23-
cd ../../cuda_core/docs
24-
rm -rf build
25-
./build_docs.sh
26-
cp -r build/html/* "$(dirs -l +1)"/$CUDA_CORE_PATH
27-
popd
31+
build_all_docs $@

0 commit comments

Comments
 (0)