Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions tools/ci/add-apt-keys.sh
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions tools/ci/add-apt-repositories.sh
Original file line number Diff line number Diff line change
@@ -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
Loading