Repository navigation
220 lines (209 loc) · 8.05 KB
/
Copy path_binary-test-linux.yml
File metadata and controls
220 lines (209 loc) · 8.05 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
name: linux-binary-test
# Reusable test workflow for linux binary (manywheel/libtorch).
#
# Two execution modes selected by `use_container_directive`:
# - true (default): launch the test container via GHA's native `container:`
# directive — checkout, env-setup, and the .ci/* test scripts all run
# directly inside it. Used by x86 / aarch64 / cuda runners.
# - false: run on the bare runner and spawn the test container with
# `docker run` from a step. Used by s390x self-hosted runners, which
# register only with the bare `linux.s390x` label and lack a host-level
# docker CLI compatible with GHA's container directive.
#
# /run.sh is generated by binary_linux_test.sh; symlinks bridge the legacy
# /pytorch and /final_pkgs paths it hardcodes to the GHA-managed workspace
# and artifact dir.
on:
workflow_call:
inputs:
build_name:
required: true
type: string
build_environment:
required: true
type: string
runner_prefix:
required: false
default: ""
type: string
runs_on:
required: true
type: string
timeout-minutes:
required: false
default: 240
type: number
use_container_directive:
required: false
default: true
type: boolean
description: |
When true, use GHA's native `container:` directive. When false,
run on the bare runner and spawn the test container via
`docker run`. Set to false on runners that lack a docker CLI
compatible with the container directive (e.g. s390x).
ALPINE_IMAGE:
required: false
type: string
default: "308535385114.dkr.ecr.us-east-1.amazonaws.com/tool/alpine"
PYTORCH_ROOT:
required: true
type: string
PACKAGE_TYPE:
required: true
type: string
DESIRED_CUDA:
required: true
type: string
GPU_ARCH_VERSION:
required: false
type: string
GPU_ARCH_TYPE:
required: true
type: string
DOCKER_IMAGE:
required: true
type: string
DOCKER_IMAGE_TAG_PREFIX:
required: true
type: string
DESIRED_PYTHON:
required: false
type: string
LIBTORCH_CONFIG:
required: false
type: string
LIBTORCH_VARIANT:
required: false
type: string
secrets:
github-token:
required: true
permissions:
id-token: write
contents: read
jobs:
test:
runs-on: ${{ inputs.runner_prefix }}${{ inputs.runs_on }}
timeout-minutes: ${{ inputs.timeout-minutes }}
container:
image: ${{ inputs.use_container_directive && format('pytorch/{0}:{1}', inputs.DOCKER_IMAGE, inputs.DOCKER_IMAGE_TAG_PREFIX) || '' }}
options: ${{ inputs.use_container_directive && inputs.GPU_ARCH_TYPE == 'cuda' && '--gpus all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video' || ' ' }}
env:
PYTORCH_ROOT: ${{ github.workspace }}
PACKAGE_TYPE: ${{ inputs.PACKAGE_TYPE }}
DESIRED_CUDA: ${{ inputs.DESIRED_CUDA }}
GPU_ARCH_VERSION: ${{ inputs.GPU_ARCH_VERSION }}
GPU_ARCH_TYPE: ${{ inputs.GPU_ARCH_TYPE }}
DOCKER_IMAGE: pytorch/${{ inputs.DOCKER_IMAGE }}:${{ inputs.DOCKER_IMAGE_TAG_PREFIX }}
SKIP_ALL_TESTS: 1
LIBTORCH_CONFIG: ${{ inputs.LIBTORCH_CONFIG }}
LIBTORCH_VARIANT: ${{ inputs.LIBTORCH_VARIANT }}
DESIRED_PYTHON: ${{ inputs.DESIRED_PYTHON }}
ALPINE_IMAGE: ${{ inputs.ALPINE_IMAGE }}
AWS_DEFAULT_REGION: us-east-1
BINARY_ENV_FILE: /tmp/env
BUILD_ENVIRONMENT: ${{ inputs.build_environment }}
GITHUB_TOKEN: ${{ secrets.github-token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
steps:
- name: Configure git safe directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout PyTorch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
fetch-depth: 1
submodules: recursive
show-progress: false
- name: Make test env permanent
shell: bash
run: |
mkdir -p "$(dirname "$BINARY_ENV_FILE")"
PYTORCH_FINAL_PACKAGE_DIR="${RUNNER_TEMP}/artifacts"
{
echo "PYTORCH_ROOT=${PYTORCH_ROOT}"
echo "PACKAGE_TYPE=${PACKAGE_TYPE}"
echo "DESIRED_CUDA=${DESIRED_CUDA}"
echo "GPU_ARCH_VERSION=${GPU_ARCH_VERSION}"
echo "GPU_ARCH_TYPE=${GPU_ARCH_TYPE}"
echo "DOCKER_IMAGE=${DOCKER_IMAGE}"
echo "SKIP_ALL_TESTS=${SKIP_ALL_TESTS}"
echo "LIBTORCH_CONFIG=${LIBTORCH_CONFIG}"
echo "LIBTORCH_VARIANT=${LIBTORCH_VARIANT}"
echo "DESIRED_PYTHON=${DESIRED_PYTHON}"
echo "ALPINE_IMAGE=${ALPINE_IMAGE}"
echo "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}"
echo "BINARY_ENV_FILE=${BINARY_ENV_FILE}"
echo "BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT}"
echo "BUILD_NAME=${{ inputs.build_name }}"
echo "PR_NUMBER=${PR_NUMBER}"
echo "PYTORCH_FINAL_PACKAGE_DIR=${PYTORCH_FINAL_PACKAGE_DIR}"
echo "SHA1=${SHA1}"
} >> "${GITHUB_ENV}"
mkdir -p "$PYTORCH_FINAL_PACKAGE_DIR"
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: ${{ inputs.build_name }}
path: "${{ runner.temp }}/artifacts/"
# Container-directive path: test runs directly inside the container.
- name: Populate binary env
if: inputs.use_container_directive
shell: bash
run: bash .ci/pytorch/binary_populate_env.sh
- name: Test PyTorch binary
if: inputs.use_container_directive
shell: bash
env:
OUTPUT_SCRIPT: /run.sh
run: |
ln -sf "${GITHUB_WORKSPACE}" /pytorch
ln -sf "${PYTORCH_FINAL_PACKAGE_DIR}" /final_pkgs
bash .ci/pytorch/binary_linux_test.sh
source "${BINARY_ENV_FILE}"
bash -x /run.sh
# Bare-runner path: spawn the test container manually.
- name: Test PyTorch binary (docker run)
if: ${{ !inputs.use_container_directive }}
shell: bash
run: |
set -x
container_name=$(docker run \
-e BINARY_ENV_FILE \
-e BUILD_ENVIRONMENT \
-e DESIRED_CUDA \
-e DESIRED_PYTHON \
-e GITHUB_ACTIONS \
-e GPU_ARCH_TYPE \
-e GPU_ARCH_VERSION \
-e LIBTORCH_CONFIG \
-e LIBTORCH_VARIANT \
-e PACKAGE_TYPE \
-e PYTORCH_FINAL_PACKAGE_DIR \
-e PYTORCH_ROOT \
-e SKIP_ALL_TESTS \
--tty \
--detach \
-v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
-v "${PYTORCH_FINAL_PACKAGE_DIR}:${PYTORCH_FINAL_PACKAGE_DIR}" \
-w / \
"${DOCKER_IMAGE}"
)
docker exec -t -w "${PYTORCH_ROOT}" "${container_name}" bash -c "bash .ci/pytorch/binary_populate_env.sh"
# binary_linux_test.sh writes its test commands to OUTPUT_SCRIPT (defaults to a
# legacy CircleCI path); /pytorch and /final_pkgs are hardcoded inside the script.
docker exec -t -w "${PYTORCH_ROOT}" -e OUTPUT_SCRIPT=/run.sh "${container_name}" bash -c "
ln -sf '${GITHUB_WORKSPACE}' /pytorch
ln -sf '${PYTORCH_FINAL_PACKAGE_DIR}' /final_pkgs
bash .ci/pytorch/binary_linux_test.sh
"
docker exec -t "${container_name}" bash -c "source ${BINARY_ENV_FILE} && bash -x /run.sh"
- name: Cleanup docker
if: ${{ always() && !inputs.use_container_directive }}
shell: bash
run: |
# On bare-runner mode the container is left running by docker run --detach;
# stop it for clean worker shutdown.
# shellcheck disable=SC2046
docker stop $(docker ps -q) || true