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): |
Ilya Shipitsin | cfba1f9 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 60 | return [ |
| 61 | "USE_OBSOLETE_LINKER=1", |
| 62 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 63 | 'LDFLAGS="-fsanitize=address"', |
| 64 | 'CPU_CFLAGS.generic="-O1"', |
| 65 | ] |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 66 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 67 | |
| 68 | matrix = [] |
| 69 | |
| 70 | # Ubuntu |
| 71 | |
| 72 | os = "ubuntu-latest" |
| 73 | TARGET = "linux-glibc" |
| 74 | for CC in ["gcc", "clang"]: |
| 75 | matrix.append( |
| 76 | { |
| 77 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 78 | "os": os, |
| 79 | "TARGET": TARGET, |
| 80 | "CC": CC, |
| 81 | "FLAGS": [], |
| 82 | } |
| 83 | ) |
| 84 | |
| 85 | matrix.append( |
| 86 | { |
| 87 | "name": "{}, {}, all features".format(clean_os(os), CC), |
| 88 | "os": os, |
| 89 | "TARGET": TARGET, |
| 90 | "CC": CC, |
| 91 | "FLAGS": [ |
| 92 | "USE_ZLIB=1", |
Willy Tarreau | ed17ca7 | 2021-09-12 07:01:36 +0200 | [diff] [blame] | 93 | "USE_OT=1", |
Ilya Shipitsin | b9e3fb7 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 94 | "OT_INC=${HOME}/opt-ot/include", |
| 95 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 75c95aa | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 96 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 97 | "USE_PCRE=1", |
| 98 | "USE_PCRE_JIT=1", |
| 99 | "USE_LUA=1", |
| 100 | "USE_OPENSSL=1", |
| 101 | "USE_SYSTEMD=1", |
| 102 | "USE_WURFL=1", |
Willy Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 103 | "WURFL_INC=addons/wurfl/dummy", |
| 104 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 105 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 106 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 107 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 108 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 109 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 110 | ], |
| 111 | } |
| 112 | ) |
| 113 | |
Tim Duesterhus | 762b1fd | 2021-08-14 14:36:55 +0200 | [diff] [blame] | 114 | for compression in ["USE_ZLIB=1"]: |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 115 | matrix.append( |
| 116 | { |
| 117 | "name": "{}, {}, gz={}".format( |
| 118 | clean_os(os), CC, clean_compression(compression) |
| 119 | ), |
| 120 | "os": os, |
| 121 | "TARGET": TARGET, |
| 122 | "CC": CC, |
| 123 | "FLAGS": [compression], |
| 124 | } |
| 125 | ) |
| 126 | |
| 127 | for ssl in [ |
| 128 | "stock", |
| 129 | "OPENSSL_VERSION=1.0.2u", |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 130 | "OPENSSL_VERSION=latest", |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 131 | "LIBRESSL_VERSION=latest", |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 132 | "QUICTLS=yes", |
Willy Tarreau | 30ee296 | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 133 | # "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 134 | ]: |
| 135 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 136 | if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes": |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 137 | flags.append("USE_QUIC=1") |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 138 | if ssl != "stock": |
| 139 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 140 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 141 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 142 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 143 | if "OPENSSL" in ssl and "latest" in ssl: |
| 144 | ssl = determine_latest_openssl(ssl) |
| 145 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 146 | matrix.append( |
| 147 | { |
| 148 | "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)), |
| 149 | "os": os, |
| 150 | "TARGET": TARGET, |
| 151 | "CC": CC, |
| 152 | "ssl": ssl, |
| 153 | "FLAGS": flags, |
| 154 | } |
| 155 | ) |
| 156 | |
| 157 | # ASAN |
| 158 | |
| 159 | os = "ubuntu-latest" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 160 | TARGET = "linux-glibc" |
Ilya Shipitsin | cfba1f9 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 161 | for CC in ["gcc","clang"]: |
| 162 | matrix.append( |
| 163 | { |
| 164 | "name": "{}, {}, ASAN, all features".format(clean_os(os), CC), |
| 165 | "os": os, |
| 166 | "TARGET": TARGET, |
| 167 | "CC": CC, |
| 168 | "FLAGS": get_asan_flags(CC) |
| 169 | + [ |
| 170 | "USE_ZLIB=1", |
| 171 | "USE_OT=1", |
| 172 | "OT_INC=${HOME}/opt-ot/include", |
| 173 | "OT_LIB=${HOME}/opt-ot/lib", |
| 174 | "OT_RUNPATH=1", |
| 175 | "USE_PCRE=1", |
| 176 | "USE_PCRE_JIT=1", |
| 177 | "USE_LUA=1", |
| 178 | "USE_OPENSSL=1", |
| 179 | "USE_SYSTEMD=1", |
| 180 | "USE_WURFL=1", |
| 181 | "WURFL_INC=addons/wurfl/dummy", |
| 182 | "WURFL_LIB=addons/wurfl/dummy", |
| 183 | "USE_DEVICEATLAS=1", |
| 184 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
| 185 | "USE_PROMEX=1", |
| 186 | "USE_51DEGREES=1", |
| 187 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
| 188 | ], |
| 189 | } |
| 190 | ) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 191 | |
| 192 | # macOS |
| 193 | |
| 194 | os = "macos-latest" |
| 195 | TARGET = "osx" |
| 196 | for CC in ["clang"]: |
| 197 | matrix.append( |
| 198 | { |
| 199 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 200 | "os": os, |
| 201 | "TARGET": TARGET, |
| 202 | "CC": CC, |
| 203 | "FLAGS": [], |
| 204 | } |
| 205 | ) |
| 206 | |
| 207 | # Print matrix |
| 208 | |
| 209 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 210 | |
| 211 | print("::set-output name=matrix::{}".format(json.dumps({"include": matrix}))) |