blob: 27f25ff7a8a00f72899207f543ff695fbc695024 [file] [log] [blame]
Tim Duesterhus871ef2f2021-06-08 15:14:35 +02001#!/usr/bin/python3
2
Tim Duesterhus288c0772020-07-28 23:00:35 +02003# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
4# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version
9# 2 of the License, or (at your option) any later version.
10
11import json
Tim Duesterhus8d173e12020-11-20 00:16:00 +010012import sys
Ilya Shipitsin94cd7792022-05-13 21:59:38 +050013import urllib.request
14import re
Tim Duesterhus8d173e12020-11-20 00:16:00 +010015
16if len(sys.argv) == 2:
17 build_type = sys.argv[1]
18else:
19 print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr)
20 sys.exit(1)
21
22print("Generating matrix for type '{}'.".format(build_type))
Tim Duesterhus288c0772020-07-28 23:00:35 +020023
24
25def clean_os(os):
26 if os == "ubuntu-latest":
27 return "Ubuntu"
28 elif os == "macos-latest":
29 return "macOS"
30 return os.replace("-latest", "")
31
32
33def clean_ssl(ssl):
34 return ssl.replace("_VERSION", "").lower()
35
Ilya Shipitsin7b893c22022-05-20 23:02:38 +050036def determine_latest_openssl(ssl):
37 openssl_tags = urllib.request.urlopen("https://api.github.com/repos/openssl/openssl/tags")
38 tags = json.loads(openssl_tags.read().decode('utf-8'))
39 latest_tag = ''
40 for tag in tags:
41 name = tag['name']
42 if "openssl-" in name:
43 if name > latest_tag:
44 latest_tag = name
45 return "OPENSSL={}".format(latest_tag[8:])
46
Ilya Shipitsin94cd7792022-05-13 21:59:38 +050047def determine_latest_libressl(ssl):
48 libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
49 for line in libressl_download_list.readlines():
50 decoded_line = line.decode("utf-8")
51 if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
52 l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
53 return "LIBRESSL={}".format(l)
Tim Duesterhus288c0772020-07-28 23:00:35 +020054
55def clean_compression(compression):
56 return compression.replace("USE_", "").lower()
57
58
59def get_asan_flags(cc):
60 if cc == "clang":
61 return [
62 "USE_OBSOLETE_LINKER=1",
63 'DEBUG_CFLAGS="-g -fsanitize=address"',
64 'LDFLAGS="-fsanitize=address"',
65 'CPU_CFLAGS.generic="-O1"',
66 ]
67
68 raise ValueError("ASAN is only supported for clang")
69
70
71matrix = []
72
73# Ubuntu
74
75os = "ubuntu-latest"
76TARGET = "linux-glibc"
77for CC in ["gcc", "clang"]:
78 matrix.append(
79 {
80 "name": "{}, {}, no features".format(clean_os(os), CC),
81 "os": os,
82 "TARGET": TARGET,
83 "CC": CC,
84 "FLAGS": [],
85 }
86 )
87
88 matrix.append(
89 {
90 "name": "{}, {}, all features".format(clean_os(os), CC),
91 "os": os,
92 "TARGET": TARGET,
93 "CC": CC,
94 "FLAGS": [
95 "USE_ZLIB=1",
Willy Tarreaued17ca72021-09-12 07:01:36 +020096 "USE_OT=1",
Ilya Shipitsinb9e3fb72022-01-13 11:36:28 +050097 "OT_INC=${HOME}/opt-ot/include",
98 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin75c95aa2021-05-18 09:46:43 +000099 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200100 "USE_PCRE=1",
101 "USE_PCRE_JIT=1",
102 "USE_LUA=1",
103 "USE_OPENSSL=1",
104 "USE_SYSTEMD=1",
105 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +0200106 "WURFL_INC=addons/wurfl/dummy",
107 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200108 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200109 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200110 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500111 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200112 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200113 ],
114 }
115 )
116
Tim Duesterhus762b1fd2021-08-14 14:36:55 +0200117 for compression in ["USE_ZLIB=1"]:
Tim Duesterhus288c0772020-07-28 23:00:35 +0200118 matrix.append(
119 {
120 "name": "{}, {}, gz={}".format(
121 clean_os(os), CC, clean_compression(compression)
122 ),
123 "os": os,
124 "TARGET": TARGET,
125 "CC": CC,
126 "FLAGS": [compression],
127 }
128 )
129
130 for ssl in [
131 "stock",
132 "OPENSSL_VERSION=1.0.2u",
Ilya Shipitsin7b893c22022-05-20 23:02:38 +0500133 "OPENSSL_VERSION=latest",
Ilya Shipitsin94cd7792022-05-13 21:59:38 +0500134 "LIBRESSL_VERSION=latest",
Ilya Shipitsind69d65a2021-11-18 18:27:57 +0500135 "QUICTLS=yes",
Willy Tarreau30ee2962021-09-02 17:32:43 +0200136# "BORINGSSL=yes",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200137 ]:
138 flags = ["USE_OPENSSL=1"]
Ilya Shipitsind69d65a2021-11-18 18:27:57 +0500139 if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes":
Ilya Shipitsin714f28c2021-05-09 21:27:28 +0500140 flags.append("USE_QUIC=1")
Tim Duesterhus288c0772020-07-28 23:00:35 +0200141 if ssl != "stock":
142 flags.append("SSL_LIB=${HOME}/opt/lib")
143 flags.append("SSL_INC=${HOME}/opt/include")
Ilya Shipitsin94cd7792022-05-13 21:59:38 +0500144 if "LIBRESSL" in ssl and "latest" in ssl:
145 ssl = determine_latest_libressl(ssl)
Ilya Shipitsin7b893c22022-05-20 23:02:38 +0500146 if "OPENSSL" in ssl and "latest" in ssl:
147 ssl = determine_latest_openssl(ssl)
148
Tim Duesterhus288c0772020-07-28 23:00:35 +0200149 matrix.append(
150 {
151 "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)),
152 "os": os,
153 "TARGET": TARGET,
154 "CC": CC,
155 "ssl": ssl,
156 "FLAGS": flags,
157 }
158 )
159
160# ASAN
161
162os = "ubuntu-latest"
163CC = "clang"
164TARGET = "linux-glibc"
165matrix.append(
166 {
167 "name": "{}, {}, ASAN, all features".format(clean_os(os), CC),
168 "os": os,
169 "TARGET": TARGET,
170 "CC": CC,
171 "FLAGS": get_asan_flags(CC)
172 + [
173 "USE_ZLIB=1",
Willy Tarreaued17ca72021-09-12 07:01:36 +0200174 "USE_OT=1",
Ilya Shipitsinb9e3fb72022-01-13 11:36:28 +0500175 "OT_INC=${HOME}/opt-ot/include",
176 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin75c95aa2021-05-18 09:46:43 +0000177 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200178 "USE_PCRE=1",
179 "USE_PCRE_JIT=1",
180 "USE_LUA=1",
181 "USE_OPENSSL=1",
182 "USE_SYSTEMD=1",
183 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +0200184 "WURFL_INC=addons/wurfl/dummy",
185 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200186 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200187 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200188 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500189 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200190 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200191 ],
192 }
193)
194
195# macOS
196
197os = "macos-latest"
198TARGET = "osx"
199for CC in ["clang"]:
200 matrix.append(
201 {
202 "name": "{}, {}, no features".format(clean_os(os), CC),
203 "os": os,
204 "TARGET": TARGET,
205 "CC": CC,
206 "FLAGS": [],
207 }
208 )
209
210# Print matrix
211
212print(json.dumps(matrix, indent=4, sort_keys=True))
213
214print("::set-output name=matrix::{}".format(json.dumps({"include": matrix})))