feat(ci): Cache CI results

This commit is contained in:
sinavir 2024-04-12 19:53:02 +02:00
parent 7645b6fd71
commit 9f2165abc8
6 changed files with 48 additions and 1 deletions

View file

@ -68,3 +68,21 @@ jobs:
run: | run: |
# Enter the shell # Enter the shell
nix-shell --run 'colmena build --on rescue01' nix-shell --run 'colmena build --on rescue01'
push_to_cache:
runs-on: nix
needs:
- build_compute01
- build_storage01
- build_vault01
- build_web01
- build_web02
- build_rescue01
steps:
- uses: actions/checkout@v3
- name: Push to cache
run: nix-shell --run push-to-cache
env:
ATTIC_ENDPOINT: "https://cachix.dgnum.eu"
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}

View file

@ -76,6 +76,7 @@ in
[ [
npins npins
nixos-generators nixos-generators
attic-client
] ]
++ (builtins.map (p: callPackage p { }) [ ++ (builtins.map (p: callPackage p { }) [
(sources.disko + "/package.nix") (sources.disko + "/package.nix")

View file

@ -58,7 +58,7 @@ in
proxyPass = "http://127.0.0.1:9090"; proxyPass = "http://127.0.0.1:9090";
extraConfig = '' extraConfig = ''
client_max_body_size 700M; client_max_body_size 10G;
''; '';
}; };
}; };

12
scripts/cache.sh Executable file
View file

@ -0,0 +1,12 @@
ENDPOINT=${ATTIC_ENDPOINT:-https://cachix.dgnum.eu}
if [ "$1" == "off" ]; then
echo "Please edit $XDG_CONFIG_DIRS/nix/nix.conf to remove the cache"
elif [ "$1" == "on" ]; then
@attic@/bin/attic login dgnum "$ENDPOINT"
@attic@/bin/attic use dgnum:infra
else
echo "Help:"
echo " cache {on|off}"
fi

View file

@ -10,6 +10,7 @@ let
git git
jq jq
; ;
attic = pkgs.attic-client;
}; };
mkShellScript = mkShellScript =
@ -32,6 +33,8 @@ let
"check-deployment" "check-deployment"
"launch-vm" "launch-vm"
"list-nodes" "list-nodes"
"push-to-cache"
"cache"
]; ];
in in

13
scripts/push-to-cache.sh Executable file
View file

@ -0,0 +1,13 @@
set -e
set -u
set -o pipefail
ENDPOINT=${ATTIC_ENDPOINT:-https://cachix.dgnum.eu}
@attic@/bin/attic login dgnum "$ENDPOINT" "$ATTIC_TOKEN"
@colmena@/bin/colmena eval -E '{ nodes, lib, ... }: lib.mapAttrsToList (_: v: v.config.system.build.toplevel.drvPath) nodes' |\
@jq@/bin/jq -r '.[]' |\
xargs nix-store -q -R --include-outputs |\
sed '/\.drv$/d' |\
xargs @attic@/bin/attic push dgnum:infra