-
Notifications
You must be signed in to change notification settings - Fork 20
329 lines (303 loc) · 10.3 KB
/
docker_publish.yml
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
name: docker_publish
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- "master"
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Build the ubi-no_model without cache export
docker-ubi-no_model:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
token: ${{ secrets.CR_PAT }}
tag: ubi-no_model
- name: Build:ubi-no_model
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./ubi.Dockerfile
load: true
target: no_model
labels: ${{ steps.setup.outputs.labels }}
build-args: |
GIT_SHA=${{ github.sha }}
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
- name: Test ubi-no_model docker image
run: |
docker run --group-add 0 -v ".:/app" ${{ steps.build.outputs.imageid }} -- --model base --language en --device cpu --compute_type int8 --output_format srt .github/workflows/test/en.webm;
if [ ! -f en.srt ]; then
echo "The en.srt file does not exist"
exit 1
fi
echo "cat en.srt:";
cat en.srt;
if ! grep -qi 'no' en.srt; then
echo "The en.srt file does not contain the word 'no'"
exit 1
fi
echo "Test passed."
- name: Build and push:ubi-no_model
uses: docker/build-push-action@v5
with:
context: .
file: ./ubi.Dockerfile
push: true
target: no_model
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
GIT_SHA=${{ github.sha }}
platforms: linux/amd64, linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
# Run the no_model build first ensure that the code at least builds
docker-no_model:
# The type of runner that the job will run on
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.publish.outputs.digest }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
token: ${{ secrets.CR_PAT }}
- name: Build:no_model
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./Dockerfile
load: true
target: no_model
labels: ${{ steps.setup.outputs.labels }}
build-args: |
GIT_SHA=${{ github.sha }}
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
- name: Test no_model docker image
run: |
docker run --group-add 0 -v ".:/app" ${{ steps.build.outputs.imageid }} -- --model base --language en --device cpu --compute_type int8 --output_format srt .github/workflows/test/en.webm;
if [ ! -f en.srt ]; then
echo "The en.srt file does not exist"
exit 1
fi
echo "cat en.srt:";
cat en.srt;
if ! grep -qi 'no' en.srt; then
echo "The en.srt file does not contain the word 'no'"
exit 1
fi
echo "Test passed."
- name: Build and push:no_model
uses: docker/build-push-action@v5
id: publish
with:
context: .
file: ./Dockerfile
push: true
target: no_model
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
GIT_SHA=${{ github.sha }}
platforms: linux/amd64, linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
# Download whisper model cache
docker-cache:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
model:
- tiny
- base
- small
- medium
- large-v2
- large-v3
needs: docker-no_model # wait for docker-no_model to finish
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
token: ${{ secrets.CR_PAT }}
tag: cache-${{ matrix.model }}
- name: Build cache:${{ matrix.model }}
uses: docker/build-push-action@v5
id: build
with:
context: .
file: ./Dockerfile
push: true
target: load_whisper
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
NO_MODEL_STAGE=ghcr.io/jim60105/whisperx:no_model@${{ needs.docker-no_model.outputs.digest }}
GIT_SHA=${{ github.sha }}
platforms: linux/amd64, linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
# Run the rest of the builds in parallel
docker:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
# max-parallel: 6
matrix:
lang:
- en
- fr
- de
- es
- it
- ja
- zh
- nl
- uk
- pt
- ar
- cs
- ru
- pl
- hu
- fi
- fa
- el
- tr
- da
- he
- vi
- ko
- ur
- te
- hi
- ca
- ml
- no
- nn
model:
- tiny
- base
- small
- medium
- large-v2
- large-v3
needs:
- docker-no_model # wait for docker-no_model to finish
- docker-cache # wait for docker-cache to finish
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
token: ${{ secrets.CR_PAT }}
tag: ${{ matrix.model }}-${{ matrix.lang }}
- name: Get short SHA
id: get-sha
run: |
id=$(echo ${{ github.sha }} | cut -c 1-7)
echo "id=$id" >> $GITHUB_OUTPUT
- name: Build and push:${{ matrix.model }}-${{ matrix.lang }}
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: final
push: true
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
LANG=${{ matrix.lang }}
LOAD_WHISPER_STAGE=ghcr.io/jim60105/whisperx:cache-${{ matrix.model }}-${{ steps.get-sha.outputs.id }}
NO_MODEL_STAGE=ghcr.io/jim60105/whisperx:no_model@${{ needs.docker-no_model.outputs.digest }}
GIT_SHA=${{ github.sha }}
platforms: linux/amd64, linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/whisperx:cache,mode=max
test-large-v3-zh:
name: Test large-v3-zh docker image
runs-on: ubuntu-latest
needs: docker
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/test/**
sparse-checkout-cone-mode: false
- name: Get short SHA
id: get-sha
run: |
id=$(echo ${{ github.sha }} | cut -c 1-7)
echo "id=$id" >> $GITHUB_OUTPUT
- name: Test large-v3-zh docker image
run: |
docker run --group-add 0 -v ".:/app" ghcr.io/jim60105/whisperx:large-v3-zh-${{ steps.get-sha.outputs.id }} -- --device cpu --compute_type int8 --output_format srt .github/workflows/test/zh.webm;
if [ ! -f zh.srt ]; then
echo "The zh.srt file does not exist"
exit 1
fi
echo "cat zh.srt:";
cat zh.srt;
if ! grep -qi -e '充满' -e '充滿' zh.srt; then
echo "The zh.srt file does not contain the word '充满' or '充滿'"
exit 1
fi
echo "Test passed."