mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 01:30:35 +01:00
a76a83091c
* ci workflow: don't check initial substituter list * ci workflow: s/macos-12/macos-13/g * ci push dev shell: s/macos-12/macos-13/g * cache-test.sh: only check for upload, not enqueue lines; enqueue log lines not printed for dnixd-subscriber scenario
53 lines
1.2 KiB
Bash
Executable file
53 lines
1.2 KiB
Bash
Executable file
#! /usr/bin/env bash
|
|
|
|
set -e
|
|
set -ux
|
|
|
|
seed=$(date)
|
|
|
|
log="${MAGIC_NIX_CACHE_DAEMONDIR}/daemon.log"
|
|
|
|
binary_cache=https://cache.flakehub.com
|
|
|
|
# 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")
|
|
|
|
# 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
|
|
echo "$outpath still exists? can't test"
|
|
exit 1
|
|
fi
|
|
|
|
rm -rf ~/.cache/nix
|
|
|
|
echo "-------"
|
|
echo "Trying to substitute the build again..."
|
|
echo "if it fails, the cache is broken."
|
|
|
|
nix-store --realize -vvvvvvvv "$outpath"
|