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 | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 15 | |
| 16 | if len(sys.argv) == 2: |
| 17 | build_type = sys.argv[1] |
| 18 | else: |
| 19 | print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr) |
| 20 | sys.exit(1) |
| 21 | |
| 22 | print("Generating matrix for type '{}'.".format(build_type)) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 23 | |
| 24 | |
| 25 | def 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 | |
| 33 | def clean_ssl(ssl): |
| 34 | return ssl.replace("_VERSION", "").lower() |
| 35 | |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 36 | def 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 Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 47 | def 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 Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 54 | |
| 55 | def clean_compression(compression): |
| 56 | return compression.replace("USE_", "").lower() |
| 57 | |
| 58 | |
| 59 | def 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 | |
| 71 | matrix = [] |
| 72 | |
| 73 | # Ubuntu |
| 74 | |
| 75 | os = "ubuntu-latest" |
| 76 | TARGET = "linux-glibc" |
| 77 | for 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 Tarreau | ed17ca7 | 2021-09-12 07:01:36 +0200 | [diff] [blame] | 96 | "USE_OT=1", |
Ilya Shipitsin | b9e3fb7 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 97 | "OT_INC=${HOME}/opt-ot/include", |
| 98 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 75c95aa | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 99 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 100 | "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 Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 106 | "WURFL_INC=addons/wurfl/dummy", |
| 107 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 108 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 109 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 110 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 111 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 112 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 113 | ], |
| 114 | } |
| 115 | ) |
| 116 | |
Tim Duesterhus | 762b1fd | 2021-08-14 14:36:55 +0200 | [diff] [blame] | 117 | for compression in ["USE_ZLIB=1"]: |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 118 | 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 Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 133 | "OPENSSL_VERSION=latest", |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 134 | "LIBRESSL_VERSION=latest", |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 135 | "QUICTLS=yes", |
Willy Tarreau | 30ee296 | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 136 | # "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 137 | ]: |
| 138 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 139 | if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes": |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 140 | flags.append("USE_QUIC=1") |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 141 | if ssl != "stock": |
| 142 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 143 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 144 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 145 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 146 | if "OPENSSL" in ssl and "latest" in ssl: |
| 147 | ssl = determine_latest_openssl(ssl) |
| 148 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 149 | 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 | |
| 162 | os = "ubuntu-latest" |
| 163 | CC = "clang" |
| 164 | TARGET = "linux-glibc" |
| 165 | matrix.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 Tarreau | ed17ca7 | 2021-09-12 07:01:36 +0200 | [diff] [blame] | 174 | "USE_OT=1", |
Ilya Shipitsin | b9e3fb7 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 175 | "OT_INC=${HOME}/opt-ot/include", |
| 176 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 75c95aa | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 177 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 178 | "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 Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 184 | "WURFL_INC=addons/wurfl/dummy", |
| 185 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 186 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 187 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 188 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 189 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 190 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 191 | ], |
| 192 | } |
| 193 | ) |
| 194 | |
| 195 | # macOS |
| 196 | |
| 197 | os = "macos-latest" |
| 198 | TARGET = "osx" |
| 199 | for 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 | |
| 212 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 213 | |
| 214 | print("::set-output name=matrix::{}".format(json.dumps({"include": matrix}))) |