From a1865093a899fdf8f8aabfbcebf77b80f49da8dd Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Tue, 20 Feb 2024 06:22:29 +0000 Subject: [PATCH] _scripts: do not use cache volumes on Netlify Fix up build.bash to set --nocachevolume on Netlify. Indeed fix up the script to be easier to read, with sensible safe defaults (for Netlify), and comments for any adjustments. Signed-off-by: Paul Jolly Change-Id: Ibadf30047fba2833791690c4428438b5fd6134fe Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1177095 Reviewed-by: Jonathan Matthews TryBot-Result: CUEcueckoo --- _scripts/build.bash | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/_scripts/build.bash b/_scripts/build.bash index d258665be..ee3d5d11b 100755 --- a/_scripts/build.bash +++ b/_scripts/build.bash @@ -21,18 +21,36 @@ set -eux # cd to the parent directory to that containing the script cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.." -skipcache="" -readonlycache="true" +# Defaults, appropriate for the sensitive Netlify environment time="" +readonlycache="--readonlycache" +nocachevolume="--nocachevolume" +skipcache="" minify="--minify" + if [ "${NETLIFY:-}" != "true" ] then + # Local or CI - just not Netlify + + # It's useful to see timings on steps time="time -p" - readonlycache="false" - minify="" + + # In CI or locally we want to write to cache files. But per below we only + # skip initially reading the cache in the case of CI. This is how we detect + # stale caches. + readonlycache="" + if [ "${CI:-}" == "true" ] then - skipcache="--skipcache=true --nocachevolume" + # See comment above for readonlycache + skipcache="--skipcache" + else + # Locally we don't want to minify the results of Hugo to help make + # debugging easier + minify="" + + # We do want to use cache volumes locally... and only locally. + nocachevolume="" fi fi @@ -40,7 +58,7 @@ fi bash playground/_scripts/build.bash # Run the preprocessor -bash _scripts/runPreprocessor.bash execute --readonlycache=$readonlycache $skipcache +bash _scripts/runPreprocessor.bash execute $readonlycache $nocachevolume $skipcache # Main site cd hugo