checks-integration: init
All checks were successful
checks-integration / test (pull_request) Successful in 7s
checks / test (pull_request) Successful in 1m6s

This commit is contained in:
DavHau 2023-08-27 00:18:17 +02:00
parent df628ffd96
commit 7928e953fa
6 changed files with 67 additions and 17 deletions

View File

@ -0,0 +1,11 @@
name: checks-integration
on:
pull_request:
push:
branches: main
jobs:
test:
runs-on: nix
steps:
- uses: actions/checkout@v3
- run: nix run .#checks-integration

View File

@ -1,4 +1,4 @@
name: build
name: checks
on:
pull_request:
push:

View File

@ -1,4 +1,7 @@
{ self, ... }: {
imports = [
./integration/flake-module.nix
];
perSystem = { pkgs, lib, self', ... }: {
checks =
let

View File

@ -0,0 +1,50 @@
{ self, ... }: {
perSystem = { pkgs, lib, self', ... }:
let
integrationTests = {
check-clan-create = pkgs.writeShellScriptBin "check-clan-init" ''
#!${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.nix
self'.packages.clan-cli
]}"
cd $TMPDIR
echo initialize new clan
nix flake init -t ${self}#new-clan
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 // {
# a script that executes all other checks
checks-integration = pkgs.writeShellScriptBin "checks-integration" ''
#!${pkgs.bash}/bin/bash
set -euo pipefail
${lib.concatMapStringsSep "\n" (name: ''
echo -e "\n\nrunning check ${name}\n"
${integrationTests.${name}}/bin/*
'') (lib.attrNames integrationTests)}
'';
};
};
}

View File

@ -7,7 +7,7 @@ import subprocess
def create(args: argparse.Namespace) -> None:
os.makedirs(args.folder, exist_ok=True)
# TODO create clan template in flake
subprocess.Popen(
subprocess.run(
[
"nix",
"flake",
@ -18,17 +18,6 @@ def create(args: argparse.Namespace) -> None:
)
def git(args: argparse.Namespace) -> None:
subprocess.Popen(
[
"git",
"-C",
args.folder,
]
+ args.git_args
)
# takes a (sub)parser and configures it
def register_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
@ -46,7 +35,3 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
parser_create = subparser.add_parser("create", help="create a new clan")
parser_create.set_defaults(func=create)
parser_git = subparser.add_parser("git", help="control the clan repo via git")
parser_git.add_argument("git_args", nargs="*")
parser_git.set_defaults(func=git)

View File

@ -8,6 +8,7 @@
outputs = inputs @ { flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
imports = [
./clan-flake-module.nix
];