-
Notifications
You must be signed in to change notification settings - Fork 654
179 lines (160 loc) · 5.68 KB
/
build_docs.yml
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
name: Build documentation
# Documentation is deployed in the following ways
# 1. Each time a commit is pushed to main branch
# 2. Nightly (so that docs are updated even when there is no commit to main branch on the day)
# 3. Manual trigger for release
# Because release requires changing the version number, which is used as a directory name,
# automating release doc deployment is tricky.
# There is no reliable way to know if there should have been a minor version bump.
#
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build:
# Do not use matrix here to parameterize Python/CUDA versions.
# This job is required to pass for each PR.
# The name of the required job is sensitive to matrix parameter.
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
with:
job-name: Build doc
runner: linux.g5.4xlarge.nvidia.gpu
repository: pytorch/audio
gpu-arch-type: cuda
gpu-arch-version: "11.8"
timeout: 120
upload-artifact: docs
script: |
set -ex
# Set up Environment Variables
export PYTHON_VERSION="3.10"
export CU_VERSION="11.8"
export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}"
# Set CHANNEL
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
export CHANNEL=test
export BUILD_VERSION="$( cut -f 1 -d a version.txt )"
else
export CHANNEL=nightly
export BUILD_VERSION="$( cut -f 1 -d a version.txt )".dev"$(date "+%Y%m%d")"
fi
echo "::group::Create conda env"
# Mark Build Directory Safe
git config --global --add safe.directory /__w/audio/audio
conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}"
conda activate ./ci_env
echo "::endgroup::"
echo "::group::Install PyTorch"
conda install \
--yes \
--quiet \
-c "pytorch-${CHANNEL}" \
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \
"${CUDATOOLKIT}"
echo "::endgroup::"
echo "::group::Install TorchAudio"
conda install --quiet --yes cmake>=3.18.0 ninja
pip3 install --progress-bar off -v -e . --no-use-pep517
echo "::endgroup::"
echo "::group::Build FFmpeg"
.github/scripts/ffmpeg/build_gpu.sh
echo "::endgroup::"
echo "::group::Install other dependencies"
conda install \
--quiet --yes \
-c conda-forge \
sox libvorbis pandoc doxygen pysoundfile
pip install --progress-bar off \
git+https://github.com/kpu/kenlm/ flashlight-text \
-r docs/requirements.txt -r docs/requirements-tutorials.txt
echo "::endgroup::"
echo "::group::Build documentation"
export BUILD_GALLERY=true
(cd docs && make html)
echo "::endgroup::"
echo "::group::Copy artifact"
cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}"
mv docs/build/html /artifacts/
commit-main:
if: github.ref_name == 'main'
permissions:
# Required for `git push`
# Note:
# This is not effective from fork.
# When you debug this, make sure to make a branch on pytorch and
# make PR from there.
contents: write
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
fetch-depth: 5
- uses: actions/download-artifact@v3
with:
name: docs
- name: Update main doc
run: |
set -x
git config user.name "pytorchbot"
git config user.email "[email protected]"
# When `git clone`, `gh-pages` branch is fetched by default.
# The size of gh-pages grows significantly, so we use ammend and force push
# We add a new commit once a week
if [ "$(date +%d)" = "1" ]; then
git commit --allow-empty -m "placeholder"
fi
# TODO: add tag-based process (need to handle the main directory name)
# Update the main doc
rm -rf main
mv html main
git add --all main || true
git commit --amend -m "auto-generating sphinx docs" || true
git push -f
# Push for release
# Make sure that version.txt is updated first (alpha suffix is removed)
commit-release:
if: startsWith(github.ref_name, 'release/') && ( github.event_name == 'workflow_dispatch' )
permissions:
# Required for `git push`
# Note:
# This is not effective from fork.
# When you debug this, make sure to make a branch on pytorch and
# make PR from there.
contents: write
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
fetch-depth: 5
- uses: actions/checkout@v4
with:
path: _src
- uses: actions/download-artifact@v3
with:
name: docs
- name: Update doc
run: |
set -x
git config user.name "pytorchbot"
git config user.email "[email protected]"
# When `git clone`, `gh-pages` branch is fetched by default.
# The size of gh-pages grows significantly, so we use ammend and force push
# We add a new commit once a week
if [ "$(date +%d)" = "1" ]; then
git commit --allow-empty -m "placeholder"
fi
dirname="$(cat _src/version.txt)"
rm -rf "${dirname}"
mv html "${dirname}"
git add --all "${dirname}" || true
git commit --amend -m "auto-generating sphinx docs" || true
git push -f