Skip to content

Commit 00d8b24

Browse files
authored
Enable docs preview upload for nightly builds (#3718)
Add doc preview uploads for nightly builds to preview HTML for nightly/RC doc versions. * Added configurable S3_PREFIX input parameter to _build-tutorials-base.yml (defaults to pytorch/tutorials) * Updated build-tutorials-nightly.yml to enable uploads (`UPLOAD: 1`) with custom path `pytorch/tutorials-nightly-preview`
1 parent a3695df commit 00d8b24

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/_build-tutorials-base.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
required: false
1414
type: number
1515
default: 0
16+
S3_PREFIX:
17+
description: "S3 prefix path for uploading docs preview"
18+
required: false
19+
type: string
20+
default: "pytorch/tutorials"
1621

1722
jobs:
1823
worker:
@@ -187,7 +192,7 @@ jobs:
187192
s3-bucket: doc-previews
188193
if-no-files-found: error
189194
path: docs
190-
s3-prefix: pytorch/tutorials/${{ github.event.pull_request.number }}
195+
s3-prefix: ${{ inputs.S3_PREFIX }}/${{ github.event.pull_request.number }}
191196

192197
- name: Teardown Linux
193198
uses: pytorch/test-infra/.github/actions/teardown-linux@main

.github/workflows/build-tutorials-nightly.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ jobs:
3232
secrets: inherit
3333
with:
3434
USE_NIGHTLY: 1
35-
UPLOAD: 0
35+
UPLOAD: 1
36+
S3_PREFIX: pytorch/tutorials-nightly-preview

.jenkins/build.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ set -ex
44

55
export BUCKET_NAME=pytorch-tutorial-build-pull-request
66

7+
# Set build prefix based on whether this is a nightly build or not
8+
# This prevents conflicts when both builds run simultaneously
9+
if [ "${USE_NIGHTLY:-0}" -eq 1 ]; then
10+
export BUILD_PREFIX="nightly"
11+
else
12+
export BUILD_PREFIX="stable"
13+
fi
14+
715
# set locale for click dependency in spacy
816
export LC_ALL=C.UTF-8
917
export LANG=C.UTF-8
@@ -122,7 +130,7 @@ if [[ "${JOB_TYPE}" == "worker" ]]; then
122130
# Step 6: Copy generated files to S3, tag with commit ID
123131
if [ "${UPLOAD:-0}" -eq 1 ]; then
124132
7z a worker_${WORKER_ID}.7z docs
125-
awsv2 s3 cp worker_${WORKER_ID}.7z s3://${BUCKET_NAME}/${COMMIT_ID}/worker_${WORKER_ID}.7z
133+
awsv2 s3 cp worker_${WORKER_ID}.7z s3://${BUCKET_NAME}/${BUILD_PREFIX}/${COMMIT_ID}/worker_${WORKER_ID}.7z
126134
fi
127135
elif [[ "${JOB_TYPE}" == "manager" ]]; then
128136
# Step 1: Generate no-plot HTML pages for all tutorials
@@ -136,7 +144,7 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then
136144
# Step 3: Download generated with-plot HTML files and static files from S3, merge into one folder
137145
mkdir -p docs_with_plot/docs
138146
for ((worker_id=1;worker_id<NUM_WORKERS+1;worker_id++)); do
139-
awsv2 s3 cp s3://${BUCKET_NAME}/${COMMIT_ID}/worker_$worker_id.7z worker_$worker_id.7z
147+
awsv2 s3 cp s3://${BUCKET_NAME}/${BUILD_PREFIX}/${COMMIT_ID}/worker_$worker_id.7z worker_$worker_id.7z
140148
7z x worker_$worker_id.7z -oworker_$worker_id
141149
yes | cp -R worker_$worker_id/docs/* docs_with_plot/docs
142150
done
@@ -153,7 +161,7 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then
153161

154162
# Step 6: Copy generated HTML files and static files to S3
155163
7z a manager.7z docs
156-
awsv2 s3 cp manager.7z s3://${BUCKET_NAME}/${COMMIT_ID}/manager.7z
164+
awsv2 s3 cp manager.7z s3://${BUCKET_NAME}/${BUILD_PREFIX}/${COMMIT_ID}/manager.7z
157165

158166
# Step 7: push new HTML files and static files to gh-pages
159167
if [[ "$COMMIT_SOURCE" == "refs/heads/master" || "$COMMIT_SOURCE" == "refs/heads/main" ]]; then

0 commit comments

Comments
 (0)