ci: use run-tests.sh

This commit is contained in:
Erik Arvstedt 2020-12-11 13:26:10 +01:00
parent a82f0f5f48
commit 9977fa69af
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
3 changed files with 37 additions and 39 deletions

View File

@ -1,12 +0,0 @@
let
pkgs = import <nixpkgs> {};
nbPkgs = import ../pkgs { inherit pkgs; };
ciPkgs = with nbPkgs; [
electrs
elementsd
hwi
joinmarket
lightning-loop
];
in
pkgs.writeText "ci-pkgs" (pkgs.lib.concatMapStringsSep "\n" toString ciPkgs)

View File

@ -21,9 +21,9 @@ fi
echo "$NIX_PATH ($(nix eval --raw nixpkgs.lib.version))"
if [[ $scenario ]]; then
buildExpr=$(../test/run-tests.sh --scenario $scenario exprForCI)
testArgs="--scenario $scenario"
else
buildExpr="import ./build.nix"
testArgs=pkgsUnstable
fi
"${BASH_SOURCE[0]%/*}/build-to-cachix.sh" -E "$buildExpr"
"${BASH_SOURCE[0]%/*}/../test/run-tests.sh" --ci $testArgs

View File

@ -44,6 +44,7 @@ scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
scenario=
outLinkPrefix=
ciBuild=
while :; do
case $1 in
--scenario|-s)
@ -66,6 +67,10 @@ while :; do
exit 1
fi
;;
--ci)
shift
ciBuild=1
;;
*)
break
esac
@ -135,12 +140,16 @@ container() {
doBuild() {
name=$1
shift
if [[ $outLinkPrefix ]]; then
outLink="--out-link $outLinkPrefix-$name"
if [[ $ciBuild ]]; then
"$scriptDir/../ci/build-to-cachix.sh" "$@"
else
outLink=--no-out-link
if [[ $outLinkPrefix ]]; then
outLink="--out-link $outLinkPrefix-$name"
else
outLink=--no-out-link
fi
nix-build $outLink "$@"
fi
nix-build $outLink "$@"
}
# Run the test by building the test derivation
@ -148,27 +157,28 @@ buildTest() {
vmTestNixExpr | doBuild $scenario $outLinkArg "$@" -
}
# On continuous integration nodes there are few other processes running alongside the
# test, so use more memory here for maximum performance.
exprForCI() {
memoryMiB=4096
memTotalKiB=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
memAvailableKiB=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
# Round down to nearest multiple of 50 MiB for improved test build caching
((memAvailableMiB = memAvailableKiB / (1024 * 50) * 50))
((memAvailableMiB < memoryMiB)) && memoryMiB=$memAvailableMiB
>&2 echo "VM stats: CPUs: $numCPUs, memory: $memoryMiB MiB"
>&2 echo "Host memory total: $((memTotalKiB / 1024)) MiB, available: $memAvailableMiB MiB"
# VMX is usually not available on CI nodes due to recursive virtualisation.
# Explicitly disable VMX, otherwise QEMU 4.20 fails with message
# "error: failed to set MSR 0x48b to 0x159ff00000000"
vmTestNixExpr "-cpu host,-vmx"
}
vmTestNixExpr() {
extraQEMUOpts="$1"
cat <<EOF
extraQEMUOpts=
if [[ $ciBuild ]]; then
# On continuous integration nodes there are few other processes running alongside the
# test, so use more memory here for maximum performance.
memoryMiB=4096
memTotalKiB=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
memAvailableKiB=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
# Round down to nearest multiple of 50 MiB for improved test build caching
((memAvailableMiB = memAvailableKiB / (1024 * 50) * 50))
((memAvailableMiB < memoryMiB)) && memoryMiB=$memAvailableMiB
>&2 echo "VM stats: CPUs: $numCPUs, memory: $memoryMiB MiB"
>&2 echo "Host memory total: $((memTotalKiB / 1024)) MiB, available: $memAvailableMiB MiB"
# VMX is usually not available on CI nodes due to recursive virtualisation.
# Explicitly disable VMX, otherwise QEMU 4.20 fails with message
# "error: failed to set MSR 0x48b to 0x159ff00000000"
extraQEMUOpts="-cpu host,-vmx"
fi
cat <<EOF
((import "$scriptDir/tests.nix" { scenario = "$scenario"; }).vm {}).overrideAttrs (old: rec {
buildCommand = ''
export QEMU_OPTS="-smp $numCPUs -m $memoryMiB $extraQEMUOpts"