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: |
Ilya Shipitsin | 4a04cd3 | 2022-12-12 19:15:22 +0500 | [diff] [blame] | 18 | ref_name = sys.argv[1] |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 19 | else: |
Ilya Shipitsin | 4a04cd3 | 2022-12-12 19:15:22 +0500 | [diff] [blame] | 20 | print("Usage: {} <ref_name>".format(sys.argv[0]), file=sys.stderr) |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 21 | sys.exit(1) |
| 22 | |
Ilya Shipitsin | 4a04cd3 | 2022-12-12 19:15:22 +0500 | [diff] [blame] | 23 | print("Generating matrix for type '{}'.".format(ref_name)) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 24 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 25 | def clean_ssl(ssl): |
| 26 | return ssl.replace("_VERSION", "").lower() |
| 27 | |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 28 | def determine_latest_openssl(ssl): |
Ilya Shipitsin | 6fbc35f | 2022-12-22 22:27:37 +0600 | [diff] [blame^] | 29 | 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 Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 32 | 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 Shipitsin | 14711bd | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 39 | return "OPENSSL_VERSION={}".format(latest_tag[8:]) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 40 | |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 41 | def 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 Shipitsin | 14711bd | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 47 | return "LIBRESSL_VERSION={}".format(l) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 48 | |
| 49 | def clean_compression(compression): |
| 50 | return compression.replace("USE_", "").lower() |
| 51 | |
| 52 | |
| 53 | def get_asan_flags(cc): |
Ilya Shipitsin | cfba1f9 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 54 | return [ |
| 55 | "USE_OBSOLETE_LINKER=1", |
| 56 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 57 | 'LDFLAGS="-fsanitize=address"', |
| 58 | 'CPU_CFLAGS.generic="-O1"', |
| 59 | ] |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 60 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 61 | |
| 62 | matrix = [] |
| 63 | |
| 64 | # Ubuntu |
| 65 | |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 66 | os = "ubuntu-latest" if "haproxy-" not in ref_name else "ubuntu-22.04" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 67 | TARGET = "linux-glibc" |
| 68 | for CC in ["gcc", "clang"]: |
| 69 | matrix.append( |
| 70 | { |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 71 | "name": "{}, {}, no features".format(os, CC), |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 72 | "os": os, |
| 73 | "TARGET": TARGET, |
| 74 | "CC": CC, |
| 75 | "FLAGS": [], |
| 76 | } |
| 77 | ) |
| 78 | |
| 79 | matrix.append( |
| 80 | { |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 81 | "name": "{}, {}, all features".format(os, CC), |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 82 | "os": os, |
| 83 | "TARGET": TARGET, |
| 84 | "CC": CC, |
| 85 | "FLAGS": [ |
| 86 | "USE_ZLIB=1", |
Willy Tarreau | ed17ca7 | 2021-09-12 07:01:36 +0200 | [diff] [blame] | 87 | "USE_OT=1", |
Ilya Shipitsin | b9e3fb7 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 88 | "OT_INC=${HOME}/opt-ot/include", |
| 89 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 75c95aa | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 90 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 91 | "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 Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 97 | "WURFL_INC=addons/wurfl/dummy", |
| 98 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 99 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 100 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 101 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 102 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 103 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 104 | ], |
| 105 | } |
| 106 | ) |
| 107 | |
Ilya Shipitsin | 6dedeb7 | 2022-12-14 18:18:20 +0500 | [diff] [blame] | 108 | # ASAN |
| 109 | |
| 110 | matrix.append( |
| 111 | { |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 112 | "name": "{}, {}, ASAN, all features".format(os, CC), |
Ilya Shipitsin | 6dedeb7 | 2022-12-14 18:18:20 +0500 | [diff] [blame] | 113 | "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 Duesterhus | 762b1fd | 2021-08-14 14:36:55 +0200 | [diff] [blame] | 140 | for compression in ["USE_ZLIB=1"]: |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 141 | matrix.append( |
| 142 | { |
| 143 | "name": "{}, {}, gz={}".format( |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 144 | os, CC, clean_compression(compression) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 145 | ), |
| 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 Lallemand | 393e4e4 | 2022-12-12 08:52:03 +0100 | [diff] [blame] | 156 | "OPENSSL_VERSION=1.1.1s", |
Ilya Shipitsin | d69d65a | 2021-11-18 18:27:57 +0500 | [diff] [blame] | 157 | "QUICTLS=yes", |
Willy Tarreau | 30ee296 | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 158 | # "BORINGSSL=yes", |
Ilya Shipitsin | 4a04cd3 | 2022-12-12 19:15:22 +0500 | [diff] [blame] | 159 | ] + (["OPENSSL_VERSION=latest", "LIBRESSL_VERSION=latest"] if "haproxy-" not in ref_name else []): |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 160 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | 6397c7c | 2022-11-02 11:59:37 +0500 | [diff] [blame] | 161 | if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes" or "LIBRESSL" in ssl: |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 162 | flags.append("USE_QUIC=1") |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 163 | if ssl != "stock": |
| 164 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 165 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | 94cd779 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 166 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 167 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 7b893c2 | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 168 | if "OPENSSL" in ssl and "latest" in ssl: |
| 169 | ssl = determine_latest_openssl(ssl) |
| 170 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 171 | matrix.append( |
| 172 | { |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 173 | "name": "{}, {}, ssl={}".format(os, CC, clean_ssl(ssl)), |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 174 | "os": os, |
| 175 | "TARGET": TARGET, |
| 176 | "CC": CC, |
| 177 | "ssl": ssl, |
| 178 | "FLAGS": flags, |
| 179 | } |
| 180 | ) |
| 181 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 182 | # macOS |
| 183 | |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 184 | os = "macos-latest" if "haproxy-" not in ref_name else "macos-12" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 185 | TARGET = "osx" |
| 186 | for CC in ["clang"]: |
| 187 | matrix.append( |
| 188 | { |
Ilya Shipitsin | f5994fc | 2022-12-14 18:23:24 +0500 | [diff] [blame] | 189 | "name": "{}, {}, no features".format(os, CC), |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 190 | "os": os, |
| 191 | "TARGET": TARGET, |
| 192 | "CC": CC, |
| 193 | "FLAGS": [], |
| 194 | } |
| 195 | ) |
| 196 | |
| 197 | # Print matrix |
| 198 | |
| 199 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 200 | |
Tim Duesterhus | 8a03bf4 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 201 | if 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) |