Merge pull request 'checks-integration: init' (#193) from DavHau-main into main
This commit is contained in:
commit
11dd70bf43
11
.gitea/workflows/checks-integration.yaml
Normal file
11
.gitea/workflows/checks-integration.yaml
Normal 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
|
@ -1,4 +1,4 @@
|
||||
name: build
|
||||
name: checks
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
@ -1,4 +1,7 @@
|
||||
{ self, ... }: {
|
||||
imports = [
|
||||
./integration/flake-module.nix
|
||||
];
|
||||
perSystem = { pkgs, lib, self', ... }: {
|
||||
checks =
|
||||
let
|
||||
|
50
checks/integration/flake-module.nix
Normal file
50
checks/integration/flake-module.nix
Normal 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)}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
@ -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)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
outputs = inputs @ { flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" ];
|
||||
imports = [
|
||||
./clan-flake-module.nix
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user