2021-06-08 13:14:35 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
|
|
|
|
# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version
|
|
|
|
# 2 of the License, or (at your option) any later version.
|
|
|
|
|
2022-12-29 16:40:25 +00:00
|
|
|
import functools
|
2020-07-28 21:00:35 +00:00
|
|
|
import json
|
2022-12-29 16:40:29 +00:00
|
|
|
import re
|
2020-11-19 23:16:00 +00:00
|
|
|
import sys
|
2022-05-13 16:59:38 +00:00
|
|
|
import urllib.request
|
2022-10-14 17:46:06 +00:00
|
|
|
from os import environ
|
2020-11-19 23:16:00 +00:00
|
|
|
|
|
|
|
if len(sys.argv) == 2:
|
2022-12-12 14:15:22 +00:00
|
|
|
ref_name = sys.argv[1]
|
2020-11-19 23:16:00 +00:00
|
|
|
else:
|
2022-12-12 14:15:22 +00:00
|
|
|
print("Usage: {} <ref_name>".format(sys.argv[0]), file=sys.stderr)
|
2020-11-19 23:16:00 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2022-12-29 16:40:24 +00:00
|
|
|
print("Generating matrix for branch '{}'.".format(ref_name))
|
2020-07-28 21:00:35 +00:00
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
def clean_ssl(ssl):
|
|
|
|
return ssl.replace("_VERSION", "").lower()
|
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
|
2022-12-29 16:40:25 +00:00
|
|
|
@functools.lru_cache(5)
|
2022-05-20 18:02:38 +00:00
|
|
|
def determine_latest_openssl(ssl):
|
2022-12-29 16:40:26 +00:00
|
|
|
headers = {}
|
2022-12-29 16:40:29 +00:00
|
|
|
if environ.get("GITHUB_TOKEN") is not None:
|
|
|
|
headers["Authorization"] = "token {}".format(environ.get("GITHUB_TOKEN"))
|
|
|
|
request = urllib.request.Request(
|
|
|
|
"https://api.github.com/repos/openssl/openssl/tags", headers=headers
|
|
|
|
)
|
2023-04-26 18:39:39 +00:00
|
|
|
try:
|
|
|
|
openssl_tags = urllib.request.urlopen(request)
|
|
|
|
except:
|
|
|
|
return "OPENSSL_VERSION=failed_to_detect"
|
2022-12-29 16:40:29 +00:00
|
|
|
tags = json.loads(openssl_tags.read().decode("utf-8"))
|
|
|
|
latest_tag = ""
|
2022-05-20 18:02:38 +00:00
|
|
|
for tag in tags:
|
2022-12-29 16:40:29 +00:00
|
|
|
name = tag["name"]
|
2022-05-20 18:02:38 +00:00
|
|
|
if "openssl-" in name:
|
|
|
|
if name > latest_tag:
|
2022-12-29 16:40:29 +00:00
|
|
|
latest_tag = name
|
2022-10-11 07:10:57 +00:00
|
|
|
return "OPENSSL_VERSION={}".format(latest_tag[8:])
|
2022-05-20 18:02:38 +00:00
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
|
2022-12-29 16:40:25 +00:00
|
|
|
@functools.lru_cache(5)
|
2022-05-13 16:59:38 +00:00
|
|
|
def determine_latest_libressl(ssl):
|
2023-04-26 18:39:39 +00:00
|
|
|
try:
|
|
|
|
libressl_download_list = urllib.request.urlopen(
|
|
|
|
"https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/"
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
return "LIBRESSL_VERSION=failed_to_detect"
|
2022-05-13 16:59:38 +00:00
|
|
|
for line in libressl_download_list.readlines():
|
|
|
|
decoded_line = line.decode("utf-8")
|
|
|
|
if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
|
2022-12-29 16:40:29 +00:00
|
|
|
l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
|
2022-10-11 07:10:57 +00:00
|
|
|
return "LIBRESSL_VERSION={}".format(l)
|
2020-07-28 21:00:35 +00:00
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
def clean_compression(compression):
|
|
|
|
return compression.replace("USE_", "").lower()
|
|
|
|
|
|
|
|
|
|
|
|
def get_asan_flags(cc):
|
2022-07-02 05:30:28 +00:00
|
|
|
return [
|
|
|
|
"USE_OBSOLETE_LINKER=1",
|
|
|
|
'DEBUG_CFLAGS="-g -fsanitize=address"',
|
|
|
|
'LDFLAGS="-fsanitize=address"',
|
|
|
|
'CPU_CFLAGS.generic="-O1"',
|
|
|
|
]
|
2020-07-28 21:00:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
matrix = []
|
|
|
|
|
|
|
|
# Ubuntu
|
|
|
|
|
2022-12-29 16:40:26 +00:00
|
|
|
if "haproxy-" in ref_name:
|
|
|
|
os = "ubuntu-22.04"
|
|
|
|
else:
|
|
|
|
os = "ubuntu-latest"
|
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
TARGET = "linux-glibc"
|
|
|
|
for CC in ["gcc", "clang"]:
|
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-14 13:23:24 +00:00
|
|
|
"name": "{}, {}, no features".format(os, CC),
|
2020-07-28 21:00:35 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"FLAGS": [],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-14 13:23:24 +00:00
|
|
|
"name": "{}, {}, all features".format(os, CC),
|
2020-07-28 21:00:35 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"FLAGS": [
|
|
|
|
"USE_ZLIB=1",
|
2021-09-12 05:01:36 +00:00
|
|
|
"USE_OT=1",
|
2022-01-13 06:36:28 +00:00
|
|
|
"OT_INC=${HOME}/opt-ot/include",
|
|
|
|
"OT_LIB=${HOME}/opt-ot/lib",
|
2021-05-18 09:46:43 +00:00
|
|
|
"OT_RUNPATH=1",
|
2020-07-28 21:00:35 +00:00
|
|
|
"USE_PCRE=1",
|
|
|
|
"USE_PCRE_JIT=1",
|
|
|
|
"USE_LUA=1",
|
|
|
|
"USE_OPENSSL=1",
|
|
|
|
"USE_SYSTEMD=1",
|
|
|
|
"USE_WURFL=1",
|
2021-04-02 14:39:44 +00:00
|
|
|
"WURFL_INC=addons/wurfl/dummy",
|
|
|
|
"WURFL_LIB=addons/wurfl/dummy",
|
2020-07-28 21:00:35 +00:00
|
|
|
"USE_DEVICEATLAS=1",
|
2021-04-02 14:19:39 +00:00
|
|
|
"DEVICEATLAS_SRC=addons/deviceatlas/dummy",
|
2021-04-02 13:35:19 +00:00
|
|
|
"USE_PROMEX=1",
|
2020-11-26 15:59:42 +00:00
|
|
|
"USE_51DEGREES=1",
|
2021-04-02 14:12:32 +00:00
|
|
|
"51DEGREES_SRC=addons/51degrees/dummy/pattern",
|
2020-07-28 21:00:35 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
# ASAN
|
2022-12-14 13:18:20 +00:00
|
|
|
|
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-14 13:23:24 +00:00
|
|
|
"name": "{}, {}, ASAN, all features".format(os, CC),
|
2022-12-14 13:18:20 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"FLAGS": get_asan_flags(CC)
|
|
|
|
+ [
|
|
|
|
"USE_ZLIB=1",
|
|
|
|
"USE_OT=1",
|
|
|
|
"OT_INC=${HOME}/opt-ot/include",
|
|
|
|
"OT_LIB=${HOME}/opt-ot/lib",
|
|
|
|
"OT_RUNPATH=1",
|
|
|
|
"USE_PCRE=1",
|
|
|
|
"USE_PCRE_JIT=1",
|
|
|
|
"USE_LUA=1",
|
|
|
|
"USE_OPENSSL=1",
|
|
|
|
"USE_SYSTEMD=1",
|
|
|
|
"USE_WURFL=1",
|
|
|
|
"WURFL_INC=addons/wurfl/dummy",
|
|
|
|
"WURFL_LIB=addons/wurfl/dummy",
|
|
|
|
"USE_DEVICEATLAS=1",
|
|
|
|
"DEVICEATLAS_SRC=addons/deviceatlas/dummy",
|
|
|
|
"USE_PROMEX=1",
|
|
|
|
"USE_51DEGREES=1",
|
|
|
|
"51DEGREES_SRC=addons/51degrees/dummy/pattern",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-08-14 12:36:55 +00:00
|
|
|
for compression in ["USE_ZLIB=1"]:
|
2020-07-28 21:00:35 +00:00
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-29 16:40:29 +00:00
|
|
|
"name": "{}, {}, gz={}".format(os, CC, clean_compression(compression)),
|
2020-07-28 21:00:35 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"FLAGS": [compression],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-12-29 16:40:26 +00:00
|
|
|
ssl_versions = [
|
2020-07-28 21:00:35 +00:00
|
|
|
"stock",
|
|
|
|
"OPENSSL_VERSION=1.0.2u",
|
2022-12-12 07:52:03 +00:00
|
|
|
"OPENSSL_VERSION=1.1.1s",
|
2021-11-18 13:27:57 +00:00
|
|
|
"QUICTLS=yes",
|
2022-12-29 16:40:29 +00:00
|
|
|
# "BORINGSSL=yes",
|
2022-12-29 16:40:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if "haproxy-" not in ref_name:
|
|
|
|
ssl_versions = ssl_versions + [
|
|
|
|
"OPENSSL_VERSION=latest",
|
|
|
|
"LIBRESSL_VERSION=latest",
|
|
|
|
]
|
|
|
|
|
|
|
|
for ssl in ssl_versions:
|
2020-07-28 21:00:35 +00:00
|
|
|
flags = ["USE_OPENSSL=1"]
|
2022-11-02 06:59:37 +00:00
|
|
|
if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes" or "LIBRESSL" in ssl:
|
2021-05-09 16:27:28 +00:00
|
|
|
flags.append("USE_QUIC=1")
|
2020-07-28 21:00:35 +00:00
|
|
|
if ssl != "stock":
|
|
|
|
flags.append("SSL_LIB=${HOME}/opt/lib")
|
|
|
|
flags.append("SSL_INC=${HOME}/opt/include")
|
2022-05-13 16:59:38 +00:00
|
|
|
if "LIBRESSL" in ssl and "latest" in ssl:
|
|
|
|
ssl = determine_latest_libressl(ssl)
|
2022-05-20 18:02:38 +00:00
|
|
|
if "OPENSSL" in ssl and "latest" in ssl:
|
|
|
|
ssl = determine_latest_openssl(ssl)
|
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-14 13:23:24 +00:00
|
|
|
"name": "{}, {}, ssl={}".format(os, CC, clean_ssl(ssl)),
|
2020-07-28 21:00:35 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"ssl": ssl,
|
|
|
|
"FLAGS": flags,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# macOS
|
|
|
|
|
2022-12-29 16:40:26 +00:00
|
|
|
if "haproxy-" in ref_name:
|
|
|
|
os = "macos-12"
|
|
|
|
else:
|
|
|
|
os = "macos-latest"
|
|
|
|
|
2020-07-28 21:00:35 +00:00
|
|
|
TARGET = "osx"
|
|
|
|
for CC in ["clang"]:
|
|
|
|
matrix.append(
|
|
|
|
{
|
2022-12-14 13:23:24 +00:00
|
|
|
"name": "{}, {}, no features".format(os, CC),
|
2020-07-28 21:00:35 +00:00
|
|
|
"os": os,
|
|
|
|
"TARGET": TARGET,
|
|
|
|
"CC": CC,
|
|
|
|
"FLAGS": [],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Print matrix
|
|
|
|
|
|
|
|
print(json.dumps(matrix, indent=4, sort_keys=True))
|
|
|
|
|
2022-12-29 16:40:29 +00:00
|
|
|
if environ.get("GITHUB_OUTPUT") is not None:
|
|
|
|
with open(environ.get("GITHUB_OUTPUT"), "a") as f:
|
2022-10-14 17:46:06 +00:00
|
|
|
print("matrix={}".format(json.dumps({"include": matrix})), file=f)
|