blob: 72e6b1a8524e46d974fb06265b312379a5a36b84 [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 Duesterhus8a03bf42022-10-14 19:46:06 +020015from os import environ
Tim Duesterhus8d173e12020-11-20 00:16:00 +010016
17if len(sys.argv) == 2:
Ilya Shipitsin4a04cd32022-12-12 19:15:22 +050018 ref_name = sys.argv[1]
Tim Duesterhus8d173e12020-11-20 00:16:00 +010019else:
Ilya Shipitsin4a04cd32022-12-12 19:15:22 +050020 print("Usage: {} <ref_name>".format(sys.argv[0]), file=sys.stderr)
Tim Duesterhus8d173e12020-11-20 00:16:00 +010021 sys.exit(1)
22
Ilya Shipitsin4a04cd32022-12-12 19:15:22 +050023print("Generating matrix for type '{}'.".format(ref_name))
Tim Duesterhus288c0772020-07-28 23:00:35 +020024
Tim Duesterhus288c0772020-07-28 23:00:35 +020025def clean_ssl(ssl):
26 return ssl.replace("_VERSION", "").lower()
27
Ilya Shipitsin7b893c22022-05-20 23:02:38 +050028def determine_latest_openssl(ssl):
Ilya Shipitsin6fbc35f2022-12-22 22:27:37 +060029 headers = {'Authorization': 'token ' + environ.get('GITHUB_API_TOKEN')} if environ.get('GITHUB_API_TOKEN') else {}
30 request = urllib.request.Request('https://api.github.com/repos/openssl/openssl/tags', headers=headers)
31 openssl_tags = urllib.request.urlopen(request)
Ilya Shipitsin7b893c22022-05-20 23:02:38 +050032 tags = json.loads(openssl_tags.read().decode('utf-8'))
33 latest_tag = ''
34 for tag in tags:
35 name = tag['name']
36 if "openssl-" in name:
37 if name > latest_tag:
38 latest_tag = name
Ilya Shipitsin14711bd2022-10-11 12:10:57 +050039 return "OPENSSL_VERSION={}".format(latest_tag[8:])
Ilya Shipitsin7b893c22022-05-20 23:02:38 +050040
Ilya Shipitsin94cd7792022-05-13 21:59:38 +050041def determine_latest_libressl(ssl):
42 libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
43 for line in libressl_download_list.readlines():
44 decoded_line = line.decode("utf-8")
45 if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
46 l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
Ilya Shipitsin14711bd2022-10-11 12:10:57 +050047 return "LIBRESSL_VERSION={}".format(l)
Tim Duesterhus288c0772020-07-28 23:00:35 +020048
49def clean_compression(compression):
50 return compression.replace("USE_", "").lower()
51
52
53def get_asan_flags(cc):
Ilya Shipitsincfba1f92022-07-02 10:30:28 +050054 return [
55 "USE_OBSOLETE_LINKER=1",
56 'DEBUG_CFLAGS="-g -fsanitize=address"',
57 'LDFLAGS="-fsanitize=address"',
58 'CPU_CFLAGS.generic="-O1"',
59 ]
Tim Duesterhus288c0772020-07-28 23:00:35 +020060
Tim Duesterhus288c0772020-07-28 23:00:35 +020061
62matrix = []
63
64# Ubuntu
65
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +050066os = "ubuntu-latest" if "haproxy-" not in ref_name else "ubuntu-22.04"
Tim Duesterhus288c0772020-07-28 23:00:35 +020067TARGET = "linux-glibc"
68for CC in ["gcc", "clang"]:
69 matrix.append(
70 {
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +050071 "name": "{}, {}, no features".format(os, CC),
Tim Duesterhus288c0772020-07-28 23:00:35 +020072 "os": os,
73 "TARGET": TARGET,
74 "CC": CC,
75 "FLAGS": [],
76 }
77 )
78
79 matrix.append(
80 {
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +050081 "name": "{}, {}, all features".format(os, CC),
Tim Duesterhus288c0772020-07-28 23:00:35 +020082 "os": os,
83 "TARGET": TARGET,
84 "CC": CC,
85 "FLAGS": [
86 "USE_ZLIB=1",
Willy Tarreaued17ca72021-09-12 07:01:36 +020087 "USE_OT=1",
Ilya Shipitsinb9e3fb72022-01-13 11:36:28 +050088 "OT_INC=${HOME}/opt-ot/include",
89 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin75c95aa2021-05-18 09:46:43 +000090 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +020091 "USE_PCRE=1",
92 "USE_PCRE_JIT=1",
93 "USE_LUA=1",
94 "USE_OPENSSL=1",
95 "USE_SYSTEMD=1",
96 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +020097 "WURFL_INC=addons/wurfl/dummy",
98 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +020099 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200100 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200101 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500102 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200103 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200104 ],
105 }
106 )
107
Ilya Shipitsin6dedeb72022-12-14 18:18:20 +0500108# ASAN
109
110 matrix.append(
111 {
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +0500112 "name": "{}, {}, ASAN, all features".format(os, CC),
Ilya Shipitsin6dedeb72022-12-14 18:18:20 +0500113 "os": os,
114 "TARGET": TARGET,
115 "CC": CC,
116 "FLAGS": get_asan_flags(CC)
117 + [
118 "USE_ZLIB=1",
119 "USE_OT=1",
120 "OT_INC=${HOME}/opt-ot/include",
121 "OT_LIB=${HOME}/opt-ot/lib",
122 "OT_RUNPATH=1",
123 "USE_PCRE=1",
124 "USE_PCRE_JIT=1",
125 "USE_LUA=1",
126 "USE_OPENSSL=1",
127 "USE_SYSTEMD=1",
128 "USE_WURFL=1",
129 "WURFL_INC=addons/wurfl/dummy",
130 "WURFL_LIB=addons/wurfl/dummy",
131 "USE_DEVICEATLAS=1",
132 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
133 "USE_PROMEX=1",
134 "USE_51DEGREES=1",
135 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
136 ],
137 }
138 )
139
Tim Duesterhus762b1fd2021-08-14 14:36:55 +0200140 for compression in ["USE_ZLIB=1"]:
Tim Duesterhus288c0772020-07-28 23:00:35 +0200141 matrix.append(
142 {
143 "name": "{}, {}, gz={}".format(
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +0500144 os, CC, clean_compression(compression)
Tim Duesterhus288c0772020-07-28 23:00:35 +0200145 ),
146 "os": os,
147 "TARGET": TARGET,
148 "CC": CC,
149 "FLAGS": [compression],
150 }
151 )
152
153 for ssl in [
154 "stock",
155 "OPENSSL_VERSION=1.0.2u",
William Lallemand393e4e42022-12-12 08:52:03 +0100156 "OPENSSL_VERSION=1.1.1s",
Ilya Shipitsind69d65a2021-11-18 18:27:57 +0500157 "QUICTLS=yes",
Willy Tarreau30ee2962021-09-02 17:32:43 +0200158# "BORINGSSL=yes",
Ilya Shipitsin4a04cd32022-12-12 19:15:22 +0500159 ] + (["OPENSSL_VERSION=latest", "LIBRESSL_VERSION=latest"] if "haproxy-" not in ref_name else []):
Tim Duesterhus288c0772020-07-28 23:00:35 +0200160 flags = ["USE_OPENSSL=1"]
Ilya Shipitsin6397c7c2022-11-02 11:59:37 +0500161 if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes" or "LIBRESSL" in ssl:
Ilya Shipitsin714f28c2021-05-09 21:27:28 +0500162 flags.append("USE_QUIC=1")
Tim Duesterhus288c0772020-07-28 23:00:35 +0200163 if ssl != "stock":
164 flags.append("SSL_LIB=${HOME}/opt/lib")
165 flags.append("SSL_INC=${HOME}/opt/include")
Ilya Shipitsin94cd7792022-05-13 21:59:38 +0500166 if "LIBRESSL" in ssl and "latest" in ssl:
167 ssl = determine_latest_libressl(ssl)
Ilya Shipitsin7b893c22022-05-20 23:02:38 +0500168 if "OPENSSL" in ssl and "latest" in ssl:
169 ssl = determine_latest_openssl(ssl)
170
Tim Duesterhus288c0772020-07-28 23:00:35 +0200171 matrix.append(
172 {
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +0500173 "name": "{}, {}, ssl={}".format(os, CC, clean_ssl(ssl)),
Tim Duesterhus288c0772020-07-28 23:00:35 +0200174 "os": os,
175 "TARGET": TARGET,
176 "CC": CC,
177 "ssl": ssl,
178 "FLAGS": flags,
179 }
180 )
181
Tim Duesterhus288c0772020-07-28 23:00:35 +0200182# macOS
183
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +0500184os = "macos-latest" if "haproxy-" not in ref_name else "macos-12"
Tim Duesterhus288c0772020-07-28 23:00:35 +0200185TARGET = "osx"
186for CC in ["clang"]:
187 matrix.append(
188 {
Ilya Shipitsinf5994fc2022-12-14 18:23:24 +0500189 "name": "{}, {}, no features".format(os, CC),
Tim Duesterhus288c0772020-07-28 23:00:35 +0200190 "os": os,
191 "TARGET": TARGET,
192 "CC": CC,
193 "FLAGS": [],
194 }
195 )
196
197# Print matrix
198
199print(json.dumps(matrix, indent=4, sort_keys=True))
200
Tim Duesterhus8a03bf42022-10-14 19:46:06 +0200201if environ.get('GITHUB_OUTPUT') is not None:
202 with open(environ.get('GITHUB_OUTPUT'), 'a') as f:
203 print("matrix={}".format(json.dumps({"include": matrix})), file=f)