From 9977fa69afeb04e8c14fc8217bff5ae2699f32ae Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 11 Dec 2020 13:26:10 +0100 Subject: [PATCH] ci: use run-tests.sh --- ci/build.nix | 12 ---------- ci/build.sh | 6 ++--- test/run-tests.sh | 58 +++++++++++++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 ci/build.nix diff --git a/ci/build.nix b/ci/build.nix deleted file mode 100644 index 16cb6a2..0000000 --- a/ci/build.nix +++ /dev/null @@ -1,12 +0,0 @@ -let - pkgs = import {}; - 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) diff --git a/ci/build.sh b/ci/build.sh index a1f8653..3c3f2e1 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -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 diff --git a/test/run-tests.sh b/test/run-tests.sh index 7703fa9..c3fd248 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -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 <&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 <