From c9adf12e72941a5b8a1088f20c03476c0c069dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 27 Aug 2023 10:05:48 +0200 Subject: [PATCH] reduce impure tests to just instantiate the template --- .gitea/workflows/checks-impure.yaml | 4 +-- checks/flake-module.nix | 2 +- .../{integration => impure}/flake-module.nix | 28 ++++++------------- 3 files changed, 12 insertions(+), 22 deletions(-) rename checks/{integration => impure}/flake-module.nix (54%) diff --git a/.gitea/workflows/checks-impure.yaml b/.gitea/workflows/checks-impure.yaml index badacf0e..6e627ab4 100644 --- a/.gitea/workflows/checks-impure.yaml +++ b/.gitea/workflows/checks-impure.yaml @@ -1,4 +1,4 @@ -name: checks-integration +name: checks-impure on: pull_request: push: @@ -8,4 +8,4 @@ jobs: runs-on: nix steps: - uses: actions/checkout@v3 - - run: nix run .#checks-impure + - run: nix run .#impure-checks diff --git a/checks/flake-module.nix b/checks/flake-module.nix index 631aef66..16b52813 100644 --- a/checks/flake-module.nix +++ b/checks/flake-module.nix @@ -1,6 +1,6 @@ { self, ... }: { imports = [ - ./integration/flake-module.nix + ./impure/flake-module.nix ]; perSystem = { pkgs, lib, self', ... }: { checks = diff --git a/checks/integration/flake-module.nix b/checks/impure/flake-module.nix similarity index 54% rename from checks/integration/flake-module.nix rename to checks/impure/flake-module.nix index abc143e6..5a7c8d3d 100644 --- a/checks/integration/flake-module.nix +++ b/checks/impure/flake-module.nix @@ -1,17 +1,16 @@ { self, ... }: { - perSystem = { pkgs, lib, self', ... }: + perSystem = { pkgs, lib, ... }: let - integrationTests = { - check-clan-create = pkgs.writeShellScriptBin "check-clan-init" '' + impureChecks = { + check-clan-template = pkgs.writeShellScriptBin "check-clan-template" '' #!${pkgs.bash}/bin/bash set -euo pipefail export TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d) trap "${pkgs.coreutils}/bin/chmod -R +w '$TMPDIR'; ${pkgs.coreutils}/bin/rm -rf '$TMPDIR'" EXIT export PATH="${lib.makeBinPath [ - pkgs.git - pkgs.gnugrep + pkgs.gitMinimal + pkgs.openssh pkgs.nix - self'.packages.clan-cli ]}" cd $TMPDIR @@ -21,29 +20,20 @@ echo ensure flake outputs can be listed nix flake show - - echo create a machine - clan machines create machine1 - - echo check machine1 exists - clan machines list | grep -q machine1 - - echo check machine1 appears in flake output - nix flake show | grep -q machine1 ''; }; in { packages = - integrationTests // { + impureChecks // { # a script that executes all other checks - checks-impure = pkgs.writeShellScriptBin "checks-impure" '' + impure-checks = pkgs.writeShellScriptBin "impure-checks" '' #!${pkgs.bash}/bin/bash set -euo pipefail ${lib.concatMapStringsSep "\n" (name: '' echo -e "\n\nrunning check ${name}\n" - ${integrationTests.${name}}/bin/* - '') (lib.attrNames integrationTests)} + ${impureChecks.${name}}/bin/* + '') (lib.attrNames impureChecks)} ''; }; };