From 54f25b2a17e109fa959f1e0813960c604d42a681 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Mon, 23 Nov 2026 22:23:03 +0000 Subject: [PATCH] Cache successful networked integration checks Assisted-by: Replit --- flake.nix | 4 ++++ nix-ci.nix | 6 ------ nix/test-suite-check.nix | 45 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) delete mode 100644 nix-ci.nix create mode 100644 nix/test-suite-check.nix diff --git a/flake.nix b/flake.nix index 5777fa3e..d2cd3994 100644 --- a/flake.nix +++ b/flake.nix @@ -43,5 +43,9 @@ checks.x86_64-linux.lint = import ./nix/lint { pkgs = nixpkgs.legacyPackages.x86_64-linux; }; + checks.x86_64-linux.test-suite = import ./nix/test-suite-check.nix { + inherit nixpkgs nix-editor; + system = "x86_64-linux"; + }; }; } diff --git a/nix-ci.nix b/nix-ci.nix deleted file mode 100644 index 739275cc..00000000 --- a/nix-ci.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - test.test-suite = { - package = "packages.x86_64-linux.test-suite"; - in-repo = true; - }; -} diff --git a/nix/test-suite-check.nix b/nix/test-suite-check.nix new file mode 100644 index 00000000..055d1810 --- /dev/null +++ b/nix/test-suite-check.nix @@ -0,0 +1,45 @@ +{ nixpkgs, nix-editor, system }: +let + pkgs = nixpkgs.legacyPackages.${system}; + src = pkgs.lib.fileset.toSource { + root = ../.; + fileset = pkgs.lib.fileset.unions [ + ../cmd + ../internal + ../resources + ../test-suite + ../go.mod + ../go.sum + ../Makefile + ]; + }; + # The release version includes the Git revision; unrelated commits should + # not invalidate the test binary or the check. + packages = import ./default.nix { + inherit nixpkgs nix-editor system; + self = src; + rev = "0.0.0-test"; + }; + suite = pkgs.runCommand "upm-integration-check" { + nativeBuildInputs = [ pkgs.cacert ]; + } '' + export HOME="$TMPDIR/home" + mkdir -p "$HOME" + cp -R ${src} source + chmod -R u+w source + cd source + ${packages.test-suite}/bin/upm-test-suite + ''; + # A fixed-output build may use the network. Key its only output to the + # ordinary derivation so changing any declared input invalidates success. + marker = builtins.unsafeDiscardStringContext (builtins.baseNameOf suite.drvPath); +in +suite.overrideAttrs (old: { + outputHashAlgo = "sha256"; + outputHashMode = "flat"; + outputHash = builtins.hashString "sha256" marker; + preferHashedMirrors = false; + buildCommand = old.buildCommand + '' + printf '%s' '${marker}' > "$out" + ''; +})