ci: switch from Cirrus to Github Actions
This commit is contained in:
parent
7d33e9d5e9
commit
5516bcc43b
9 changed files with 130 additions and 50 deletions
|
|
@ -28,7 +28,9 @@ fi
|
|||
|
||||
## Build
|
||||
|
||||
if [[ -v CIRRUS_CI ]]; then
|
||||
if [[ -v GITHUB_ACTIONS ]]; then
|
||||
# Avoid cachix warning message
|
||||
mkdir -p ~/.config/nix && touch ~/.config/nix/nix.conf
|
||||
cachix use "$cachixCache"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,17 @@
|
|||
# This script can also be run locally for testing:
|
||||
# ./build.sh <scenario>
|
||||
#
|
||||
# When variable CIRRUS_CI is unset, this script leaves no persistent traces on the host system.
|
||||
# When variable GITHUB_ACTIONS is unset, this script leaves no persistent traces on the host system.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
scenario=$1
|
||||
|
||||
if [[ -v CIRRUS_CI ]]; then
|
||||
if [[ -v GITHUB_ACTIONS ]]; then
|
||||
if [[ ! -e /dev/kvm ]]; then
|
||||
>&2 echo "No KVM available on VM host."
|
||||
exit 1
|
||||
fi
|
||||
# Enable KVM access for nixbld users
|
||||
chmod o+rw /dev/kvm
|
||||
fi
|
||||
|
||||
cd "${BASH_SOURCE[0]%/*}"
|
||||
|
|
|
|||
52
test/ci/build_test_drivers.sh
Executable file
52
test/ci/build_test_drivers.sh
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "${BASH_SOURCE[0]%/*}"
|
||||
|
||||
cachixCache=nix-bitcoin
|
||||
|
||||
# Declare variables for shellcheck
|
||||
driverDrvs=()
|
||||
drivers=()
|
||||
scenarioTests=()
|
||||
|
||||
# Call ./test-info.nix
|
||||
testInfo=$(time nix eval --raw --show-trace ../..#ciTestInfo)
|
||||
# This sets variables `driverDrvs`, `drivers`, `scenarioTests`
|
||||
eval "$testInfo"
|
||||
|
||||
if nix path-info --store "https://${cachixCache}.cachix.org" "${scenarioTests[@]}" &>/dev/null; then
|
||||
echo
|
||||
echo "All tests have already been built successfully:"
|
||||
printf '%s\n' "${scenarioTests[@]}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "run_scenario_tests=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
## Build test drivers
|
||||
|
||||
if nix path-info --store "https://${cachixCache}.cachix.org" "${drivers[@]}" &>/dev/null; then
|
||||
echo
|
||||
echo "All test drivers have already been built successfully:"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -v GITHUB_ACTIONS ]]; then
|
||||
# Avoid cachix warning message
|
||||
mkdir -p ~/.config/nix && touch ~/.config/nix/nix.conf
|
||||
cachix use "$cachixCache"
|
||||
fi
|
||||
|
||||
if [[ $CACHIX_SIGNING_KEY ]]; then
|
||||
# Speed up task by uploading store paths as soon as they are created
|
||||
buildCmd="cachix watch-exec $cachixCache nix -- build"
|
||||
else
|
||||
buildCmd="nix build"
|
||||
fi
|
||||
|
||||
$buildCmd --no-link --print-build-logs "${driverDrvs[@]}"
|
||||
|
||||
if [[ $CACHIX_SIGNING_KEY ]]; then
|
||||
cachix push "$cachixCache" "${drivers[@]}"
|
||||
fi
|
||||
22
test/ci/test-info.nix
Normal file
22
test/ci/test-info.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
pkgs: instantiateTests:
|
||||
|
||||
let
|
||||
# `instantiateTests` prints the test name before evaluating, which is useful for debugging
|
||||
ciTests = instantiateTests [
|
||||
"default"
|
||||
"netns"
|
||||
"netnsRegtest"
|
||||
];
|
||||
drivers = map (x: x.driver) ciTests;
|
||||
driverDrvs = map (x: ''"${x.drvPath}^*"'') drivers;
|
||||
in ''
|
||||
driverDrvs=(
|
||||
${builtins.concatStringsSep "\n" driverDrvs}
|
||||
)
|
||||
drivers=(
|
||||
${builtins.concatStringsSep "\n" drivers}
|
||||
)
|
||||
scenarioTests=(
|
||||
${builtins.concatStringsSep "\n" ciTests}
|
||||
)
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue