From 34b4cdbc26644634114b4b9cd410b4719ec5e30f Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 2 May 2026 12:27:03 +0200 Subject: [PATCH] GHA: Add GCC 16 to CI --- .github/workflows/unit-tests.yml | 7 +++++ tools/ci/add-apt-keys.sh | 47 ++++++++++++++++++++++++++++++++ tools/ci/add-apt-repositories.sh | 34 +++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100755 tools/ci/add-apt-keys.sh create mode 100755 tools/ci/add-apt-repositories.sh diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 799b16d52c..1c6fd096ac 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -108,6 +108,7 @@ jobs: # Use (compiler) default C++ 17 standard # Use default cmake - { compiler: gcc-14, os: ubuntu-24.04, type: Debug } + - { compiler: gcc-16, os: ubuntu-24.04, type: Debug, "apt_key": "0x1E9377A2BA9EF27F", "apt_repo": "ppa:ubuntu-toolchain-r/test" } - { compiler: clang-18, os: ubuntu-24.04, type: Debug, externalSanitizer: true } - { compiler: clang-21, os: ubuntu-latest, type: Debug, init_llvm: true} @@ -179,6 +180,12 @@ jobs: clang_version=${compiler#clang-*} wget -qO- "https://apt.llvm.org/llvm.sh" | sudo bash -s -- "${clang_version}" fi + if [[ -n "${{matrix.apt_key}}" ]]; then + tools/ci/add-apt-keys.sh "${{matrix.apt_key}}" + fi + if [[ -n "${{matrix.apt_repo}}" ]]; then + tools/ci/add-apt-repositories.sh "${{matrix.apt_repo}}" + fi sudo apt-get -o Acquire::Retries=5 update sudo apt-get -o Acquire::Retries=5 -y -q --no-install-suggests --no-install-recommends install gettext libsdl2-dev libsdl2-mixer-dev libcurl4-openssl-dev libbz2-dev libminiupnpc-dev liblua5.2-dev $compiler fi diff --git a/tools/ci/add-apt-keys.sh b/tools/ci/add-apt-keys.sh new file mode 100755 index 0000000000..963aa0cc9b --- /dev/null +++ b/tools/ci/add-apt-keys.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Copyright 2023-2024 Alexander Grund +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +# Add APT keys +# - Each argument should be a key URL or a key ID (0x...) +# - $NET_RETRY_COUNT is the amount of retries attempted + +set -eu + +if curl --retry-all-errors 2>&1 | grep -iq unknown; then + # --retry-all-errors not available + curl_extra_options="" +else + curl_extra_options="--retry-all-errors" +fi + +function do_add_key +{ + key_url=$1 + # If a keyserver URL (e.g. http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F) + # use the hash as the filename, + # if it is an ID, e.g. 0x1E9377A2BA9EF27F, use it as the filename, and http://keyserver.ubuntu.com/pks/lookup as the URL + # else assume the URL contains a filename, e.g. https://apt.llvm.org/llvm-snapshot.gpg.key + if [[ "$key_url" =~ .*keyserver.*search=0x([A-F0-9]+) ]]; then + keyfilename="${BASH_REMATCH[1]}.key" + elif [[ $key_url =~ ^0x[A-F0-9]+$ ]]; then + keyfilename=${key_url#0x}.key + key_server="keyserver.boost.org" + key_url="https://$key_server/pks/lookup?op=get&search=$key_url" + else + keyfilename=$(basename -s .key "$key_url") + fi + echo -e "\tDownloading APT key from '$key_url' to '$keyfilename'" + if ! curl ${curl_extra_options} --connect-timeout 15 -sSL --retry "${NET_RETRY_COUNT:-5}" "$key_url" | sudo gpg --dearmor -o "/etc/apt/trusted.gpg.d/${keyfilename}"; then + echo "Failed downloading $keyfilename" + return 1 + fi +} + +for key_url in "$@"; do + [[ -n $key_url ]] || continue + do_add_key "$key_url" +done diff --git a/tools/ci/add-apt-repositories.sh b/tools/ci/add-apt-repositories.sh new file mode 100755 index 0000000000..e31fb3ea7a --- /dev/null +++ b/tools/ci/add-apt-repositories.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2023 Sam Darwin +# Copyright 2023-2024 Alexander Grund +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +# Add APT keys, i.e. wrapper around add-apt-repository +# - Each argument should be a repository name +# - $NET_RETRY_COUNT is the amount of retries attempted + +set -eu + +function do_add_repository { + name=$1 + echo -e "\tAdding repository $name" + for i in $(seq "${NET_RETRY_COUNT:-3}"); do + if [[ $i -ne 1 ]]; then + sleep 10 + echo -e "\tRetrying" + fi + if sudo -E apt-add-repository -y "$name"; then + return 0 + fi + done + echo "Failed adding $name" + return 1 # Failed +} + +for repo_name in "$@"; do + [[ -n $repo_name ]] || continue + do_add_repository "$repo_name" +done