Tim Duesterhus | 871ef2f | 2021-06-08 15:14:35 +0200 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 3 | # 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 | |
| 11 | import json |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 12 | import sys |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 13 | import urllib.request |
| 14 | import re |
Tim Duesterhus | 8a03bf4 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 15 | from os import environ |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 16 | |
| 17 | if len(sys.argv) == 2: |
| 18 | build_type = sys.argv[1] |
| 19 | else: |
| 20 | print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr) |
| 21 | sys.exit(1) |
| 22 | |
| 23 | print("Generating matrix for type '{}'.".format(build_type)) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 24 | |
| 25 | |
| 26 | def clean_os(os): |
| 27 | if os == "ubuntu-latest": |
| 28 | return "Ubuntu" |
| 29 | elif os == "macos-latest": |
| 30 | return "macOS" |
| 31 | return os.replace("-latest", "") |
| 32 | |
| 33 | |
| 34 | def clean_ssl(ssl): |
| 35 | return ssl.replace("_VERSION", "").lower() |
| 36 | |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 37 | def determine_latest_openssl(ssl): |
| 38 | openssl_tags = urllib.request.urlopen("https://api.github.com/repos/openssl/openssl/tags") |
| 39 | tags = json.loads(openssl_tags.read().decode('utf-8')) |
| 40 | latest_tag = '' |
| 41 | for tag in tags: |
| 42 | name = tag['name'] |
| 43 | if "openssl-" in name: |
| 44 | if name > latest_tag: |
| 45 | latest_tag = name |
Ilya Shipitsin | 14711bd | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 46 | return "OPENSSL_VERSION={}".format(latest_tag[8:]) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 47 | |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 48 | def determine_latest_libressl(ssl): |
| 49 | libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/") |
| 50 | for line in libressl_download_list.readlines(): |
| 51 | decoded_line = line.decode("utf-8") |
| 52 | if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line: |
| 53 | l = re.split("libressl-|.tar.gz.asc", decoded_line)[1] |
Ilya Shipitsin | 14711bd | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 54 | return "LIBRESSL_VERSION={}".format(l) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 55 | |
| 56 | def clean_compression(compression): |
| 57 | return compression.replace("USE_", "").lower() |
| 58 | |
| 59 | |
| 60 | def get_asan_flags(cc): |
Ilya Shipitsin | cfba1f9 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 61 | return [ |
| 62 | "USE_OBSOLETE_LINKER=1", |
| 63 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 64 | 'LDFLAGS="-fsanitize=address"', |
| 65 | 'CPU_CFLAGS.generic="-O1"', |
| 66 | ] |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 67 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 68 | |
| 69 | matrix = [] |
| 70 | |
| 71 | # Ubuntu |
| 72 | |
| 73 | os = "ubuntu-latest" |
| 74 | TARGET = "linux-glibc" |
| 75 | for CC in ["gcc", "clang"]: |
| 76 | matrix.append( |
| 77 | { |
| 78 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 79 | "os": os, |
| 80 | "TARGET": TARGET, |
| 81 | "CC": CC, |
| 82 | "FLAGS": [], |
| 83 | } |
| 84 | ) |
| 85 | |
| 86 | matrix.append( |
| 87 | { |
| 88 | "name": "{}, {}, all features".format(clean_os(os), CC), |
| 89 | "os": os, |
| 90 | "TARGET": TARGET, |
| 91 | "CC": CC, |
| 92 | "FLAGS": [ |
| 93 | "USE_ZLIB=1", |
Willy Tarreau | ed17ca7 | 2021-09-12 07:01:36 +0200 | [diff] [blame] | 94 | "USE_OT=1", |
Ilya Shipitsin | b9e3fb7 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 95 | "OT_INC=${HOME}/opt-ot/include", |
| 96 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 75c95aa | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 97 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 98 | "USE_PCRE=1", |
| 99 | "USE_PCRE_JIT=1", |
| 100 | "USE_LUA=1", |
| 101 | "USE_OPENSSL=1", |
| 102 | "USE_SYSTEMD=1", |
| 103 | "USE_WURFL=1", |
Willy Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 104 | "WURFL_INC=addons/wurfl/dummy", |
| 105 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 106 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 107 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 108 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 109 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 110 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 111 | ], |
| 112 | } |
| 113 | ) |
| 114 | |
Tim Duesterhus | 762b1fd | 2021-08-14 14:36:55 +0200 | [diff] [blame] | 115 | for compression in ["USE_ZLIB=1"]: |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 116 | matrix.append( |
| 117 | { |
| 118 | "name": "{}, {}, gz={}".format( |
| 119 | clean_os(os), CC, clean_compression(compression) |
| 120 | ), |
| 121 | "os": os, |
| 122 | "TARGET": TARGET, |
| 123 | "CC": CC, |
| 124 | "FLAGS": [compression], |
| 125 | } |
| 126 | ) |
| 127 | |
| 128 | for ssl in [ |
| 129 | "stock", |
| 130 | "OPENSSL_VERSION=1.0.2u", |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 131 | "OPENSSL_VERSION=latest", |
Ilya Shipitsin | b65fd66 | 2022-10-11 12:11:55 +0500 | [diff] [blame] | 132 | "LIBRESSL_VERSION=3.5.3", |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 133 | "QUICTLS=yes", |
Willy Tarreau | 30ee296 | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 134 | # "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 135 | ]: |
| 136 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 137 | if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes": |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 138 | flags.append("USE_QUIC=1") |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 139 | if ssl != "stock": |
| 140 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 141 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 142 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 143 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 144 | if "OPENSSL" in ssl and "latest" in ssl: |
| 145 | ssl = determine_latest_openssl(ssl) |
| 146 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 147 | matrix.append( |
| 148 | { |
| 149 | "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)), |
| 150 | "os": os, |
| 151 | "TARGET": TARGET, |
| 152 | "CC": CC, |
| 153 | "ssl": ssl, |
| 154 | "FLAGS": flags, |
| 155 | } |
| 156 | ) |
| 157 | |
| 158 | # ASAN |
| 159 | |
| 160 | os = "ubuntu-latest" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 161 | TARGET = "linux-glibc" |
Ilya Shipitsin | cfba1f9 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 162 | for CC in ["gcc","clang"]: |
| 163 | matrix.append( |
| 164 | { |
| 165 | "name": "{}, {}, ASAN, all features".format(clean_os(os), CC), |
| 166 | "os": os, |
| 167 | "TARGET": TARGET, |
| 168 | "CC": CC, |
| 169 | "FLAGS": get_asan_flags(CC) |
| 170 | + [ |
| 171 | "USE_ZLIB=1", |
| 172 | "USE_OT=1", |
| 173 | "OT_INC=${HOME}/opt-ot/include", |
| 174 | "OT_LIB=${HOME}/opt-ot/lib", |
| 175 | "OT_RUNPATH=1", |
| 176 | "USE_PCRE=1", |
| 177 | "USE_PCRE_JIT=1", |
| 178 | "USE_LUA=1", |
| 179 | "USE_OPENSSL=1", |
| 180 | "USE_SYSTEMD=1", |
| 181 | "USE_WURFL=1", |
| 182 | "WURFL_INC=addons/wurfl/dummy", |
| 183 | "WURFL_LIB=addons/wurfl/dummy", |
| 184 | "USE_DEVICEATLAS=1", |
| 185 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
| 186 | "USE_PROMEX=1", |
| 187 | "USE_51DEGREES=1", |
| 188 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
| 189 | ], |
| 190 | } |
| 191 | ) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 192 | |
| 193 | # macOS |
| 194 | |
| 195 | os = "macos-latest" |
| 196 | TARGET = "osx" |
| 197 | for CC in ["clang"]: |
| 198 | matrix.append( |
| 199 | { |
| 200 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 201 | "os": os, |
| 202 | "TARGET": TARGET, |
| 203 | "CC": CC, |
| 204 | "FLAGS": [], |
| 205 | } |
| 206 | ) |
| 207 | |
| 208 | # Print matrix |
| 209 | |
| 210 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 211 | |
Tim Duesterhus | 8a03bf4 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 212 | if environ.get('GITHUB_OUTPUT') is not None: |
| 213 | with open(environ.get('GITHUB_OUTPUT'), 'a') as f: |
| 214 | print("matrix={}".format(json.dumps({"include": matrix})), file=f) |