Skip to content

Commit

Permalink
Add mode to only restore caches in CI, without running npm
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Mar 13, 2024
1 parent 1bcf648 commit 7bd057c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .buildkite/commands/install-node-dependencies.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 "$@"

Expand Down
12 changes: 7 additions & 5 deletions .buildkite/commands/test-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions .buildkite/commands/test-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7bd057c

Please sign in to comment.