Repository navigation
392 lines (367 loc) · 17.1 KB
/
Copy path_nightly_image_build.yaml
File metadata and controls
392 lines (367 loc) · 17.1 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is a part of the vllm-ascend project.
#
# Build the nightly test image on top of the runtime image produced from the
# root Dockerfiles. All dependency versions come from those Dockerfiles; this
# workflow does not select versions.
#
# The generated matrix pins each architecture to a fixed self-hosted runner so
# the local build cache on those runners keeps being reused by later builds.
#
# Every nightly image is multi-arch (amd64+arm64). Ubuntu nightly images serve
# the CI contract (test workflows pull from base_image/ascend-ci/vllm-ascend)
# and are also pushed to atlas_inference/vllm-ascend; openEuler nightly images
# are pushed to atlas_inference/vllm-ascend only. Everything under
# atlas_inference/vllm-ascend on swr.cn-north-12 is mirrored to swr.cn-north-4
# by the sync-tools workflow.
#
# Multi-arch ('full') builds follow the mainline nightly tag rule and publish
# each image under two tags: the stable
# nightly-ci-<branch>-<target>[-openeuler] tag, which is overwritten by every
# nightly and is what the test workflows reference, and a unique
# nightly-ci-...-cann<cann_version>-<date>-r<run_number> tag that preserves
# each historical build. The CANN version is read from the root Dockerfile of
# the branch that produced the runtime base image.
name: 'Nightly image build'
on:
workflow_call:
inputs:
target:
required: true
type: string
description: "Build target: 'a2', 'a3', '310p' or 'a5'"
vllm_ascend_branch:
required: false
type: string
default: 'main'
description: "Branch/ref to checkout"
base_image_branch:
required: false
type: string
default: ''
description: "Branch used to resolve the base image (nightly-<branch>). Defaults to vllm_ascend_branch. For PR verification builds, set to the target branch instead of the head SHA."
build_type:
required: false
type: string
default: 'release'
description: "Matrix shape only (dependency versions always come from the Dockerfiles): 'full' builds both OS variants on amd64+arm64; 'release' builds ubuntu on arm64 only."
swr_registry:
required: false
type: string
default: 'swr.cn-north-12.myhuaweicloud.com'
description: 'SWR registry domain'
should_push:
required: false
type: boolean
default: false
description: "If true, login to SWR and push built images. Set to false for PR verification builds."
cann_swr_url:
required: false
type: string
default: 'swr.cn-north-12.myhuaweicloud.com/base_image/ascend-ci/cann'
description: "CANN base image URL (SWR registry) for the job container"
cann_image_version:
required: false
type: string
default: '9.1.0'
description: "CANN version for the job container image tag only"
soc:
required: false
type: string
default: '910b'
description: "Ascend SoC type for the job container image tag (e.g. 910b, a3, 310p, 950)"
os_filter:
required: false
type: string
default: 'all'
description: "Build a single OS variant: 'ubuntu', 'openeuler', or 'all'. Lets ubuntu and openeuler pipelines run independently."
secrets:
SWR_USERNAME:
required: false
SWR_PASSWORD:
required: false
SYNC_TOOLS_TOKEN:
required: false
jobs:
generate-matrix:
runs-on: linux-amd64-cpu-2-hk
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
tag_suffix_ubuntu: ${{ steps.set-tag.outputs.tag_suffix_ubuntu }}
tag_suffix_openeuler: ${{ steps.set-tag.outputs.tag_suffix_openeuler }}
steps:
# The unique nightly tag follows the mainline format and needs the CANN
# version of the runtime base image, which is read from the root
# Dockerfile of the branch that produced it.
- uses: actions/checkout@v7
with:
fetch-depth: 1
ref: ${{ inputs.base_image_branch || inputs.vllm_ascend_branch }}
- id: set-matrix
run: |
if [ "${{ inputs.build_type }}" = "full" ]; then
ALL='{"include":[{"arch_name":"amd64","arch_runner":"linux-amd64-cpu-4","arch_platform":"linux/amd64","os":"ubuntu"},{"arch_name":"amd64","arch_runner":"linux-amd64-cpu-4","arch_platform":"linux/amd64","os":"openeuler"},{"arch_name":"arm64","arch_runner":"linux-aarch64-cpu-4","arch_platform":"linux/arm64","os":"ubuntu"},{"arch_name":"arm64","arch_runner":"linux-aarch64-cpu-4","arch_platform":"linux/arm64","os":"openeuler"}]}'
else
ALL='{"include":[{"arch_name":"arm64","arch_runner":"linux-aarch64-cpu-4","arch_platform":"linux/arm64","os":"ubuntu"}]}'
fi
OS="${{ inputs.os_filter }}"
if [ -z "$OS" ] || [ "$OS" = "all" ]; then
MATRIX="$ALL"
else
MATRIX=$(echo "$ALL" | jq -c --arg os "$OS" '{include:[.include[]|select(.os==$os)]}')
fi
# Guard against an empty matrix (e.g. os_filter='openeuler' with build_type
# 'release', where release only builds ubuntu, or an unsupported os_filter).
# An empty `include` yields a matrix with no jobs, so fail loudly instead.
COUNT=$(echo "$MATRIX" | jq '.include | length')
if [ "$COUNT" = "0" ]; then
echo "::error::No build matrix for os_filter='${{ inputs.os_filter }}' with build_type='${{ inputs.build_type }}'"
exit 1
fi
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
- id: set-tag
run: |
# Full builds are published under the stable tag plus a unique history
# tag whose suffix follows the mainline nightly rule:
# -cann<cann_version>-<build_date>-r<run_number>
# The suffix is computed once here and reused by the build and merge
# jobs. Release builds only keep the stable tag.
if [ "${{ inputs.build_type }}" != "full" ]; then
echo "tag_suffix_ubuntu=" >> "$GITHUB_OUTPUT"
echo "tag_suffix_openeuler=" >> "$GITHUB_OUTPUT"
exit 0
fi
case "${{ inputs.target }}" in
a2) UBUNTU_DOCKERFILE=Dockerfile; OPENEULER_DOCKERFILE=Dockerfile.openEuler ;;
a3) UBUNTU_DOCKERFILE=Dockerfile.a3; OPENEULER_DOCKERFILE=Dockerfile.a3.openEuler ;;
a5) UBUNTU_DOCKERFILE=Dockerfile.a5; OPENEULER_DOCKERFILE=Dockerfile.a5.openEuler ;;
310p) UBUNTU_DOCKERFILE=Dockerfile.310p; OPENEULER_DOCKERFILE=Dockerfile.310p.openEuler ;;
*)
echo "::error::Unsupported target '${{ inputs.target }}'"
exit 1
;;
esac
read_cann_version() {
sed -n 's|^FROM .*cann:\([^-]*\)-.*|\1|p' "$1" | head -n 1 | tr '[:upper:]' '[:lower:]'
}
DATE=$(date -u +%Y%m%d)
for OS_NAME in ubuntu openeuler; do
if [ "$OS_NAME" = "ubuntu" ]; then
DOCKERFILE="$UBUNTU_DOCKERFILE"
else
DOCKERFILE="$OPENEULER_DOCKERFILE"
fi
CANN_VERSION=$(read_cann_version "$DOCKERFILE")
if [ -z "$CANN_VERSION" ]; then
echo "::error::Could not read the CANN version from ${DOCKERFILE}"
exit 1
fi
echo "tag_suffix_${OS_NAME}=-cann${CANN_VERSION}-${DATE}-r${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
done
build:
needs: generate-matrix
name: Build nightly-${{ inputs.target }}-${{ matrix.os }}-${{ matrix.arch_name }}
runs-on: ${{ matrix.arch_runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
container:
image: ${{ format('{0}:{1}-{2}-ubuntu22.04-py3.12', inputs.cann_swr_url, inputs.cann_image_version, inputs.soc) }}
env:
SOC: ${{ inputs.soc }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ inputs.vllm_ascend_branch }}
- name: Login to SWR
id: login-swr
if: ${{ inputs.should_push }}
uses: docker/login-action@v4
with:
registry: ${{ inputs.swr_registry }}
username: ${{ secrets.SWR_USERNAME }}
password: ${{ secrets.SWR_PASSWORD }}
- name: Build nightly-${{ inputs.target }} image
id: build
shell: bash
run: |
BRANCH_TAG="${{ inputs.vllm_ascend_branch }}"
BRANCH_TAG=$(echo "$BRANCH_TAG" | tr '/' '-')
BASE_BRANCH_TAG="${{ inputs.base_image_branch }}"
if [ -z "$BASE_BRANCH_TAG" ]; then
BASE_BRANCH_TAG="${{ inputs.vllm_ascend_branch }}"
fi
BASE_BRANCH_TAG=$(echo "$BASE_BRANCH_TAG" | tr '/' '-')
# Runtime images are published by the runtime build workflow as
# nightly-<branch>[-<target>][-openeuler] from the root Dockerfiles.
BASE_IMAGE="${{ inputs.swr_registry }}/ascend/vllm-ascend"
OS_MARK=""
if [ "${{ matrix.os }}" = "openeuler" ]; then
OS_MARK="-openeuler"
fi
# Runtime image tags are stable now that dependency versions are pinned
# in the Dockerfiles, so no CANN/date suffix is appended.
TAG_SUFFIX=""
FULL_TAG="nightly-ci-${BRANCH_TAG}-${{ inputs.target }}${OS_MARK}"
# Same dual-tag rule as the mainline nightly builds: the stable tag is
# overwritten by each nightly, while a unique tag (CANN version +
# build date + run number) keeps the history of nightly images.
if [ "${{ matrix.os }}" = "openeuler" ]; then
UNIQUE_SUFFIX="${{ needs.generate-matrix.outputs.tag_suffix_openeuler }}"
else
UNIQUE_SUFFIX="${{ needs.generate-matrix.outputs.tag_suffix_ubuntu }}"
fi
UNIQUE_TAG="${FULL_TAG}${UNIQUE_SUFFIX}"
if [ "${{ inputs.build_type }}" = "full" ]; then
# Arch-specific images are pushed to the temp repo under the unique
# tag; the merge job creates the final multi-arch manifests. Ubuntu
# full builds are published to the CI repo and to atlas_inference
# (mirrored to swr.cn-north-4); openEuler only to atlas_inference.
if [ -n "$OS_MARK" ]; then
FINAL_IMAGE="${{ inputs.swr_registry }}/atlas_inference/vllm-ascend:${FULL_TAG}"
else
FINAL_IMAGE="${{ inputs.swr_registry }}/base_image/ascend-ci/vllm-ascend:${FULL_TAG}, ${{ inputs.swr_registry }}/atlas_inference/vllm-ascend:${FULL_TAG}"
fi
PUSH_IMAGE="${{ inputs.swr_registry }}/atlas_ci/vllm-atlas-temp:${UNIQUE_TAG}-${{ matrix.arch_name }}"
else
FINAL_IMAGE="${{ inputs.swr_registry }}/base_image/ascend-ci/vllm-ascend:${FULL_TAG}"
PUSH_IMAGE="${FINAL_IMAGE}"
fi
BUILD_ARGS=(
--platform ${{ matrix.arch_platform }}
-f .github/workflows/dockerfiles/Dockerfile.nightly.${{ inputs.target }}
--build-arg VLLM_ASCEND_BRANCH="${BASE_BRANCH_TAG}"
--build-arg BASE_IMAGE="${BASE_IMAGE}"
--build-arg OS_MARK="${OS_MARK}"
--build-arg TAG_SUFFIX="${TAG_SUFFIX}"
)
if [ "${{ inputs.should_push }}" = "true" ]; then
docker buildx build "${BUILD_ARGS[@]}" --provenance=false --sbom=false --output "type=image,name=${PUSH_IMAGE},oci-mediatypes=false,push=true" .
else
docker buildx build "${BUILD_ARGS[@]}" --provenance=false --sbom=false --output "type=image,name=${PUSH_IMAGE},oci-mediatypes=false" .
fi
{
echo "image=${FINAL_IMAGE}"
echo "full_tag=${FULL_TAG}"
echo "unique_tag=${UNIQUE_TAG}"
} >> "$GITHUB_OUTPUT"
- name: Log image push status
if: ${{ inputs.should_push && github.repository_owner == 'vllm-project' && steps.login-swr.conclusion == 'success' }}
run: |
echo "nightly test image pushed: ${{ steps.build.outputs.image }}"
merge-image:
name: Merge multi-arch nightly-${{ inputs.target }}
runs-on: linux-amd64-cpu-4
needs: [generate-matrix, build]
# Run even if some matrix instances failed. Each OS variant is merged
# independently, only when BOTH arch images exist.
if: ${{ inputs.should_push && always() && inputs.build_type == 'full' }}
steps:
- name: Login to SWR
uses: docker/login-action@v4
with:
registry: ${{ inputs.swr_registry }}
username: ${{ secrets.SWR_USERNAME }}
password: ${{ secrets.SWR_PASSWORD }}
- name: Create multi-arch manifest
id: merge
env:
SWR_REGISTRY: ${{ inputs.swr_registry }}
TARGET: ${{ inputs.target }}
VLLM_ASCEND_BRANCH: ${{ inputs.vllm_ascend_branch }}
OS_FILTER: ${{ inputs.os_filter }}
TAG_SUFFIX_UBUNTU: ${{ needs.generate-matrix.outputs.tag_suffix_ubuntu }}
TAG_SUFFIX_OPENEULER: ${{ needs.generate-matrix.outputs.tag_suffix_openeuler }}
run: |
set -euo pipefail
BRANCH_TAG="${VLLM_ASCEND_BRANCH//\//-}"
# Restrict to the requested OS variant so ubuntu and openeuler
# pipelines merge independently of each other.
case "$OS_FILTER" in
ubuntu) OS_LIST="ubuntu" ;;
openeuler) OS_LIST="openeuler" ;;
*) OS_LIST="ubuntu openeuler" ;;
esac
MISSING_VARIANT=0
MERGED_VARIANT=0
for OS_NAME in $OS_LIST; do
if [ "$OS_NAME" = "openeuler" ]; then
OS_MARK="-openeuler"
TAG_SUFFIX="${TAG_SUFFIX_OPENEULER}"
# openEuler nightly images only live in the release-shaped repo
# that the sync-tools workflow mirrors to swr.cn-north-4.
DESTS="${SWR_REGISTRY}/atlas_inference/vllm-ascend"
else
OS_MARK=""
TAG_SUFFIX="${TAG_SUFFIX_UBUNTU}"
# ubuntu nightly images serve the CI contract (test workflows
# pull from ascend-ci) and the north-4 consumers through the
# atlas_inference mirror, matching the retired daily pipeline.
DESTS="${SWR_REGISTRY}/base_image/ascend-ci/vllm-ascend ${SWR_REGISTRY}/atlas_inference/vllm-ascend"
fi
TAG="nightly-ci-${BRANCH_TAG}-${TARGET}${OS_MARK}"
# The build step pushed the per-arch images under the unique tag.
UNIQUE_TAG="${TAG}${TAG_SUFFIX}"
TEMP="${SWR_REGISTRY}/atlas_ci/vllm-atlas-temp:${UNIQUE_TAG}"
# A variant merges only when BOTH arch images exist.
MISSING_ARCH=0
for ARCH in amd64 arm64; do
if ! docker buildx imagetools inspect "${TEMP}-${ARCH}" >/dev/null 2>&1; then
echo "::warning::Skipping ${UNIQUE_TAG}: missing ${TEMP}-${ARCH}"
MISSING_ARCH=1
break
fi
done
if [ "$MISSING_ARCH" = "1" ]; then
MISSING_VARIANT=1
continue
fi
# Publish both tags on the same manifest in every destination: the
# stable tag keeps being overwritten by the newest nightly, the
# unique tag preserves this build in history.
for DEST in $DESTS; do
echo "Creating multi-arch manifests: ${DEST}:${TAG} and ${DEST}:${UNIQUE_TAG}"
docker buildx imagetools create \
-t "${DEST}:${TAG}" \
-t "${DEST}:${UNIQUE_TAG}" \
"${TEMP}-amd64" \
"${TEMP}-arm64"
done
MERGED_VARIANT=1
done
# No variant merged at all -> fail loudly so the job is not silently green.
if [ "${MERGED_VARIANT}" = "0" ]; then
echo "::error::No variant could be merged; all arch images are missing."
exit 1
fi
# At least one variant merged, others skipped -> surface a warning.
if [ "${MISSING_VARIANT}" = "1" ]; then
echo "::warning::Some variants were skipped due to missing arch images."
fi
echo "merged=${MERGED_VARIANT}" >> "$GITHUB_OUTPUT"
- name: Dispatch cn-north-4 sync
if: ${{ steps.merge.outputs.merged == '1' && github.repository == 'vllm-project/vllm-ascend' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.SYNC_TOOLS_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'ascend-gha-runners',
repo: 'sync-tools',
workflow_id: 'sync-vllm-ascend.yml',
ref: 'main',
});