-
Notifications
You must be signed in to change notification settings - Fork 2
199 lines (191 loc) · 8.32 KB
/
pack.yaml
File metadata and controls
199 lines (191 loc) · 8.32 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
# This workflow packs the Docker images for the Benchmark Runner.
name: Pack
permissions:
actions: read
contents: write
pull-requests: write
defaults:
run:
shell: bash
on:
workflow_dispatch: {}
push:
branches:
- "main"
- "v*-dev"
tags:
- "v*.*.*"
paths-ignore:
- "mkdocs.yml"
- "docs/**"
- "**.md"
- "**.mdx"
- "**.png"
- "**.jpg"
- "**.gif"
pull_request:
branches:
- "main"
- "v*-dev"
paths:
- ".github/workflows/pack.yaml"
- "Dockerfile"
env:
INPUT_PYTHON_VERSION: 3.11
INPUT_USERNAME: ${{ secrets.CI_DOCKERHUB_USERNAME || 'gpustack' }}
INPUT_PASSWORD: ${{ secrets.CI_DOCKERHUB_PASSWORD }}
INPUT_NAMESPACE: ${{ secrets.CI_DOCKERHUB_NAMESPACE || 'gpustack' }}
INPUT_REPOSITORY: benchmark-runner
jobs:
pack:
runs-on: ubuntu-22.04
timeout-minutes: 360
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
persist-credentials: false
- name: Maximize Docker Build Space
uses: gpustack/.github/.github/actions/maximize-docker-build-space@main
with:
deep-clean: true
root-reserve-mb: 20480
- name: Setup BuildX Cache
id: setup-buildx-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.cache
key: cache-mount-${{ hashFiles('uv.lock') }}
- name: Restore BuildX Cache
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-dir: ${{ github.workspace }}/.cache
dockerfile: ${{ github.workspace }}/Dockerfile
skip-extraction: ${{ steps.setup-buildx-cache.outputs.cache-hit }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v9.2.2
platforms: "arm64"
- name: Setup BuildX
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
- name: Login DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ env.INPUT_USERNAME }}
password: ${{ env.INPUT_PASSWORD }}
- name: Get Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: "${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}"
tags: |
type=ref,event=pr
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,prefix=dev-,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=branch,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }}
type=sha,prefix={{branch}}-,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }}
type=pep440,pattern={{raw}}
type=pep440,pattern=v{{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }}
flavor: |
latest=false
- name: Get Cache Ref
run: |
#
# Use different cache ref for different branches.
#
# Examples:
# CACHE_FROM_REF
# - vX.Y.Z -> "gpustack/build-cache:benchmark-runner-${VERSION|DEFAULT_BRANCH}"
# - PR/PUSH to branch -> "gpustack/build-cache:benchmark-runner-${BRANCH|DEFUALT_BRANCH}"
# CACHE_TO_REF
# - vX.Y.Z -> "gpustack/build-cache:benchmark-runner-${VERSION}"
# - PUSH to branch -> "gpustack/build-cache:benchmark-runner-${BRANCH}"
#
# Stories:
# CACHE_FROM_REF
# - Release tag v0.7.0rc1 -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main
# - Release tag v0.7.0 -> gpustack/build-cache:benchmark-runner-v0.7
# - PR to "main" branch -> gpustack/build-cache:benchmark-runner-main
# - PR to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main
# - Push to "main" branch -> gpustack/build-cache:benchmark-runner-main
# - Push to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main
# CACHE_TO_REF
# - Release tag v0.7.0rc1 -> gpustack/build-cache:benchmark-runner-v0.7
# - Release tag v0.7.0 -> gpustack/build-cache:benchmark-runner-v0.7
# - PR to "main" branch -> gpustack/build-cache:benchmark-runner-main
# - PR to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7
# - Push to "main" branch -> gpustack/build-cache:benchmark-runner-main
# - Push to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7
#
DEFAULT_BRANCH="main"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
REF="${GITHUB_REF#refs/tags/}"
IFS="." read -r VERSION_MAJOR VERSION_MINOR VERSION_PATCH <<< "${REF}"
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${VERSION}"
CACHE_TO_REF="${CACHE_FROM_REF}"
else
REF="${GITHUB_BASE_REF:-${GITHUB_REF}}"
BRANCH="${REF#refs/heads/}"
BRANCH="${BRANCH%-dev}"
CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${BRANCH}"
CACHE_TO_REF="${CACHE_FROM_REF}"
fi
if ! docker manifest inspect "${CACHE_FROM_REF}" >/dev/null 2>&1; then
CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${DEFAULT_BRANCH}"
fi
echo "CACHE_FROM_REF=${CACHE_FROM_REF}" >> $GITHUB_ENV
echo "CACHE_TO_REF=${CACHE_TO_REF}" >> $GITHUB_ENV
echo "DEBUG: GITHUB_BASE_REF=${GITHUB_BASE_REF}"
echo "DEBUG: GITHUB_REF=${GITHUB_REF}"
echo "DEBUG: CACHE_FROM_REF=${CACHE_FROM_REF}"
echo "DEBUG: CACHE_TO_REF=${CACHE_TO_REF}"
- name: Get Image Labels
run: |
#!/usr/bin/env bash
set -eo pipefail
LABELS=(
"org.opencontainers.image.source=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.source'] }}"
"org.opencontainers.image.version=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.version'] }}"
"org.opencontainers.image.revision=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.revision'] }}"
"org.opencontainers.image.created=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.created'] }}"
)
INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=$(printf "%s;" "${LABELS[@]}")
echo "INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=${INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS}" >> $GITHUB_ENV
- name: Package
uses: docker/build-push-action@v6
with:
allow: |
network.host
security.insecure
ulimit: |
nofile=65536:65536
shm-size: 16G
provenance: true
sbom: true
push: ${{ github.event_name != 'pull_request' }}
file: ${{ github.workspace }}/Dockerfile
context: ${{ github.workspace }}
platforms: "linux/amd64,linux/arm64"
build-args: |
PYTHON_VERSION=${{ env.INPUT_PYTHON_VERSION }}
GPUSTACK_RUNTIME_DOCKER_MIRRORED_NAME_FILTER_LABELS=${{ env.INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS }}
tags: |
${{ steps.metadata.outputs.tags }}
labels: |
${{ steps.metadata.outputs.labels }}
cache-from: |
type=registry,ref=${{ env.CACHE_FROM_REF }}
cache-to: |
${{ github.event_name != 'pull_request' && format('type=registry,mode=max,compression=gzip,ref={0},ignore-error=true', env.CACHE_TO_REF) || '' }}