1+ #
2+ # Copyright (c) 2026 Huawei Technologies Co., Ltd. All Rights Reserved.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ # This file is a part of the vllm-ascend project.
16+ #
17+
18+ name : ' Validate: Docker Actions on Self-Hosted'
19+
20+ on :
21+ workflow_dispatch :
22+
23+ defaults :
24+ run :
25+ shell : bash -el {0}
26+
27+ concurrency :
28+ group : ${{ github.workflow }}-${{ github.ref }}
29+ cancel-in-progress : true
30+
31+ jobs :
32+ validate-docker-build :
33+ name : validate-docker-on-${{ matrix.runner }}
34+ runs-on : ${{ matrix.runner }}
35+ strategy :
36+ fail-fast : false
37+ matrix :
38+ runner :
39+ - linux-amd64-cpu-8-hk
40+ - linux-arm64-cpu-16
41+
42+ steps :
43+ - name : Checkout repo
44+ uses : actions/checkout@v7
45+
46+ - name : Print runner info
47+ run : |
48+ echo "Runner: ${{ matrix.runner }}"
49+ echo "Arch: $(uname -m)"
50+ echo "Docker version: $(docker --version || echo 'docker not found')"
51+ echo "Buildx available: $(docker buildx version || echo 'buildx not found')"
52+
53+ - name : Docker meta
54+ id : meta
55+ uses : docker/metadata-action@v6
56+ with :
57+ images : |
58+ ghcr.io/${{ github.repository_owner }}/validate-docker-test
59+ tags : |
60+ type=raw,value=self-hosted-${{ matrix.runner }}
61+ flavor :
62+ latest=false
63+ labels : |
64+ self-hosted=true
65+ validation=true
66+
67+ - name : Verify metadata
68+ run : |
69+ echo "Tags: ${{ steps.meta.outputs.tags }}"
70+ echo "Labels: ${{ steps.meta.outputs.labels }}"
71+ echo "JSON: ${{ steps.meta.outputs.json }}"
72+ test -n "${{ steps.meta.outputs.tags }}" && echo "metadata OK" || echo "metadata FAILED"
73+
74+ - name : Set up QEMU (cross-arch)
75+ uses : docker/setup-qemu-action@v4
76+ if : runner.arch == 'X64'
77+
78+ - name : Set up Docker Buildx
79+ uses : docker/setup-buildx-action@v4
80+ with :
81+ install : true
82+ driver : docker-container
83+ use : true
84+
85+ - name : Verify Buildx
86+ run : |
87+ docker buildx inspect --bootstrap
88+ docker buildx ls
89+ echo "buildx setup OK"
90+
91+ - name : Login to GitHub Container Registry
92+ uses : docker/login-action@v4
93+ with :
94+ registry : ghcr.io
95+ username : ${{ github.actor }}
96+ password : ${{ secrets.GITHUB_TOKEN }}
97+
98+ - name : Create test Dockerfile
99+ run : |
100+ cat > /tmp/Dockerfile.validate << 'DOCKERFILE'
101+ FROM alpine:3.20
102+ RUN echo "Docker build validation on self-hosted runner" > /validate.txt
103+ CMD ["cat", "/validate.txt"]
104+ DOCKERFILE
105+ echo "Test Dockerfile created at /tmp/Dockerfile.validate"
106+
107+ - name : Build and push test image
108+ uses : docker/build-push-action@v7
109+ with :
110+ platforms : ${{ matrix.runner == 'linux-arm64-cpu-16' && 'linux/arm64' || 'linux/amd64' }}
111+ context : /tmp
112+ file : /tmp/Dockerfile.validate
113+ push : true
114+ tags : ${{ steps.meta.outputs.tags }}
115+ labels : ${{ steps.meta.outputs.labels }}
116+ provenance : false
117+ cache-from : type=gha
118+ cache-to : type=gha,mode=max
119+
120+ - name : Verify pushed image
121+ run : |
122+ echo "Image pushed to: ${{ steps.meta.outputs.tags }}"
123+ echo "Docker build and push completed successfully"
124+
125+ - name : Pull and test image
126+ run : |
127+ TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -1)
128+ echo "Pulling: $TAG"
129+ docker pull "$TAG"
130+ docker run --rm "$TAG"
131+ echo "Image pull and run OK"
132+
133+ - name : Cleanup GHCR test image
134+ if : always()
135+ uses : actions/github-script@v9
136+ with :
137+ script : |
138+ const owner = context.repo.owner;
139+ const packageName = 'validate-docker-test';
140+ const url = `https://api.github.com/orgs/${owner}/packages/container/${packageName}/versions`;
141+ console.log(`Listing versions for ${owner}/${packageName}`);
142+ try {
143+ const response = await github.request(`GET ${url}`, {
144+ headers: {
145+ Accept: 'application/vnd.github+json',
146+ },
147+ });
148+ console.log(`Found ${response.data.length} version(s)`);
149+ } catch (e) {
150+ console.log(`Could not list versions: ${e.message}`);
151+ }
0 commit comments