From e1ed3800a27de7565d8e3b87e544d20cba9f18ea Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 15:55:46 +0200 Subject: [PATCH 01/38] NPM Postinstall - Remove patch-package and gutenberg clean --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c9044de78..6b1d491a8c 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "webdriverio": "8.16.20" }, "scripts": { - "postinstall": "patch-package && npm run clean:gutenberg:distclean && npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --ignore-scripts\"", + "postinstall": "npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --ignore-scripts\"", "start": "echo \"\\x1b[33mThe start command is not available in this project. It is strongly recommended to use \\x1b[1:33mstart:reset\\x1b[0m\\x1b[33m to perform some cleanup when starting the metro bundler.\nOr you may use \\x1b[1:33mstart:quick\\x1b[0m\\x1b[33m for a quicker startup, but this may lead to unexpected javascript errors when running the app.\\x1b[0m\"", "start:reset": "npm run core clean:runtime && npm run start:quick -- --reset-cache", "start:quick": "npm run core start:quick -- -- -- --config ../../../metro.config.js", From dd83a381bf017dca4e19447f82a756fa93d0a4b6 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 17:22:48 +0200 Subject: [PATCH 02/38] Update lint command --- bin/ci-checks-js.sh | 6 ------ package.json | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/ci-checks-js.sh b/bin/ci-checks-js.sh index 9daa3535d5..62182dbd2d 100755 --- a/bin/ci-checks-js.sh +++ b/bin/ci-checks-js.sh @@ -38,12 +38,6 @@ if [ "$CHECK_CORRECTNESS" = true ] ; then checkDiff echo "--- :eslint: Lint" - # Need to build gutenberg packages before linting so that eslint-plugin-import can resolve those. - # See https://github.com/WordPress/gutenberg/pull/22088 for more information. - cd gutenberg - npm run build:packages || pFail - cd .. - npm run lint || pFail fi diff --git a/package.json b/package.json index 6b1d491a8c..f0f8de8eb3 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "clean:gutenberg": "cd gutenberg && npm run clean:packages", "clean:gutenberg:distclean": "cd gutenberg && npm run distclean", "clean:i18n": "rm -rf src/i18n-cache && npm run i18n:check-cache", - "lint": "eslint . --ext .js", + "lint": "eslint . --ext .js --quiet 2>/dev/null", "lint:fix": "npm run lint -- --fix", "xcframework:setup": "./bin/xcframework-setup", "xcframework:build": "npm run xcframework:setup && pushd ./ios-xcframework && ./build.sh && popd" From a22a24cd271c79b93ed9389b72170ef3d51cf879 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 17:32:34 +0200 Subject: [PATCH 03/38] Reduce npm installation for linting --- .buildkite/commands/lint.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.buildkite/commands/lint.sh b/.buildkite/commands/lint.sh index a7913bc659..72b96ab6ee 100755 --- a/.buildkite/commands/lint.sh +++ b/.buildkite/commands/lint.sh @@ -1,6 +1,12 @@ #!/bin/bash -eu -.buildkite/commands/install-node-dependencies.sh +# Restore the caches, if any +.buildkite/commands/install-node-dependencies.sh --restore-only +# Set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) +echo "--- :npm: Install Node dependencies" +npm ci --prefer-offline --no-progress --no-audit --ignore-scripts +# Set up the gutenberg submodule dependencies +npm ci --prefer-offline --no-progress --no-audit --prefix gutenberg --ignore-scripts echo "--- :node: Lint" CHECK_CORRECTNESS=true CHECK_TESTS=false ./bin/ci-checks-js.sh From 8d5ecdd63cc6305131dc1adad054e811c58f667a Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 17:39:26 +0200 Subject: [PATCH 04/38] Add check cache for lint step --- .buildkite/commands/lint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.buildkite/commands/lint.sh b/.buildkite/commands/lint.sh index 72b96ab6ee..8b58afce42 100755 --- a/.buildkite/commands/lint.sh +++ b/.buildkite/commands/lint.sh @@ -2,9 +2,11 @@ # Restore the caches, if any .buildkite/commands/install-node-dependencies.sh --restore-only -# Set up the gutenberg-mobile dependencies without building the i18n cache (--ignore-scripts) +# Set up the gutenberg-mobile dependencies without scripts (--ignore-scripts) echo "--- :npm: Install Node dependencies" npm ci --prefer-offline --no-progress --no-audit --ignore-scripts +# Set up building the i18n cache +npm run i18n:check-cache # Set up the gutenberg submodule dependencies npm ci --prefer-offline --no-progress --no-audit --prefix gutenberg --ignore-scripts From 37fcf4286e4d010e033e10f13b4d75255dd7a8f8 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 18:03:43 +0200 Subject: [PATCH 05/38] Add offline flags --- bin/run-block-experiments-command.sh | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run-block-experiments-command.sh b/bin/run-block-experiments-command.sh index fb77fddad2..39be689149 100755 --- a/bin/run-block-experiments-command.sh +++ b/bin/run-block-experiments-command.sh @@ -35,4 +35,4 @@ else fi # Install only regular dependencies (excluding devDependencies) -npx --silent yarn install --production \ No newline at end of file +npx --silent yarn install --production --prefer-offline \ No newline at end of file diff --git a/package.json b/package.json index f0f8de8eb3..3f5c0d1da5 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "webdriverio": "8.16.20" }, "scripts": { - "postinstall": "npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --ignore-scripts\"", + "postinstall": "npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --offline --ignore-scripts\"", "start": "echo \"\\x1b[33mThe start command is not available in this project. It is strongly recommended to use \\x1b[1:33mstart:reset\\x1b[0m\\x1b[33m to perform some cleanup when starting the metro bundler.\nOr you may use \\x1b[1:33mstart:quick\\x1b[0m\\x1b[33m for a quicker startup, but this may lead to unexpected javascript errors when running the app.\\x1b[0m\"", "start:reset": "npm run core clean:runtime && npm run start:quick -- --reset-cache", "start:quick": "npm run core start:quick -- -- -- --config ../../../metro.config.js", From 8e4f92ddbc1bdaefc8cf7f63152f2ae7893b62f9 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 18:11:01 +0200 Subject: [PATCH 06/38] Use --prefer-offline --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f5c0d1da5..e233eae833 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "webdriverio": "8.16.20" }, "scripts": { - "postinstall": "npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --offline --ignore-scripts\"", + "postinstall": "npm ci --prefix gutenberg && ./bin/run-block-experiments-command.sh && npm run i18n:check-cache && ./bin/run-jetpack-command.sh \"install --prefer-offline --ignore-scripts\"", "start": "echo \"\\x1b[33mThe start command is not available in this project. It is strongly recommended to use \\x1b[1:33mstart:reset\\x1b[0m\\x1b[33m to perform some cleanup when starting the metro bundler.\nOr you may use \\x1b[1:33mstart:quick\\x1b[0m\\x1b[33m for a quicker startup, but this may lead to unexpected javascript errors when running the app.\\x1b[0m\"", "start:reset": "npm run core clean:runtime && npm run start:quick -- --reset-cache", "start:quick": "npm run core start:quick -- -- -- --config ../../../metro.config.js", From 349dcf87a57d437bf0e61f2e6a3b4b79b17e07ae Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 19:25:38 +0200 Subject: [PATCH 07/38] Test check if the files folder from npm exists --- .buildkite/commands/install-node-dependencies.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index d522c5f133..5ae55f8d00 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -22,6 +22,14 @@ echo "--- :npm: Restore cache if present" restore_cache "$CACHEKEY" restore_cache "$PNPM_CACHEKEY" +# Check if /files/ folder exists after restoring cache +if [ -d "./files" ]; then + echo "The folder /files/ exists." +else + echo "The folder /files/ does not exist." +fi + + if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' exit 0 From 4004a13cd132d1e16c10a70914e9b24f20e85f18 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 19:43:50 +0200 Subject: [PATCH 08/38] Check pnpm folder --- .buildkite/commands/install-node-dependencies.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 5ae55f8d00..46d5f2ab9e 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -22,13 +22,7 @@ echo "--- :npm: Restore cache if present" restore_cache "$CACHEKEY" restore_cache "$PNPM_CACHEKEY" -# Check if /files/ folder exists after restoring cache -if [ -d "./files" ]; then - echo "The folder /files/ exists." -else - echo "The folder /files/ does not exist." -fi - +if [ "$(uname -s)" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm/store/v3"; elif [ "$(uname -s)" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm/store/v3"; else echo "Unsupported platform: $(uname -s)"; exit 1; fi; if [ -d "$PNPM_PATH" ]; then echo "PNPM cache path exists: $PNPM_PATH"; else echo "PNPM cache path does not exist: $PNPM_PATH"; fi if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' From a58e72e1bde2227e3e0f51e186cd4e865dc7aba4 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:05:14 +0200 Subject: [PATCH 09/38] Try pnpm cache folder --- .../commands/install-node-dependencies.sh | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 46d5f2ab9e..4102a257cc 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -17,10 +17,20 @@ GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node$NODE_VERSION-$JETPACK_PACKAGE_HASH" +PNPM_CACHE_FOLDER="store" + +if [ "$PLATFORM" = "Darwin" ]; then + PNPM_PATH="$HOME/Library/pnpm" +elif [ "$PLATFORM" = "Linux" ]; then + PNPM_PATH="$HOME/.local/share/pnpm" +fi echo "--- :npm: Restore cache if present" restore_cache "$CACHEKEY" + +pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" +popd if [ "$(uname -s)" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm/store/v3"; elif [ "$(uname -s)" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm/store/v3"; else echo "Unsupported platform: $(uname -s)"; exit 1; fi; if [ -d "$PNPM_PATH" ]; then echo "PNPM cache path exists: $PNPM_PATH"; else echo "PNPM cache path does not exist: $PNPM_PATH"; fi @@ -53,13 +63,7 @@ if echo "$@" | grep -q -- '--prefix gutenberg'; then exit 0 fi -if [ "$PLATFORM" = "Darwin" ]; then - PNPM_PATH="$HOME/Library/pnpm/store/v3" -elif [ "$PLATFORM" = "Linux" ]; then - PNPM_PATH="$HOME/.local/share/pnpm/store/v3" -else - echo "Unsupported platform: $PLATFORM." - exit 1 -fi - -save_cache "$PNPM_PATH" "$PNPM_CACHEKEY" +mkdir -p "$PNPM_PATH" +pushd "$PNPM_PATH" +save_cache "$PNPM_CACHE_FOLDER" "$PNPM_CACHEKEY" +popd From 9554af1b5e5019e7f68e61802c992f83a80ee919 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:09:22 +0200 Subject: [PATCH 10/38] Create folder if it doesnt exist --- .buildkite/commands/install-node-dependencies.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 4102a257cc..2bcf365569 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -28,6 +28,7 @@ fi echo "--- :npm: Restore cache if present" restore_cache "$CACHEKEY" +mkdir -p "$PNPM_PATH" pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" popd From 5dec582c40545eefdcff14c2d497041006be500b Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:16:59 +0200 Subject: [PATCH 11/38] Update pnpm key --- .buildkite/commands/install-node-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 2bcf365569..5610178c1c 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -16,7 +16,7 @@ PACKAGE_HASH=$(hash_file package-lock.json) GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" -PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node$NODE_VERSION-$JETPACK_PACKAGE_HASH" +PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$JETPACK_PACKAGE_HASH" PNPM_CACHE_FOLDER="store" if [ "$PLATFORM" = "Darwin" ]; then From d7ae58f197e326eabbb97283b3855193f3073af4 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:27:25 +0200 Subject: [PATCH 12/38] Fix path --- .buildkite/commands/install-node-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 5610178c1c..2277142444 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -33,7 +33,7 @@ pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" popd -if [ "$(uname -s)" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm/store/v3"; elif [ "$(uname -s)" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm/store/v3"; else echo "Unsupported platform: $(uname -s)"; exit 1; fi; if [ -d "$PNPM_PATH" ]; then echo "PNPM cache path exists: $PNPM_PATH"; else echo "PNPM cache path does not exist: $PNPM_PATH"; fi +if [ -d "$PNPM_PATH" ]; then echo "PNPM cache path exists: $PNPM_PATH"; else echo "PNPM cache path does not exist: $PNPM_PATH"; fi if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' From 4c0a9c7bfc8808f74445d658dd9e64aa8b6590c8 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:47:47 +0200 Subject: [PATCH 13/38] Make npm changes as pnpm --- .buildkite/commands/install-node-dependencies.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 2277142444..ab9d98469c 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -15,9 +15,10 @@ NODE_VERSION=$(node --version) PACKAGE_HASH=$(hash_file package-lock.json) GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) -CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" +CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$JETPACK_PACKAGE_HASH" PNPM_CACHE_FOLDER="store" +NPM_CACHE_FOLDER=".npm" if [ "$PLATFORM" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm" @@ -26,7 +27,9 @@ elif [ "$PLATFORM" = "Linux" ]; then fi echo "--- :npm: Restore cache if present" +pushd "$HOME" restore_cache "$CACHEKEY" +popd mkdir -p "$PNPM_PATH" pushd "$PNPM_PATH" @@ -54,7 +57,9 @@ echo "--- :npm: Save cache if necessary" # # Example: https://buildkite.com/automattic/gutenberg-mobile/builds/8857#018e37eb-7afc-4280-b736-cba76f02f1a3/524 rm -rf "$HOME/.npm/_cacache/tmp" -save_cache "$HOME/.npm" "$CACHEKEY" +pushd "$HOME" +save_cache "$NPM_CACHE_FOLDER" "$CACHEKEY" +popd # If we attempted to save the pnpm cache when npm run with '--prefix gutenberg', the command might fail. # That's because the Jetpack submodule alone uses pnpm. @@ -64,7 +69,6 @@ if echo "$@" | grep -q -- '--prefix gutenberg'; then exit 0 fi -mkdir -p "$PNPM_PATH" pushd "$PNPM_PATH" save_cache "$PNPM_CACHE_FOLDER" "$PNPM_CACHEKEY" popd From 01f0a9dec91b6594a7044643cd42448dd7ea6f73 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 20:58:11 +0200 Subject: [PATCH 14/38] Remove log --- .buildkite/commands/install-node-dependencies.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index ab9d98469c..b38ec9b6d6 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -36,8 +36,6 @@ pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" popd -if [ -d "$PNPM_PATH" ]; then echo "PNPM cache path exists: $PNPM_PATH"; else echo "PNPM cache path does not exist: $PNPM_PATH"; fi - if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' exit 0 From 41dbd2cef1195fd19df228b1bbfd0f52ae897c3a Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 21:26:00 +0200 Subject: [PATCH 15/38] Add i18n cache --- .../commands/install-node-dependencies.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index b38ec9b6d6..6b44d77a02 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -12,13 +12,20 @@ done PLATFORM=$(uname -s) ARCHITECTURE=$(uname -m) NODE_VERSION=$(node --version) +PACKAGE_VERSION=$(jq -r .version package.json) + PACKAGE_HASH=$(hash_file package-lock.json) GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) -CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" + +NPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" +NPM_CACHE_FOLDER=".npm" + PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$JETPACK_PACKAGE_HASH" PNPM_CACHE_FOLDER="store" -NPM_CACHE_FOLDER=".npm" + +I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_VERSION" +I18N_CACHE_FOLDER="src/i18n-cache" if [ "$PLATFORM" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm" @@ -28,7 +35,7 @@ fi echo "--- :npm: Restore cache if present" pushd "$HOME" -restore_cache "$CACHEKEY" +restore_cache "$NPM_CACHEKEY" popd mkdir -p "$PNPM_PATH" @@ -36,6 +43,8 @@ pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" popd +restore_cache "$I18N_CACHEKEY" + if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' exit 0 @@ -56,8 +65,9 @@ echo "--- :npm: Save cache if necessary" # Example: https://buildkite.com/automattic/gutenberg-mobile/builds/8857#018e37eb-7afc-4280-b736-cba76f02f1a3/524 rm -rf "$HOME/.npm/_cacache/tmp" pushd "$HOME" -save_cache "$NPM_CACHE_FOLDER" "$CACHEKEY" +save_cache "$NPM_CACHE_FOLDER" "$NPM_CACHEKEY" popd +save_cache "$I18N_CACHE_FOLDER" "$I18N_CACHEKEY" # If we attempted to save the pnpm cache when npm run with '--prefix gutenberg', the command might fail. # That's because the Jetpack submodule alone uses pnpm. From 6087ab7f18e38a4f6cef8f502c90872d6d7fcf1c Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 21:32:06 +0200 Subject: [PATCH 16/38] Show errors output if any --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e233eae833..2b68cb33e4 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "clean:gutenberg": "cd gutenberg && npm run clean:packages", "clean:gutenberg:distclean": "cd gutenberg && npm run distclean", "clean:i18n": "rm -rf src/i18n-cache && npm run i18n:check-cache", - "lint": "eslint . --ext .js --quiet 2>/dev/null", + "lint": "eslint . --ext .js --quiet", "lint:fix": "npm run lint -- --fix", "xcframework:setup": "./bin/xcframework-setup", "xcframework:build": "npm run xcframework:setup && pushd ./ios-xcframework && ./build.sh && popd" From 423fd230c39963a1b473e56e8f9813d7e4a5f5b4 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 21:37:59 +0200 Subject: [PATCH 17/38] Check if the i18 folder exists before saving cache --- .buildkite/commands/install-node-dependencies.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 6b44d77a02..a9b2e793ef 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -67,7 +67,12 @@ rm -rf "$HOME/.npm/_cacache/tmp" pushd "$HOME" save_cache "$NPM_CACHE_FOLDER" "$NPM_CACHEKEY" popd -save_cache "$I18N_CACHE_FOLDER" "$I18N_CACHEKEY" + +if [ -d "$I18N_CACHE_FOLDER" ]; then + save_cache "$I18N_CACHE_FOLDER" "$I18N_CACHEKEY" +else + echo "Directory $I18N_CACHE_FOLDER does not exist. Skipping..." +fi # If we attempted to save the pnpm cache when npm run with '--prefix gutenberg', the command might fail. # That's because the Jetpack submodule alone uses pnpm. From dc95660bb1f937ca3a0faca3ad9e9b8ad9f14a5d Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 21:53:57 +0200 Subject: [PATCH 18/38] Try adding cache to the bundle job --- .buildkite/pipeline.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 250cf2e8ac..c4c9fdb0ae 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -119,7 +119,7 @@ steps: # The following plugins are disabled temporarily until PHP is available. # In the meantime, we'll keep using the GB-mobile docker container. - *gb-mobile-docker-container - # - *ci_toolkit_plugin # unused? + - *ci_toolkit_plugin # - *nvm_plugin - *git-partial-clone-plugin command: | @@ -128,6 +128,9 @@ steps: echo "--- :node: Set up Node environment" nvm install && nvm use + # Restore the caches, if any + .buildkite/commands/install-node-dependencies.sh --restore-only + echo "--- :npm: Install Node dependencies" npm ci --unsafe-perm --prefer-offline --no-audit --no-progress From fc766c66765fcf890374b9fd2409c500f5156d72 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 5 Jun 2024 22:05:10 +0200 Subject: [PATCH 19/38] Revert adding cache since its not supported with the docker image --- .buildkite/pipeline.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index c4c9fdb0ae..250cf2e8ac 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -119,7 +119,7 @@ steps: # The following plugins are disabled temporarily until PHP is available. # In the meantime, we'll keep using the GB-mobile docker container. - *gb-mobile-docker-container - - *ci_toolkit_plugin + # - *ci_toolkit_plugin # unused? # - *nvm_plugin - *git-partial-clone-plugin command: | @@ -128,9 +128,6 @@ steps: echo "--- :node: Set up Node environment" nvm install && nvm use - # Restore the caches, if any - .buildkite/commands/install-node-dependencies.sh --restore-only - echo "--- :npm: Install Node dependencies" npm ci --unsafe-perm --prefer-offline --no-audit --no-progress From e738f545ef3af5b028b02f0af2475cd269fcdc74 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 08:59:15 +0200 Subject: [PATCH 20/38] Move bundles to mac agent --- .buildkite/commands/build-bundles.sh | 26 ++++++++++++++++ .buildkite/pipeline.yml | 45 ++++------------------------ 2 files changed, 32 insertions(+), 39 deletions(-) create mode 100755 .buildkite/commands/build-bundles.sh diff --git a/.buildkite/commands/build-bundles.sh b/.buildkite/commands/build-bundles.sh new file mode 100755 index 0000000000..e76a731260 --- /dev/null +++ b/.buildkite/commands/build-bundles.sh @@ -0,0 +1,26 @@ +#!/bin/bash -eu + +.buildkite/commands/install-node-dependencies.sh + +if [[ -z "$BUILDKITE_TAG" ]]; then + echo "--- :package: Skip bundle prep work" +else + echo "--- :package: Run bundle prep work" + npm run prebundle:js +fi + +echo "--- :android: Build Android bundle" +npm run bundle:android + +echo "--- :arrow_up: Upload Android bundle and source map artifacts" +buildkite-agent artifact upload bundle/android/App.js +buildkite-agent artifact upload bundle/android/App.composed.js.map + +echo "--- :iOS: Build iOS bundle" +npm run bundle:ios + +echo "--- :arrow_up: Upload iOS bundle and source map artifacts" +buildkite-agent artifact upload bundle/iOS/App.js +buildkite-agent artifact upload bundle/iOS/App.composed.js.map +tar -czvf ios-assets.tar.gz -C ios-xcframework/Gutenberg/Resources assets/ +buildkite-agent artifact upload ios-assets.tar.gz \ No newline at end of file diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 250cf2e8ac..2d868f8a92 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -113,46 +113,13 @@ steps: - label: Build JS Bundles key: js-bundles - agents: - queue: android plugins: - # The following plugins are disabled temporarily until PHP is available. - # In the meantime, we'll keep using the GB-mobile docker container. - - *gb-mobile-docker-container - # - *ci_toolkit_plugin # unused? - # - *nvm_plugin - - *git-partial-clone-plugin - command: | - source /root/.bashrc - - echo "--- :node: Set up Node environment" - nvm install && nvm use - - echo "--- :npm: Install Node dependencies" - npm ci --unsafe-perm --prefer-offline --no-audit --no-progress - - if [[ -z "$BUILDKITE_TAG" ]]; then - echo "--- :package: Skip bundle prep work" - else - echo "--- :package: Run bundle prep work" - npm run prebundle:js - fi - - echo "--- :android: Build Android bundle" - npm run bundle:android - - echo "--- :arrow_up: Upload Android bundle and source map artifacts" - buildkite-agent artifact upload bundle/android/App.js - buildkite-agent artifact upload bundle/android/App.composed.js.map - - echo "--- :ios: Build iOS bundle" - npm run bundle:ios - - echo "--- :arrow_up: Upload iOS bundle and source map artifacts" - buildkite-agent artifact upload bundle/ios/App.js - buildkite-agent artifact upload bundle/ios/App.composed.js.map - tar -czvf ios-assets.tar.gz -C ios-xcframework/Gutenberg/Resources assets/ - buildkite-agent artifact upload ios-assets.tar.gz + - *ci_toolkit_plugin + - *nvm_plugin + command: .buildkite/commands/build-bundles.sh + agents: + queue: mac + env: *xcode_agent_env - label: "Build Android RN Aztec & Publish to S3" key: "publish-react-native-aztec-android" From 29478f394c4f4e1f1d50cb740967497addfe9825 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:10:05 +0200 Subject: [PATCH 21/38] Fix tag condition --- .buildkite/commands/build-bundles.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/build-bundles.sh b/.buildkite/commands/build-bundles.sh index e76a731260..ef5507569b 100755 --- a/.buildkite/commands/build-bundles.sh +++ b/.buildkite/commands/build-bundles.sh @@ -2,7 +2,7 @@ .buildkite/commands/install-node-dependencies.sh -if [[ -z "$BUILDKITE_TAG" ]]; then +if [ -z "${BUILDKITE_TAG:-}" ]; then echo "--- :package: Skip bundle prep work" else echo "--- :package: Run bundle prep work" From 2deac9608525d02ea2172a463cf07c1808de3c34 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:22:14 +0200 Subject: [PATCH 22/38] Get yarn cache folder --- .buildkite/commands/install-node-dependencies.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index a9b2e793ef..41b386b325 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -17,6 +17,7 @@ PACKAGE_VERSION=$(jq -r .version package.json) PACKAGE_HASH=$(hash_file package-lock.json) GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) +BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/yarn.lock) NPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" NPM_CACHE_FOLDER=".npm" @@ -24,6 +25,9 @@ NPM_CACHE_FOLDER=".npm" PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$JETPACK_PACKAGE_HASH" PNPM_CACHE_FOLDER="store" +YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_PACKAGE_HASH" +YARN_CACHE_FOLDER="Yarn" + I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_VERSION" I18N_CACHE_FOLDER="src/i18n-cache" @@ -33,6 +37,8 @@ elif [ "$PLATFORM" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm" fi +npx yarn cache dir + echo "--- :npm: Restore cache if present" pushd "$HOME" restore_cache "$NPM_CACHEKEY" From e5475de7fa5da551c7e0a1486fdf479f426dc3cc Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:23:14 +0200 Subject: [PATCH 23/38] Fix iOS casing --- .buildkite/commands/build-bundles.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/commands/build-bundles.sh b/.buildkite/commands/build-bundles.sh index ef5507569b..eb293abf4e 100755 --- a/.buildkite/commands/build-bundles.sh +++ b/.buildkite/commands/build-bundles.sh @@ -16,11 +16,11 @@ echo "--- :arrow_up: Upload Android bundle and source map artifacts" buildkite-agent artifact upload bundle/android/App.js buildkite-agent artifact upload bundle/android/App.composed.js.map -echo "--- :iOS: Build iOS bundle" +echo "--- :ios: Build iOS bundle" npm run bundle:ios echo "--- :arrow_up: Upload iOS bundle and source map artifacts" -buildkite-agent artifact upload bundle/iOS/App.js -buildkite-agent artifact upload bundle/iOS/App.composed.js.map +buildkite-agent artifact upload bundle/ios/App.js +buildkite-agent artifact upload bundle/ios/App.composed.js.map tar -czvf ios-assets.tar.gz -C ios-xcframework/Gutenberg/Resources assets/ buildkite-agent artifact upload ios-assets.tar.gz \ No newline at end of file From ab464cef7aa5ca260ffeff064e408ab41cf84dbf Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:29:29 +0200 Subject: [PATCH 24/38] Print yarn path --- .buildkite/commands/install-node-dependencies.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 41b386b325..b5236bdc54 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -37,7 +37,8 @@ elif [ "$PLATFORM" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm" fi -npx yarn cache dir +YARN_CACHE_DIR=$(npx yarn cache dir) +echo "Yarn cache directory: $YARN_CACHE_DIR" echo "--- :npm: Restore cache if present" pushd "$HOME" From fb3d60c4be63b952baba9a2afa6d722991ee9c1c Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:41:04 +0200 Subject: [PATCH 25/38] Add yarn cache --- .../commands/install-node-dependencies.sh | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index b5236bdc54..f89f1fd054 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -26,30 +26,38 @@ PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_ PNPM_CACHE_FOLDER="store" YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_PACKAGE_HASH" -YARN_CACHE_FOLDER="Yarn" I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_VERSION" I18N_CACHE_FOLDER="src/i18n-cache" if [ "$PLATFORM" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm" + YARN_PATH="$HOME/Library/Caches" + YARN_CACHE_FOLDER="Yarn" elif [ "$PLATFORM" = "Linux" ]; then PNPM_PATH="$HOME/.local/share/pnpm" + YARN_PATH="$HOME/.cache" + YARN_CACHE_FOLDER="yarn" fi -YARN_CACHE_DIR=$(npx yarn cache dir) -echo "Yarn cache directory: $YARN_CACHE_DIR" - echo "--- :npm: Restore cache if present" +# npm pushd "$HOME" restore_cache "$NPM_CACHEKEY" popd +# pnpm mkdir -p "$PNPM_PATH" pushd "$PNPM_PATH" restore_cache "$PNPM_CACHEKEY" popd +# yarn +pushd "$YARN_PATH" +restore_cache "$YARN_CACHEKEY" +popd + +# i18n restore_cache "$I18N_CACHEKEY" if [[ "${RESTORE_ONLY}" == 'true' ]]; then @@ -71,10 +79,13 @@ echo "--- :npm: Save cache if necessary" # # Example: https://buildkite.com/automattic/gutenberg-mobile/builds/8857#018e37eb-7afc-4280-b736-cba76f02f1a3/524 rm -rf "$HOME/.npm/_cacache/tmp" + +# npm pushd "$HOME" save_cache "$NPM_CACHE_FOLDER" "$NPM_CACHEKEY" popd +# i18n if [ -d "$I18N_CACHE_FOLDER" ]; then save_cache "$I18N_CACHE_FOLDER" "$I18N_CACHEKEY" else @@ -89,6 +100,12 @@ if echo "$@" | grep -q -- '--prefix gutenberg'; then exit 0 fi +# pnpm pushd "$PNPM_PATH" save_cache "$PNPM_CACHE_FOLDER" "$PNPM_CACHEKEY" popd + +# yarn +pushd "$YARN_PATH" +save_cache "$YARN_CACHE_FOLDER" "$YARN_CACHEKEY" +popd From ee93a49d257fb1204a2fd875096de48639a17088 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:48:32 +0200 Subject: [PATCH 26/38] Fix yarn path --- .buildkite/commands/install-node-dependencies.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index f89f1fd054..85fb00f727 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -53,6 +53,7 @@ restore_cache "$PNPM_CACHEKEY" popd # yarn +mkdir -p "$YARN_PATH" pushd "$YARN_PATH" restore_cache "$YARN_CACHEKEY" popd From 8627dd31ff17319669b06ad307d71667b4ff9f25 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 09:58:38 +0200 Subject: [PATCH 27/38] Remove unused docker image --- .buildkite/pipeline.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2d868f8a92..03ac4deae4 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,14 +1,4 @@ x-common-params: - - &gb-mobile-docker-container - docker#v3.8.0: - image: 'public.ecr.aws/automattic/gb-mobile-image:latest' - environment: - - 'CI=true' - # Allow WP-CLI to be run as root, otherwise it throws an exception. - # Reference: https://git.io/J9q2S - - 'WP_CLI_ALLOW_ROOT=true' - # Increase max available memory for node - - 'NODE_OPTIONS="--max-old-space-size=4096"' - &git-partial-clone-plugin automattic/git-partial-clone#0.1.0 - &publish-android-artifacts-docker-container From 8fc2aacf5249ee87547887c4ffc754d8559fa01b Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 10:14:16 +0200 Subject: [PATCH 28/38] Update Gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index eaf2d6550b..ed98cee6be 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit eaf2d6550b39587dc8945bf2e20fc4290a7139fe +Subproject commit ed98cee6be47c34e1e563cb3dd1e3211532feccb From dfe0569c1bade8ef67b0f289270cca104ff91e66 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 10:25:22 +0200 Subject: [PATCH 29/38] Add comments --- .buildkite/commands/install-node-dependencies.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 85fb00f727..7dba02e95f 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -12,24 +12,28 @@ done PLATFORM=$(uname -s) ARCHITECTURE=$(uname -m) NODE_VERSION=$(node --version) -PACKAGE_VERSION=$(jq -r .version package.json) +GUTENBERG_PACKAGE_VERSION=$(jq -r .version package.json) +# npm PACKAGE_HASH=$(hash_file package-lock.json) GUTENBERG_PACKAGE_HASH=$(hash_file gutenberg/package-lock.json) -JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) -BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/yarn.lock) - NPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-npm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_HASH-$GUTENBERG_PACKAGE_HASH" NPM_CACHE_FOLDER=".npm" +# pnpm +JETPACK_PACKAGE_HASH=$(hash_file jetpack/pnpm-lock.yaml) PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$JETPACK_PACKAGE_HASH" PNPM_CACHE_FOLDER="store" +# yarn +BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/yarn.lock) YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_PACKAGE_HASH" -I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$PACKAGE_VERSION" +# i18n +I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$GUTENBERG_PACKAGE_VERSION" I18N_CACHE_FOLDER="src/i18n-cache" +# Cache folder directories if [ "$PLATFORM" = "Darwin" ]; then PNPM_PATH="$HOME/Library/pnpm" YARN_PATH="$HOME/Library/Caches" From d719515458f7e6e6b2f357a369fd5d32112e5362 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 10:47:34 +0200 Subject: [PATCH 30/38] Update yarn installation command --- bin/run-block-experiments-command.sh | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/bin/run-block-experiments-command.sh b/bin/run-block-experiments-command.sh index 39be689149..f8d6f6b7a0 100755 --- a/bin/run-block-experiments-command.sh +++ b/bin/run-block-experiments-command.sh @@ -1,28 +1,6 @@ #!/bin/bash set -Eeuo pipefail -local_run_script="${GBM_LOCAL_BLOCK_EXPERIMENTS_RUN_SCRIPT:-./bin/run-block-experiments-command.sh.local}" - -if [ -e "$local_run_script" ] -then - source "$local_run_script" - exit 0 -fi - -# Check if nvm is installed -[ -z "$NVM_DIR" ] && NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - -command -v nvm >/dev/null 2>&1 || { - echo "nvm is not installed or cannot be sourced from $NVM_DIR/nvm.sh. Please verify that "'$NVM_DIR'" points to the .nvm directory." - exit 1 -} - -pushd block-experiments - -# Set up node requirement for block-experiments -nvm install - # Check if Yarn is installed if ! command -v yarn &> /dev/null then @@ -35,4 +13,4 @@ else fi # Install only regular dependencies (excluding devDependencies) -npx --silent yarn install --production --prefer-offline \ No newline at end of file +npx --silent yarn install --cwd block-experiments --ignore-engines --production --prefer-offline \ No newline at end of file From a77b9d107ad649d278b775a950bdb92d5dd69bd6 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 10:59:09 +0200 Subject: [PATCH 31/38] Update yarn key --- .buildkite/commands/install-node-dependencies.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 7dba02e95f..9bfdd8be26 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -26,8 +26,9 @@ PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_ PNPM_CACHE_FOLDER="store" # yarn +BLOCK_EXPERIMENTS_YARN_HASH=$(hash_file block-experiments/.yarnrc) BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/yarn.lock) -YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_PACKAGE_HASH" +YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_YARN_HASH-$BLOCK_EXPERIMENTS_PACKAGE_HASH" # i18n I18N_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-i18n-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$GUTENBERG_PACKAGE_VERSION" From c3d5aa6a671c1990ec95d58a67eaab17ed1fe723 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 11:03:22 +0200 Subject: [PATCH 32/38] Fix yarn package hash --- .buildkite/commands/install-node-dependencies.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 9bfdd8be26..93502ad239 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -26,8 +26,8 @@ PNPM_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pnpm-$PLATFORM-$ARCHITECTURE-node-$NODE_ PNPM_CACHE_FOLDER="store" # yarn -BLOCK_EXPERIMENTS_YARN_HASH=$(hash_file block-experiments/.yarnrc) -BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/yarn.lock) +BLOCK_EXPERIMENTS_YARN_HASH=$(hash_file block-experiments/yarn.lock) +BLOCK_EXPERIMENTS_PACKAGE_HASH=$(hash_file block-experiments/package.json) YARN_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-yarn-$PLATFORM-$ARCHITECTURE-node-$NODE_VERSION-$BLOCK_EXPERIMENTS_YARN_HASH-$BLOCK_EXPERIMENTS_PACKAGE_HASH" # i18n From 6da6c0ad2a97d82d53827f48ce3a3e6205a0423c Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 11:11:06 +0200 Subject: [PATCH 33/38] Clean up --- .buildkite/commands/install-node-dependencies.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.buildkite/commands/install-node-dependencies.sh b/.buildkite/commands/install-node-dependencies.sh index 93502ad239..52507e4938 100755 --- a/.buildkite/commands/install-node-dependencies.sh +++ b/.buildkite/commands/install-node-dependencies.sh @@ -65,7 +65,6 @@ popd # i18n restore_cache "$I18N_CACHEKEY" - if [[ "${RESTORE_ONLY}" == 'true' ]]; then echo 'Exiting after restoring caches as per --restore-only call parameter.' exit 0 From 6f69d45f5d4a260b122b8a81f05d8de6a4104928 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 14:24:46 +0200 Subject: [PATCH 34/38] Try caching pods folder --- .buildkite/commands/build-ios.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.buildkite/commands/build-ios.sh b/.buildkite/commands/build-ios.sh index 265a7ba2e1..aa47137d2a 100755 --- a/.buildkite/commands/build-ios.sh +++ b/.buildkite/commands/build-ios.sh @@ -1,10 +1,20 @@ #!/bin/bash -eu +PODFILE_HASH=$(hash_file gutenberg/packages/react-native-editor/ios/Podfile.lock) +PODFILE_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pods-$PLATFORM-$ARCHITECTURE-$PODFILE_HASH" +PODS_PATH="gutenberg/packages/react-native-editor/ios" +PODS_FOLDER="Pods" + echo '--- :desktop_computer: Clear up some disk space' rm -rfv ~/.Trash/15.1.xip .buildkite/commands/install-node-dependencies.sh +echo "--- :cocoapods: Restore Pods if present" +pushd "$PODS_PATH" +restore_cache "$PODFILE_CACHEKEY" +popd + echo '--- :ios: Set env var for iOS E2E testing' set -x export TEST_RN_PLATFORM=ios @@ -35,3 +45,8 @@ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \ --form 'payload=@"./gutenberg/packages/react-native-editor/ios/GutenbergDemo.app.zip"' \ --form "name=Gutenberg-$SAUCE_FILENAME.app.zip" \ --form 'description="Gutenberg"' + +echo "--- :cocoapods: Save pods cache if necessary" +pushd "$PODS_PATH" +save_cache "$PODS_FOLDER" "$PODFILE_CACHEKEY" +popd From aa5fb7c328b49616a143445172d44711e17b15d5 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 14:29:40 +0200 Subject: [PATCH 35/38] Add missing vars --- .buildkite/commands/build-ios.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.buildkite/commands/build-ios.sh b/.buildkite/commands/build-ios.sh index aa47137d2a..a3769c049a 100755 --- a/.buildkite/commands/build-ios.sh +++ b/.buildkite/commands/build-ios.sh @@ -1,5 +1,7 @@ #!/bin/bash -eu +PLATFORM=$(uname -s) +ARCHITECTURE=$(uname -m) PODFILE_HASH=$(hash_file gutenberg/packages/react-native-editor/ios/Podfile.lock) PODFILE_CACHEKEY="$BUILDKITE_PIPELINE_SLUG-pods-$PLATFORM-$ARCHITECTURE-$PODFILE_HASH" PODS_PATH="gutenberg/packages/react-native-editor/ios" From fd97c179ae0bc707c6fd906de7401f9269c4aa1b Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 14:46:37 +0200 Subject: [PATCH 36/38] Change comment case --- .buildkite/commands/build-ios.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/build-ios.sh b/.buildkite/commands/build-ios.sh index a3769c049a..81a9696c21 100755 --- a/.buildkite/commands/build-ios.sh +++ b/.buildkite/commands/build-ios.sh @@ -48,7 +48,7 @@ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \ --form "name=Gutenberg-$SAUCE_FILENAME.app.zip" \ --form 'description="Gutenberg"' -echo "--- :cocoapods: Save pods cache if necessary" +echo "--- :cocoapods: Save Pods cache if necessary" pushd "$PODS_PATH" save_cache "$PODS_FOLDER" "$PODFILE_CACHEKEY" popd From c2c6fbf176a7b458a7306a566e6121ec353f159b Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 17:10:02 +0200 Subject: [PATCH 37/38] Update Gutenbeg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index ed98cee6be..1ee3cc7615 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit ed98cee6be47c34e1e563cb3dd1e3211532feccb +Subproject commit 1ee3cc7615773e50077bffb078904cdbe1efbe04 From 4f896297f9bdeb3dfc1e9d15844e477ba9962b07 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 6 Jun 2024 17:47:28 +0200 Subject: [PATCH 38/38] Remove maxWorkers limit --- bin/ci-checks-js.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ci-checks-js.sh b/bin/ci-checks-js.sh index 62182dbd2d..2ab82d51e7 100755 --- a/bin/ci-checks-js.sh +++ b/bin/ci-checks-js.sh @@ -49,11 +49,11 @@ if [ "$CHECK_TESTS" = true ] ; then # we'll run the tests twice (once for each platform) if the platform env var is not set if [[ -z "${TEST_RN_PLATFORM:-}" ]] ; then echo "--- :microscope: :android: Unit tests" - TEST_RN_PLATFORM=android npm run test --maxWorkers=4 > "$LOGS_DIR/android-tests-out.log" || pFail + TEST_RN_PLATFORM=android npm run test > "$LOGS_DIR/android-tests-out.log" || pFail echo "--- :microscope: :ios: Unit tests" - TEST_RN_PLATFORM=ios npm run test --maxWorkers=4 > "$LOGS_DIR/ios-tests-out.log" || pFail + TEST_RN_PLATFORM=ios npm run test > "$LOGS_DIR/ios-tests-out.log" || pFail else echo "--- :microscope: :$TEST_RN_PLATFORM: Unit tests" - npm run test --maxWorkers=4 > "$TEST_RN_PLATFORM-tests-out.log" || pFail + npm run test > "$TEST_RN_PLATFORM-tests-out.log" || pFail fi fi