Skip already-cached packages in CI build-and-cache job
This commit is contained in:
@@ -56,9 +56,20 @@ jobs:
|
||||
)
|
||||
|
||||
FAILED=()
|
||||
SKIPPED=()
|
||||
for pkg in "${PACKAGES[@]}"; do
|
||||
echo "::group::Building $pkg"
|
||||
# Capture build output, extract store path (last line starting with /nix/store/)
|
||||
|
||||
# Check if package is already cached by evaluating its store path and checking the remote
|
||||
OUT_PATH=$(nix build ".#$pkg" --no-link --print-out-paths --dry-run 2>/dev/null | grep '^/nix/store/' | tail -1)
|
||||
if [ -n "$OUT_PATH" ] && ssh -i ~/.ssh/cache_key ${{ secrets.CACHE_USER }}@${{ secrets.CACHE_HOST }} \
|
||||
"nix path-info '$OUT_PATH' >/dev/null 2>&1"; then
|
||||
echo "⏭ $pkg already cached ($OUT_PATH), skipping"
|
||||
SKIPPED+=("$pkg")
|
||||
echo "::endgroup::"
|
||||
continue
|
||||
fi
|
||||
|
||||
# --cores 2 limits parallel jobs to reduce RAM pressure on john-endesktop
|
||||
if BUILD_OUTPUT=$(nix build ".#$pkg" --no-link --print-out-paths --cores 2 2>&1); then
|
||||
OUT_PATH=$(echo "$BUILD_OUTPUT" | grep '^/nix/store/' | tail -1)
|
||||
@@ -84,6 +95,10 @@ jobs:
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
if [ ${#SKIPPED[@]} -gt 0 ]; then
|
||||
echo "Skipped (already cached): ${SKIPPED[*]}"
|
||||
fi
|
||||
|
||||
if [ ${#FAILED[@]} -gt 0 ]; then
|
||||
echo "::error::Failed packages: ${FAILED[*]}"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user