forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh_matrix_builder.py
executable file
·316 lines (287 loc) · 11.1 KB
/
gh_matrix_builder.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
#!/usr/bin/env python
# This file and its contents are licensed under the Apache License 2.0.
# Please see the included NOTICE for copyright information and
# LICENSE-APACHE for a copy of the license.
# Python script to dynamically generate matrix for github action
# Since we want to run additional test configurations when triggered
# by a push to prerelease_test or by cron but github actions don't
# allow a dynamic matrix via yaml configuration, we generate the matrix
# with this python script. While we could always have the full matrix
# and have if checks on every step that would make the actual checks
# harder to browse because the workflow will have lots of entries and
# only by navigating into the individual jobs would it be visible
# if a job was actually run.
import json
import os
import subprocess
import sys
from ci_settings import (
PG12_EARLIEST,
PG12_LATEST,
PG13_EARLIEST,
PG13_LATEST,
PG14_EARLIEST,
PG14_LATEST,
PG15_EARLIEST,
PG15_LATEST,
)
# github event type which is either push, pull_request or schedule
event_type = sys.argv[1]
m = {
"include": [],
}
# helper functions to generate matrix entries
# the release and apache config inherit from the
# debug config to reduce repetition
def build_debug_config(overrides):
# llvm version and clang versions must match otherwise
# there will be build errors this is true even when compiling
# with gcc as clang is used to compile the llvm parts.
#
# Strictly speaking, WARNINGS_AS_ERRORS=ON is not needed here, but
# we add it as a precaution. Intention is to have at least one
# release and one debug build with WARNINGS_AS_ERRORS=ON so that we
# capture warnings generated due to changes in the code base or the
# compiler.
base_config = dict(
{
"build_type": "Debug",
"cc": "gcc",
"clang": "clang-14",
"coverage": True,
"cxx": "g++",
"extra_packages": "clang-14 llvm-14 llvm-14-dev llvm-14-tools",
"installcheck_args": "IGNORES='bgw_db_scheduler bgw_db_scheduler_fixed'",
"name": "Debug",
"os": "ubuntu-22.04",
"pg_extra_args": "--enable-debug --enable-cassert --with-llvm LLVM_CONFIG=llvm-config-14",
"pginstallcheck": True,
"tsdb_build_args": "-DWARNINGS_AS_ERRORS=ON -DREQUIRE_ALL_TESTS=ON",
}
)
base_config.update(overrides)
return base_config
# We build this release configuration with WARNINGS_AS_ERRORS=ON to
# make sure that we can build with -Werrors even for release
# builds. This will capture some cases where warnings are generated
# for release builds but not for debug builds.
def build_release_config(overrides):
base_config = build_debug_config({})
release_config = dict(
{
"name": "Release",
"build_type": "Release",
"tsdb_build_args": "-DWARNINGS_AS_ERRORS=ON -DREQUIRE_ALL_TESTS=ON",
"coverage": False,
}
)
base_config.update(release_config)
base_config.update(overrides)
return base_config
def build_without_telemetry(overrides):
config = build_release_config({})
config.update(
{
"name": "ReleaseWithoutTelemetry",
"tsdb_build_args": config["tsdb_build_args"] + " -DUSE_TELEMETRY=OFF",
"coverage": False,
}
)
config.update(overrides)
return config
def build_apache_config(overrides):
base_config = build_debug_config({})
apache_config = dict(
{
"name": "ApacheOnly",
"build_type": "Release",
"tsdb_build_args": "-DWARNINGS_AS_ERRORS=ON -DREQUIRE_ALL_TESTS=ON -DAPACHE_ONLY=1",
"coverage": False,
}
)
base_config.update(apache_config)
base_config.update(overrides)
return base_config
def macos_config(overrides):
base_config = dict(
{
"cc": "clang",
"clang": "clang",
"coverage": False,
"cxx": "clang++",
"extra_packages": "",
"installcheck_args": "IGNORES='bgw_db_scheduler bgw_db_scheduler_fixed bgw_launcher pg_dump remote_connection compressed_collation'",
"os": "macos-11",
"pg": PG12_LATEST,
"pg_extra_args": "--with-libraries=/usr/local/opt/openssl/lib --with-includes=/usr/local/opt/openssl/include",
"pginstallcheck": True,
"tsdb_build_args": "-DASSERTIONS=ON -DREQUIRE_ALL_TESTS=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl",
}
)
base_config.update(overrides)
return base_config
# common installcheck_args for all pg15 tests
# partialize_finalize is ignored due to #4937
pg15_installcheck_args = "IGNORES='partialize_finalize'"
# always test debug build on latest of all supported pg versions
m["include"].append(build_debug_config({"pg": PG12_LATEST}))
m["include"].append(
build_debug_config({"pg": PG13_LATEST, "cc": "clang-14", "cxx": "clang++-14"})
)
m["include"].append(build_debug_config({"pg": PG14_LATEST}))
m["include"].append(
build_debug_config({"pg": PG15_LATEST, "installcheck_args": pg15_installcheck_args})
)
# test latest postgres release in MacOS
m["include"].append(
build_release_config(
macos_config({"pg": PG15_LATEST, "installcheck_args": pg15_installcheck_args})
)
)
# test latest postgres release without telemetry
m["include"].append(
build_without_telemetry(
{"pg": PG15_LATEST, "installcheck_args": pg15_installcheck_args}
)
)
# if this is not a pull request e.g. a scheduled run or a push
# to a specific branch like prerelease_test we add additional
# entries to the matrix
if event_type != "pull_request":
# add debug test for first supported PG12 version
# most of the IGNORES are the isolation tests because the output format has changed between versions
# chunk_utils, telemetry and tablespace are skipped because of use after free bugs in postgres 12.0 which those tests hit
pg12_debug_earliest = {
"pg": PG12_EARLIEST,
# The early releases don't build with llvm 14.
"pg_extra_args": "--enable-debug --enable-cassert --without-llvm",
"installcheck_args": "SKIPS='chunk_utils tablespace telemetry' IGNORES='cluster-12 cagg_policy debug_notice dist_gapfill_pushdown-12'",
"tsdb_build_args": "-DWARNINGS_AS_ERRORS=ON -DASSERTIONS=ON -DPG_ISOLATION_REGRESS=OFF",
}
m["include"].append(build_debug_config(pg12_debug_earliest))
# add debug test for first supported PG13 version
pg13_debug_earliest = {
"pg": PG13_EARLIEST,
# The early releases don't build with llvm 14.
"pg_extra_args": "--enable-debug --enable-cassert --without-llvm",
"installcheck_args": "SKIPS='001_extension' IGNORES='dist_gapfill_pushdown-13'",
"tsdb_build_args": "-DWARNINGS_AS_ERRORS=ON -DASSERTIONS=ON -DPG_ISOLATION_REGRESS=OFF",
}
m["include"].append(build_debug_config(pg13_debug_earliest))
# add debug test for first supported PG14 version
m["include"].append(
build_debug_config(
{
"pg": PG14_EARLIEST,
# The early releases don't build with llvm 14.
"pg_extra_args": "--enable-debug --enable-cassert --without-llvm",
"installcheck_args": "IGNORES='dist_gapfill_pushdown-14 memoize'",
}
)
)
# add debug test for first supported PG15 version
m["include"].append(
build_debug_config(
{"pg": PG15_EARLIEST, "installcheck_args": pg15_installcheck_args}
)
)
# add debug test for MacOS
m["include"].append(build_debug_config(macos_config({})))
# add release test for latest pg releases
m["include"].append(build_release_config({"pg": PG12_LATEST}))
m["include"].append(build_release_config({"pg": PG13_LATEST}))
m["include"].append(build_release_config({"pg": PG14_LATEST}))
m["include"].append(
build_release_config(
{"pg": PG15_LATEST, "installcheck_args": pg15_installcheck_args}
)
)
# add apache only test for latest pg
m["include"].append(build_apache_config({"pg": PG12_LATEST}))
m["include"].append(build_apache_config({"pg": PG13_LATEST}))
m["include"].append(build_apache_config({"pg": PG14_LATEST}))
m["include"].append(build_apache_config({"pg": PG15_LATEST}))
# to discover issues with upcoming releases we run CI against
# the stable branches of supported PG releases
m["include"].append(build_debug_config({"pg": 12, "snapshot": "snapshot"}))
m["include"].append(build_debug_config({"pg": 13, "snapshot": "snapshot"}))
m["include"].append(
build_debug_config(
{
"installcheck_args": "IGNORES='dist_gapfill_pushdown-14 memoize'",
"pg": 14,
"snapshot": "snapshot",
}
)
)
m["include"].append(
build_debug_config(
{
"pg": 15,
"snapshot": "snapshot",
"installcheck_args": pg15_installcheck_args,
}
)
)
else:
# Check if we need to check for the flaky tests. Determine which test files
# have been changed in the PR. The sql files might include other files that
# change independently, and might be .in templates, so it's easier to look
# at the output files. They are also the same for the isolation tests.
p = subprocess.Popen(
f"git diff --name-only {sys.argv[2]} -- '**expected/*.out'",
stdout=subprocess.PIPE,
shell=True,
)
(output, err) = p.communicate()
p_status = p.wait()
if p_status != 0:
print(
f'git diff failed: code {p_status}, output "{output}", stderr "{err}"',
file=sys.stderr,
)
sys.exit(1)
tests = set()
test_count = 1
for f in output.decode().split("\n"):
print(f)
if not f:
continue
test_count += 1
if test_count > 10:
print(
f"too many ({test_count}) changed tests, won't run the flaky check",
file=sys.stderr,
)
print("full list:", file=sys.stderr)
print(output, file=sys.stderr)
tests = set()
break
basename = os.path.basename(f)
splitted = basename.split(".")
name = splitted[0]
ext = splitted[-1]
if ext == "out":
# Account for the version number.
tests.add(name)
else:
# Should've been filtered out above.
print(
f"unknown extension '{ext}' for test output file '{f}'", file=sys.stderr
)
sys.exit(1)
if tests:
m["include"].append(
build_debug_config(
{
"coverage": False,
"installcheck_args": f'TESTS="{" ".join(list(tests) * 20)}"',
"name": "Flaky Check Debug",
"pg": PG14_LATEST,
"pginstallcheck": False,
}
)
)
# generate command to set github action variable
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
print(str.format("matrix={0}", json.dumps(m)), file=output)