Merge pull request 'Skip already-cached packages in CI build-and-cache' (#43) from fix/ci-skip-cached-packages into main
This commit was merged in pull request #43.
This commit is contained in:
@@ -56,9 +56,20 @@ jobs:
|
|||||||
)
|
)
|
||||||
|
|
||||||
FAILED=()
|
FAILED=()
|
||||||
|
SKIPPED=()
|
||||||
for pkg in "${PACKAGES[@]}"; do
|
for pkg in "${PACKAGES[@]}"; do
|
||||||
echo "::group::Building $pkg"
|
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 eval ".#$pkg.outPath" --raw 2>/dev/null)
|
||||||
|
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
|
# --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
|
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)
|
OUT_PATH=$(echo "$BUILD_OUTPUT" | grep '^/nix/store/' | tail -1)
|
||||||
@@ -84,6 +95,10 @@ jobs:
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ ${#SKIPPED[@]} -gt 0 ]; then
|
||||||
|
echo "Skipped (already cached): ${SKIPPED[*]}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${#FAILED[@]} -gt 0 ]; then
|
if [ ${#FAILED[@]} -gt 0 ]; then
|
||||||
echo "::error::Failed packages: ${FAILED[*]}"
|
echo "::error::Failed packages: ${FAILED[*]}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user