From d51150dd47a40f6d3f4e2d6fd677eeccfd72c865 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Jan 2024 18:14:06 +0100 Subject: [PATCH] Test pushing to FlakeHub --- .github/workflows/cache-test.sh | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cache-test.sh b/.github/workflows/cache-test.sh index c1f7eb1..49e687b 100755 --- a/.github/workflows/cache-test.sh +++ b/.github/workflows/cache-test.sh @@ -1,12 +1,45 @@ -#!/bin/sh +#! /usr/bin/env bash set -e set -ux seed=$(date) +log=$MAGIC_NIX_CACHE_DAEMONDIR/daemon.log + +binary_cache=https://attic-test.fly.dev + +# Check that the action initialized correctly. +grep 'FlakeHub cache is enabled' $log +grep 'Using cache' $log +grep 'GitHub Action cache is enabled' $log + +# Build something. outpath=$(nix-build .github/workflows/cache-tester.nix --argstr seed "$seed") + +# Check that the path was enqueued to be pushed to the cache. +grep "Enqueueing.*$outpath" $log + +# Wait until it has been pushed succesfully. +found= +for ((i = 0; i < 60; i++)); do + sleep 1 + if grep "✅ $(basename $outpath)" $log; then + found=1 + break + fi +done +if [[ -z $found ]]; then + echo "FlakeHub push did not happen." >&2 + exit 1 +fi + +# Check the FlakeHub binary cache to see if the path is really there. +nix path-info --store "$binary_cache" $outpath + +# FIXME: remove this once the daemon also uploads to GHA automatically. nix copy --to 'http://127.0.0.1:37515' "$outpath" + rm ./result nix store delete "$outpath" if [ -f "$outpath" ]; then