Repository navigation
143 lines (132 loc) · 5.08 KB
/
Copy path_build-tutorials-base.yml
File metadata and controls
143 lines (132 loc) · 5.08 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
name: Build tutorials
on:
workflow_call:
inputs:
USE_NIGHTLY:
description: "Use nightly builds inside build.sh"
required: false
type: number
default: 0
UPLOAD:
description: "Upload built docs to PR preview and main site"
required: false
type: number
default: 0
S3_PREFIX:
description: "S3 prefix path for uploading docs preview"
required: false
type: string
default: "pytorch/tutorials"
jobs:
docker-image:
name: Resolve CI docker image
runs-on: ubuntu-latest
outputs:
docker-image: ${{ steps.tag.outputs.docker-image }}
steps:
- name: Checkout Tutorials
uses: actions/checkout@v6
# Built and pushed by docker-build.yml, which a PR changing .ci/docker gets
# through the ciflow/docker label
- name: Compute the image tag
id: tag
run: |
set -eu
DOCKER_TAG="$(git rev-parse HEAD:.ci/docker)"
echo "docker-image=308535385114.dkr.ecr.us-east-1.amazonaws.com/tutorials/tutorials:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
worker:
name: pytorch_tutorial_build_worker
needs: docker-image
uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
permissions:
id-token: write
contents: read
strategy:
matrix:
include:
- { shard: 1, num_shards: 15, runner: "mt-l-x86aavx2-45-167-a10g-4" }
- { shard: 2, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 3, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 4, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 5, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 6, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 7, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 8, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 9, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 10, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 11, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 12, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 13, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 14, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
- { shard: 15, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
fail-fast: false
with:
job-name: pytorch_tutorial_build_worker
runner: ${{ matrix.runner }}
docker-image: ${{ needs.docker-image.outputs.docker-image }}
gpu-arch-type: cuda
fetch-depth: 0
timeout: 120
script: |
set -ex
export NUM_WORKERS=${{ matrix.num_shards }}
export WORKER_ID=${{ matrix.shard }}
export COMMIT_ID=${{ github.sha }}
export JOB_TYPE=worker
export COMMIT_SOURCE=${{ github.ref }}
export USE_NIGHTLY=${{ inputs.USE_NIGHTLY }}
export UPLOAD=${{ inputs.UPLOAD }}
.jenkins/build.sh
# Not on linux_job_v3: a job calling a reusable workflow cannot set the environment
# that holds PYTORCHBOT_TOKEN, and the preview goes to a caller-chosen S3 prefix
manager:
name: pytorch_tutorial_build_manager
needs: [docker-image, worker]
runs-on: mt-l-x86iavx512-8-64
container:
image: ${{ needs.docker-image.outputs.docker-image }}
if: ${{ inputs.UPLOAD == 1 }}
environment: ${{ github.ref == 'refs/heads/main' && 'pytorchbot-env' || '' }}
permissions:
id-token: write
contents: read
timeout-minutes: 120
steps:
- name: Checkout Tutorials
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::308535385114:role/arc
aws-region: us-east-1
role-duration-seconds: 18000
- name: Build
shell: bash
env:
NUM_WORKERS: 15
WORKER_ID: 0
COMMIT_ID: ${{ github.sha }}
JOB_TYPE: manager
COMMIT_SOURCE: ${{ github.ref }}
GITHUB_PYTORCHBOT_TOKEN: ${{ secrets.PYTORCHBOT_TOKEN }}
USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }}
run: |
set -ex
.jenkins/build.sh
# The ciflow/docs/<pr> tag still names the pull request, so the preview
# keeps the per-PR prefix. An expression cannot split a ref, hence the step.
- name: Resolve the preview prefix
id: preview
if: ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }}
run: echo "prefix=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}"
- name: Upload docs preview
uses: seemethere/upload-artifact-s3@v5
if: ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }}
with:
retention-days: 14
s3-bucket: doc-previews
if-no-files-found: error
path: docs
s3-prefix: ${{ inputs.S3_PREFIX }}/${{ steps.preview.outputs.prefix }}