Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove patch-package and gutenberg clean #6913

Draft
wants to merge 38 commits into
base: try/remove-max-sockets-limit
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e1ed380
NPM Postinstall - Remove patch-package and gutenberg clean
Jun 5, 2024
dd83a38
Update lint command
Jun 5, 2024
a22a24c
Reduce npm installation for linting
Jun 5, 2024
8d5ecdd
Add check cache for lint step
Jun 5, 2024
37fcf42
Add offline flags
Jun 5, 2024
8e4f92d
Use --prefer-offline
Jun 5, 2024
349dcf8
Test check if the files folder from npm exists
Jun 5, 2024
4004a13
Check pnpm folder
Jun 5, 2024
a58e72e
Try pnpm cache folder
Jun 5, 2024
9554af1
Create folder if it doesnt exist
Jun 5, 2024
5dec582
Update pnpm key
Jun 5, 2024
d7ae58f
Fix path
Jun 5, 2024
4c0a9c7
Make npm changes as pnpm
Jun 5, 2024
01f0a9d
Remove log
Jun 5, 2024
41dbd2c
Add i18n cache
Jun 5, 2024
6087ab7
Show errors output if any
Jun 5, 2024
423fd23
Check if the i18 folder exists before saving cache
Jun 5, 2024
dc95660
Try adding cache to the bundle job
Jun 5, 2024
fc766c6
Revert adding cache since its not supported with the docker image
Jun 5, 2024
e738f54
Move bundles to mac agent
Jun 6, 2024
29478f3
Fix tag condition
Jun 6, 2024
2deac96
Get yarn cache folder
Jun 6, 2024
e5475de
Fix iOS casing
Jun 6, 2024
ab464ce
Print yarn path
Jun 6, 2024
fb3d60c
Add yarn cache
Jun 6, 2024
ee93a49
Fix yarn path
Jun 6, 2024
8627dd3
Remove unused docker image
Jun 6, 2024
8fc2aac
Update Gutenberg ref
Jun 6, 2024
dfe0569
Add comments
Jun 6, 2024
d719515
Update yarn installation command
Jun 6, 2024
a77b9d1
Update yarn key
Jun 6, 2024
c3d5aa6
Fix yarn package hash
Jun 6, 2024
6da6c0a
Clean up
Jun 6, 2024
6f69d45
Try caching pods folder
Jun 6, 2024
aa5fb7c
Add missing vars
Jun 6, 2024
fd97c17
Change comment case
Jun 6, 2024
c2c6fbf
Update Gutenbeg ref
Jun 6, 2024
4f89629
Remove maxWorkers limit
Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .buildkite/commands/build-bundles.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .buildkite/commands/build-ios.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/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"
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
Expand Down Expand Up @@ -35,3 +47,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
79 changes: 66 additions & 13 deletions .buildkite/commands/install-node-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,59 @@ done
PLATFORM=$(uname -s)
ARCHITECTURE=$(uname -m)
NODE_VERSION=$(node --version)
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)
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)
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"

# yarn
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
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"
YARN_CACHE_FOLDER="Yarn"
elif [ "$PLATFORM" = "Linux" ]; then
PNPM_PATH="$HOME/.local/share/pnpm"
YARN_PATH="$HOME/.cache"
YARN_CACHE_FOLDER="yarn"
fi

echo "--- :npm: Restore cache if present"
restore_cache "$CACHEKEY"
# npm
pushd "$HOME"
restore_cache "$NPM_CACHEKEY"
popd

# pnpm
mkdir -p "$PNPM_PATH"
pushd "$PNPM_PATH"
restore_cache "$PNPM_CACHEKEY"
popd

# yarn
mkdir -p "$YARN_PATH"
pushd "$YARN_PATH"
restore_cache "$YARN_CACHEKEY"
popd

# i18n
restore_cache "$I18N_CACHEKEY"
if [[ "${RESTORE_ONLY}" == 'true' ]]; then
echo 'Exiting after restoring caches as per --restore-only call parameter.'
exit 0
Expand All @@ -41,7 +84,18 @@ 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"

# 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
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.
Expand All @@ -51,13 +105,12 @@ 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
# pnpm
pushd "$PNPM_PATH"
save_cache "$PNPM_CACHE_FOLDER" "$PNPM_CACHEKEY"
popd

save_cache "$PNPM_PATH" "$PNPM_CACHEKEY"
# yarn
pushd "$YARN_PATH"
save_cache "$YARN_CACHE_FOLDER" "$YARN_CACHEKEY"
popd
10 changes: 9 additions & 1 deletion .buildkite/commands/lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/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 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

echo "--- :node: Lint"
CHECK_CORRECTNESS=true CHECK_TESTS=false ./bin/ci-checks-js.sh
55 changes: 6 additions & 49 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -113,46 +103,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"
Expand Down
12 changes: 3 additions & 9 deletions bin/ci-checks-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -55,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
24 changes: 1 addition & 23 deletions bin/run-block-experiments-command.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -35,4 +13,4 @@ else
fi

# Install only regular dependencies (excluding devDependencies)
npx --silent yarn install --production
npx --silent yarn install --cwd block-experiments --ignore-engines --production --prefer-offline
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 48 files
+1 −1 .github/workflows/php-changes-detection.yml
+1 −1 .github/workflows/rnmobile-ios-runner.yml
+2 −2 .github/workflows/unit-test.yml
+3 −0 backport-changelog/6.6/6737.md
+7 −2 changelog.txt
+1 −1 gutenberg.php
+11 −5 lib/class-wp-theme-json-gutenberg.php
+3 −7 lib/class-wp-theme-json-resolver-gutenberg.php
+10 −10 lib/class-wp-theme-json-schema-gutenberg.php
+1 −1 lib/experimental/kses.php
+2 −2 package-lock.json
+1 −1 package.json
+22 −19 packages/blocks/src/api/parser/fix-custom-classname.js
+1 −1 packages/blocks/src/api/parser/index.js
+32 −0 packages/blocks/src/api/parser/test/index.js
+15 −7 packages/blocks/src/store/selectors.js
+119 −0 packages/blocks/src/store/test/selectors.js
+30 −0 packages/blocks/src/store/utils.js
+2 −10 packages/create-block-interactive-template/block-templates/README.md.mustache
+8 −3 packages/data/src/registry.js
+22 −0 packages/data/src/test/registry.js
+4 −2 packages/dataviews/src/style.scss
+27 −4 packages/e2e-test-utils-playwright/src/request-utils/rest.ts
+26 −0 packages/e2e-tests/plugins/interactive-blocks/directive-each/render.php
+28 −1 packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js
+13 −6 packages/edit-post/src/components/back-button/index.js
+47 −95 packages/edit-site/src/components/editor/index.js
+35 −0 packages/edit-site/src/components/editor/use-editor-title.js
+0 −1 packages/edit-site/src/components/global-styles-sidebar/style.scss
+0 −5 packages/edit-site/src/components/global-styles/style.scss
+93 −0 packages/editor/src/components/editor/index.js
+6 −1 packages/editor/src/components/header/back-button.js
+13 −5 packages/editor/src/components/post-url/panel.js
+3 −1 packages/editor/src/private-apis.js
+6 −2 packages/env/README.md
+8 −2 packages/env/lib/build-docker-compose-config.js
+6 −0 packages/env/lib/config/get-config-from-environment-vars.js
+14 −0 packages/env/lib/config/parse-config.js
+8 −0 packages/env/lib/config/test/__snapshots__/config-integration.js.snap
+38 −0 packages/env/lib/config/test/config-integration.js
+1 −0 packages/env/lib/config/test/parse-config.js
+1 −1 packages/interactivity/src/directives.tsx
+4 −1 packages/react-native-aztec/android/gradle.properties
+4 −1 packages/react-native-bridge/android/gradle.properties
+3 −0 packages/react-native-editor/android/gradle.properties
+5 −0 schemas/json/block.json
+13 −0 test/e2e/specs/interactivity/directive-each.spec.ts
+1 −3 test/performance/playwright.config.ts
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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",
Expand Down Expand Up @@ -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",
"lint:fix": "npm run lint -- --fix",
"xcframework:setup": "./bin/xcframework-setup",
"xcframework:build": "npm run xcframework:setup && pushd ./ios-xcframework && ./build.sh && popd"
Expand Down