This repository has been archived by the owner on May 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
github-actions-matrix.py
357 lines (337 loc) · 8.74 KB
/
github-actions-matrix.py
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
import argparse
import json
from typing import NamedTuple
class Triplet(NamedTuple):
triplet: str
os: str
class Test(NamedTuple):
test: str
features: str
dependencies_ubuntu: str = ""
dependencies_macos: str = ""
deps_ubuntu_fontconfig = "autopoint gperf"
deps_macos_fontconfig = "automake gperf"
deps_ubuntu_opengl = "libgl-dev libglx-dev"
deps_ubuntu_all = " ".join([deps_ubuntu_fontconfig, deps_ubuntu_opengl])
deps_macos_all = deps_macos_fontconfig
triplets = [
Triplet(
triplet="x64-linux",
os="ubuntu-latest",
),
Triplet(
triplet="x64-osx",
os="macos-latest",
),
Triplet(
triplet="x64-uwp",
os="windows-latest",
),
Triplet(
triplet="x64-windows",
os="windows-latest",
),
Triplet(
triplet="x64-windows-static",
os="windows-latest",
),
Triplet(
triplet="x64-windows-static-md",
os="windows-latest",
),
Triplet(
triplet="x86-windows",
os="windows-latest",
),
Triplet(
triplet="x64-mingw-dynamic",
os="ubuntu-latest",
),
Triplet(
triplet="x64-mingw-static",
os="ubuntu-latest",
),
]
tests = [
Test(
test="minimal",
features="core",
),
Test(
test="all",
features="core,all",
dependencies_ubuntu=deps_ubuntu_all,
dependencies_macos=deps_macos_all,
),
Test(
test="all-gpl",
features="core,all-gpl",
dependencies_ubuntu=deps_ubuntu_all,
dependencies_macos=deps_macos_all,
),
Test(
test="all-nonfree",
features="core,all-nonfree",
dependencies_ubuntu=deps_ubuntu_all,
dependencies_macos=deps_macos_all,
),
Test(
test="avcodec",
features="core,avcodec",
),
Test(
test="avformat",
features="core,avformat",
),
Test(
test="avdevice",
features="core,avdevice",
),
Test(
test="avfilter",
features="core,avfilter",
),
Test(
test="swresample",
features="core,swresample",
),
Test(
test="swscale",
features="core,swscale",
),
Test(
test="ffmpeg",
features="core,ffmpeg",
),
Test(
test="ffplay",
features="core,ffplay",
),
Test(
test="ffprobe",
features="core,ffprobe",
),
Test(
test="ass",
features="core,ass,avfilter",
dependencies_ubuntu=deps_ubuntu_fontconfig,
dependencies_macos=deps_macos_fontconfig,
),
Test(
test="bzip2",
features="core,bzip2,avformat",
),
Test(
test="dav1d",
features="core,dav1d,avcodec",
),
Test(
test="freetype1",
features="core,freetype,avfilter",
),
Test(
test="freetype2",
features="core,freetype,fontconfig,fribidi,avfilter",
dependencies_ubuntu=deps_ubuntu_fontconfig,
dependencies_macos=deps_macos_fontconfig,
),
Test(
test="iconv",
features="core,iconv,avcodec",
),
Test(
test="ilbc",
features="core,ilbc,avcodec",
),
Test(
test="lzma",
features="core,lzma,avformat",
),
Test(
test="modplug",
features="core,modplug,avformat",
),
Test(
test="mp3lame",
features="core,mp3lame,avcodec",
),
Test(
test="nvcodec",
features="core,nvcodec,avcodec",
),
Test(
test="opencl",
features="core,opencl,avfilter",
),
Test(
test="opengl",
features="core,opengl,avdevice",
dependencies_ubuntu=deps_ubuntu_opengl,
),
Test(
test="openh264",
features="core,openh264,avcodec",
),
Test(
test="openjpeg",
features="core,openjpeg,avcodec",
),
Test(
test="opus",
features="core,opus,avcodec",
),
Test(
test="sdl2",
features="core,sdl2,avdevice",
),
Test(
test="snappy",
features="core,snappy,avcodec",
),
Test(
test="soxr",
features="core,soxr,swresample",
),
Test(
test="ssh",
features="core,ssh,avformat",
),
Test(
test="tesseract",
features="core,tesseract,avfilter",
),
Test(
test="speex",
features="core,speex,avcodec",
),
Test(
test="theora",
features="core,theora,avcodec",
),
Test(
test="vorbis",
features="core,vorbis,avcodec",
),
Test(
test="vpx",
features="core,vpx,avcodec",
),
Test(
test="webp",
features="core,webp,avcodec",
),
Test(
test="xml2",
features="core,xml2,avformat",
),
Test(
test="zlib",
features="core,zlib,avformat",
),
Test(
test="avisynthplus",
features="core,avisynthplus,avformat",
),
# GPL features
Test(
test="postproc",
features="core,postproc",
),
Test(
test="x264",
features="core,x264,avcodec",
),
Test(
test="x265",
features="core,x265,avcodec",
),
# non-free features
Test(
test="openssl",
features="core,openssl,avformat",
),
Test(
test="fdk-aac",
features="core,fdk-aac,avcodec",
),
]
parser = argparse.ArgumentParser(description='Generate build matrix.')
parser.add_argument('--triplets', nargs='*')
parser.add_argument('--tests', nargs='*')
parser.add_argument("--period", type=int, default=1)
parser.add_argument("--run", type=int, default=0)
parser.add_argument("--pretty", action="store_true")
parser.add_argument("--summary", action="store_true")
args = parser.parse_args()
def experimental_job(triplet: Triplet, test: Test):
is_experimental = dict(experimental=True)
if test.test == "ffplay" and triplet.triplet == "x64-osx":
return is_experimental
if test.test == "ass" and triplet.triplet == "x64-uwp":
return is_experimental
if test.test == "bzip2" and triplet.triplet == "x64-osx":
return is_experimental
if test.test == "dav1d" and triplet.triplet == "x64-osx":
return is_experimental
if test.test == "freetype2" and triplet.triplet.startswith("x64-windows-static"):
return is_experimental
if test.test == "freetype2" and triplet.triplet == "x64-linux":
return is_experimental
if test.test == "freetype2" and triplet.triplet == "x64-osx":
return is_experimental
if test.test == "modplug" and triplet.triplet == "x64-uwp":
return is_experimental
if test.test == "openh264" and triplet.triplet == "x64-uwp":
return is_experimental
return dict(experimental=False)
def include_job(triplet: Triplet, test: Test):
# filter as per arguments provided
if args.triplets:
if triplet.triplet not in args.triplets:
return False
if args.tests:
if test.test not in args.tests:
return False
# remove x64-mingw triplets if no triplets are specified
# (known to be broken)
if not args.triplets:
if triplet.triplet.startswith("x64-mingw"):
return False
# avisynthplus only supported on windows with dynamic linkage
if test.test == "avisynthplus":
return triplet.triplet in {"x86-windows", "x64-windows"}
# dav1d only supports 64 bit
if test.test == "dav1d" and triplet.triplet.startswith("x86-windows"):
return False
# nvcodec not supported on osx
if test.test == "nvcodec" and triplet.triplet == "x64-osx":
return False
# features not supported on uwp
if test.test == "opencl" and triplet.triplet == "x64-uwp":
return False
if test.test == "opengl" and triplet.triplet == "x64-uwp":
return False
return True
def schedule_jobs(jobs):
return [
job for i, job in enumerate(jobs)
if i % args.period == args.run % args.period]
jobs = schedule_jobs([
{**triplet._asdict(), **test._asdict(), **experimental_job(triplet, test)}
for triplet in triplets
for test in tests
if include_job(triplet, test)
])
if args.summary:
for job in jobs:
triplet = job["triplet"]
test = job["test"]
print(f"{triplet} {test}")
print(len(jobs))
else:
if args.pretty:
json_args = dict(indent=4)
else:
json_args = dict(separators=(',', ':'))
matrix = {"include": jobs}
print("::set-output name=matrix::%s" % json.dumps(matrix, **json_args))