From 7bd057ccaf3ba01a9bb8d765be57a2688a1a79db Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 13 Mar 2024 14:08:17 +1100 Subject: [PATCH] Add mode to only restore caches in CI, without running `npm` --- .buildkite/commands/install-node-dependencies.sh | 14 ++++++++++++++ .buildkite/commands/test-android.sh | 12 +++++++----- .buildkite/commands/test-ios.sh | 10 ++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 2c69e9133b..53fa241ca0 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -1,5 +1,14 @@ #!/bin/bash -eu +RESTORE_ONLY='false' +while [[ "$#" -gt 0 ]]; do + case $1 in + --restore-only) RESTORE_ONLY='true' ;; + *) break ;; + esac + shift +done + PLATFORM=$(uname -s) ARCHITECTURE=$(uname -m) NODE_VERSION=$(node --version) @@ -13,6 +22,11 @@ echo "--- :npm: Restore cache if present" restore_cache "$CACHEKEY" restore_cache "$PNPM_CACHEKEY" +if [[ "${RESTORE_ONLY}" == 'true' ]]; then + echo 'Exiting after restoring caches as per --restore-only call parameter.' + exit 0 +fi + echo "--- :npm: Install Node dependencies" npm ci --unsafe-perm --prefer-offline --no-audit --no-progress "$@" diff --git a/.buildkite/commands/test-android.sh b/.buildkite/commands/test-android.sh index f62476603d..6442a9716c 100755 --- a/.buildkite/commands/test-android.sh +++ b/.buildkite/commands/test-android.sh @@ -16,14 +16,16 @@ while [ "$INPUT" != "" ]; do INPUT="${1-}" done -# First, set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) +# First, restore the caches, if any +.buildkite/commands/install-node-dependencies.sh --restore-only +# Second, set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) # It takes time and we don't need at this point as we are running the tests on top of something already built. -.buildkite/commands/install-node-dependencies.sh --ignore-scripts -# Then, set up the gutenberg submodule dependencies, bypassed by the step above. +npm ci --prefer-offline --no-progress --no-audit --ignore-scripts +# Finally, set up the gutenberg submodule dependencies, bypassed by the step above. # We need them because some E2E logic lives in gutenber. -.buildkite/commands/install-node-dependencies.sh --prefix gutenberg +npm ci --prefer-offline --no-progress --no-audit --prefix gutenberg -echo '--- :ios: Set env var for Android E2E testing' +echo '--- :android: Set env var for Android E2E testing' set -x export TEST_RN_PLATFORM=android export TEST_ENV=sauce diff --git a/.buildkite/commands/test-ios.sh b/.buildkite/commands/test-ios.sh index 81a4a487b4..5f93d701c1 100755 --- a/.buildkite/commands/test-ios.sh +++ b/.buildkite/commands/test-ios.sh @@ -19,12 +19,14 @@ while [ "$INPUT" != "" ]; do INPUT="${1-}" done -# First, set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) +# First, restore the caches, if any +.buildkite/commands/install-node-dependencies.sh --restore-only +# Second, set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) # It takes time and we don't need at this point as we are running the tests on top of something already built. -.buildkite/commands/install-node-dependencies.sh --ignore-scripts -# Then, set up the gutenberg submodule dependencies, bypassed by the step above. +npm ci --prefer-offline --no-progress --no-audit --ignore-scripts +# Finally, set up the gutenberg submodule dependencies, bypassed by the step above. # We need them because some E2E logic lives in gutenber. -.buildkite/commands/install-node-dependencies.sh --prefix gutenberg +npm ci --prefer-offline --no-progress --no-audit --prefix gutenberg echo '--- :ios: Set env var for iOS E2E testing' set -x