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))" echo "$NIX_PATH ($(nix eval --raw nixpkgs.lib.version))"
if [[ $scenario ]]; then if [[ $scenario ]]; then
buildExpr=$(../test/run-tests.sh --scenario $scenario exprForCI) testArgs="--scenario $scenario"
else else
buildExpr="import ./build.nix" testArgs=pkgsUnstable
fi 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= scenario=
outLinkPrefix= outLinkPrefix=
ciBuild=
while :; do while :; do
case $1 in case $1 in
--scenario|-s) --scenario|-s)
@ -66,6 +67,10 @@ while :; do
exit 1 exit 1
fi fi
;; ;;
--ci)
shift
ciBuild=1
;;
*) *)
break break
esac esac
@ -135,12 +140,16 @@ container() {
doBuild() { doBuild() {
name=$1 name=$1
shift shift
if [[ $ciBuild ]]; then
"$scriptDir/../ci/build-to-cachix.sh" "$@"
else
if [[ $outLinkPrefix ]]; then if [[ $outLinkPrefix ]]; then
outLink="--out-link $outLinkPrefix-$name" outLink="--out-link $outLinkPrefix-$name"
else else
outLink=--no-out-link outLink=--no-out-link
fi fi
nix-build $outLink "$@" nix-build $outLink "$@"
fi
} }
# Run the test by building the test derivation # Run the test by building the test derivation
@ -148,9 +157,12 @@ buildTest() {
vmTestNixExpr | doBuild $scenario $outLinkArg "$@" - vmTestNixExpr | doBuild $scenario $outLinkArg "$@" -
} }
# On continuous integration nodes there are few other processes running alongside the vmTestNixExpr() {
# test, so use more memory here for maximum performance. extraQEMUOpts=
exprForCI() {
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 memoryMiB=4096
memTotalKiB=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) memTotalKiB=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
memAvailableKiB=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo) memAvailableKiB=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
@ -163,11 +175,9 @@ exprForCI() {
# VMX is usually not available on CI nodes due to recursive virtualisation. # VMX is usually not available on CI nodes due to recursive virtualisation.
# Explicitly disable VMX, otherwise QEMU 4.20 fails with message # Explicitly disable VMX, otherwise QEMU 4.20 fails with message
# "error: failed to set MSR 0x48b to 0x159ff00000000" # "error: failed to set MSR 0x48b to 0x159ff00000000"
vmTestNixExpr "-cpu host,-vmx" extraQEMUOpts="-cpu host,-vmx"
} fi
vmTestNixExpr() {
extraQEMUOpts="$1"
cat <<EOF cat <<EOF
((import "$scriptDir/tests.nix" { scenario = "$scenario"; }).vm {}).overrideAttrs (old: rec { ((import "$scriptDir/tests.nix" { scenario = "$scenario"; }).vm {}).overrideAttrs (old: rec {
buildCommand = '' buildCommand = ''