diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4262ae81b1f..29380a12e20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,7 +132,7 @@ jobs: install: '${{ matrix.projectName }}...' build: ${{ ( github.ref_type == 'tag' && 'false' ) || matrix.projectName }} build-type: ${{ ( matrix.testType == 'unit:php' && 'backend' ) || 'full' }} - pull-playwright-cache: ${{ matrix.testEnv.shouldCreate && matrix.testType == 'e2e' }} + pull-playwright-cache: ${{ matrix.testEnv.shouldCreate && ( matrix.testType == 'e2e' || matrix.testType == 'performance' ) }} pull-package-deps: '${{ matrix.projectName }}' - name: 'Update wp-env config' diff --git a/.github/workflows/pr-assess-bundle-size.yml b/.github/workflows/pr-assess-bundle-size.yml index 8e6b2272f8a..d6d9e2298f8 100644 --- a/.github/workflows/pr-assess-bundle-size.yml +++ b/.github/workflows/pr-assess-bundle-size.yml @@ -29,6 +29,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + jobs: build: name: Check Asset Sizes @@ -42,6 +45,8 @@ jobs: uses: ./.github/actions/setup-woocommerce-monorepo with: php-version: false + install: '@woocommerce/plugin-woocommerce...' + build: '@woocommerce/plugin-woocommerce' pull-package-deps: '@woocommerce/plugin-woocommerce' - uses: preactjs/compressed-size-action@f780fd104362cfce9e118f9198df2ee37d12946c @@ -49,9 +54,9 @@ jobs: BROWSERSLIST_IGNORE_OLD_DATA: true with: repo-token: '${{ secrets.GITHUB_TOKEN }}' - pattern: './{packages/js/!(*e2e*|*internal*|*test*|*plugin*|*create*),plugins/woocommerce-blocks}/{build,build-style}/**/*.{js,css}' + pattern: './{packages/js/!(*e2e*|*internal*|*test*|*plugin*|*create*),plugins/woocommerce-blocks,plugins/woocommerce-admin,plugins/woocommerce/client/legacy}/{build,build-style}/**/*.{js,css}' install-script: 'pnpm install --filter="@woocommerce/plugin-woocommerce..." --frozen-lockfile --config.dedupe-peer-dependents=false --ignore-scripts' build-script: '--filter="@woocommerce/plugin-woocommerce" build' - clean-script: '--if-present buildclean' + clean-script: '--if-present clean:build' minimum-change-threshold: 100 omit-unchanged: true diff --git a/.github/workflows/pr-build-live-branch.yml b/.github/workflows/pr-build-live-branch.yml index 42c39a49c93..1e92ffc9793 100644 --- a/.github/workflows/pr-build-live-branch.yml +++ b/.github/workflows/pr-build-live-branch.yml @@ -16,6 +16,9 @@ concurrency: group: build-${{ github.event_name == 'push' && github.run_id || 'pr' }}-${{ github.ref }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + permissions: {} jobs: diff --git a/.github/workflows/scripts/run-metrics.sh b/.github/workflows/scripts/run-metrics.sh index dfb6565b3e8..521c042a980 100755 --- a/.github/workflows/scripts/run-metrics.sh +++ b/.github/workflows/scripts/run-metrics.sh @@ -2,31 +2,79 @@ set -eo pipefail -function title() { - echo -e "\n\033[1m$1\033[0m" -} +# The commented variables are for troubleshooting locally. The commented commands below are also for local troubleshooting. +# GITHUB_EVENT_NAME='pull_request' +# GITHUB_SHA=$(git rev-parse HEAD) +# ARTIFACTS_PATH="$(realpath $(dirname -- ${BASH_SOURCE[0]})/../../../tools/compare-perf)/artifacts" if [[ -z "$GITHUB_EVENT_NAME" ]]; then echo "::error::GITHUB_EVENT_NAME must be set" exit 1 fi -title "Installing NVM" -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash > /dev/null -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -echo "Installed version: $(nvm -v)" +function title() { + echo -e "\n\033[1m$1\033[0m" +} -title "Installing dependencies" -pnpm install --frozen-lockfile --filter="compare-perf" > /dev/null +if [ "$GITHUB_EVENT_NAME" == "push" ] || [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + mkdir -p $ARTIFACTS_PATH && export WP_ARTIFACTS_PATH=$ARTIFACTS_PATH -if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then - title "Comparing performance with trunk" - pnpm --filter="compare-perf" run compare perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA - -elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then - title "Comparing performance with base branch" + # It should be 3d7d7f02017383937f1a4158d433d0e5d44b3dc9, but we pick 55f855a2e6d769b5ae44305b2772eb30d3e721df + # where compare-perf reporting mode was introduced for processing the provided reports. + BASE_SHA=55f855a2e6d769b5ae44305b2772eb30d3e721df + HEAD_BRANCH=$(git rev-parse --abbrev-ref HEAD) WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt) + title "Comparing performance between: $BASE_SHA@trunk (base) and $GITHUB_SHA@$HEAD_BRANCH (head) on WordPress v$WP_VERSION" + + title "##[group]Setting up necessary tooling" + pnpm --filter="@woocommerce/plugin-woocommerce" test:e2e:install > /dev/null & + pnpm install --filter='compare-perf...' --frozen-lockfile --config.dedupe-peer-dependents=false --ignore-scripts + echo '##[endgroup]' + + if test -n "$(find $ARTIFACTS_PATH -maxdepth 1 -name "*_${GITHUB_SHA}_*" -print -quit)"; then + title "Skipping benchmarking head as benchmarking results already available under $ARTIFACTS_PATH" + else + # title "##[group]Building head" + # git -c core.hooksPath=/dev/null checkout --quiet $HEAD_BRANCH > /dev/null && echo 'On' $(git rev-parse HEAD) + # pnpm run --if-present clean:build + # pnpm install --filter='@woocommerce/plugin-woocommerce...' --frozen-lockfile --config.dedupe-peer-dependents=false + # pnpm --filter='@woocommerce/plugin-woocommerce' build + # echo '##[endgroup]' + + title "##[group]Benchmarking head" + RESULTS_ID="editor_${GITHUB_SHA}_round-1" pnpm --filter="@woocommerce/plugin-woocommerce" test:metrics editor + RESULTS_ID="product-editor_${GITHUB_SHA}_round-1" pnpm --filter="@woocommerce/plugin-woocommerce" test:metrics product-editor + echo '##[endgroup]' + fi + + if test -n "$(find $ARTIFACTS_PATH -maxdepth 1 -name "*_${BASE_SHA}_*" -print -quit)"; then + title "Skipping benchmarking baseline as benchmarking results already available under $ARTIFACTS_PATH" + else + title "##[group]Checkout baseline" + git fetch --no-tags --quiet --unshallow origin trunk + echo '##[endgroup]' + + title "##[group]Building baseline" + ( git -c core.hooksPath=/dev/null checkout --quiet $BASE_SHA > /dev/null || git reset --hard $BASE_SHA ) && echo 'On' $(git rev-parse HEAD) + pnpm run --if-present clean:build & + pnpm install --filter='@woocommerce/plugin-woocommerce...' --frozen-lockfile --config.dedupe-peer-dependents=false + pnpm --filter='@woocommerce/plugin-woocommerce' build + echo '##[endgroup]' + + title "##[group]Benchmarking baseline" + RESULTS_ID="editor_${BASE_SHA}_round-1" pnpm --filter="@woocommerce/plugin-woocommerce" test:metrics editor + RESULTS_ID="product-editor_${BASE_SHA}_round-1" pnpm --filter="@woocommerce/plugin-woocommerce" test:metrics product-editor + echo '##[endgroup]' + + # title "##[group]Restoring codebase state back to head" + # git -c core.hooksPath=/dev/null checkout --quiet $HEAD_BRANCH > /dev/null && echo 'On' $(git rev-parse HEAD) + # pnpm install --frozen-lockfile > /dev/null & + # pnpm run --if-present clean:build + # echo '##[endgroup]' + fi + + title "##[group]Processing reports under $ARTIFACTS_PATH" + ls -l $ARTIFACTS_PATH # Updating the WP version used for performance jobs means there’s a high # chance that the reference commit used for performance test stability # becomes incompatible with the WP version. So, every time the "Tested up @@ -36,15 +84,16 @@ elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then # - Be compatible with the new WP version used in the “Tested up to” flag. # - Be tracked on https://www.codevitals.run/project/woo for all existing # metrics. - BASE_SHA=3d7d7f02017383937f1a4158d433d0e5d44b3dc9 - echo "WP_VERSION: $WP_VERSION" IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION" - WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" - pnpm --filter="compare-perf" run compare perf $GITHUB_SHA $BASE_SHA --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR" + pnpm --filter="compare-perf" run compare perf $GITHUB_SHA $BASE_SHA --tests-branch $GITHUB_SHA --wp-version "${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" --ci --skip-benchmarking + echo '##[endgroup]' - title "Publish results to CodeVitals" - COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%cI") - pnpm --filter="compare-perf" run log $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA $BASE_SHA $COMMITTED_AT + if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then + title "##[group]Publish results to CodeVitals" + COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%cI") + pnpm --filter="compare-perf" run log $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA $BASE_SHA $COMMITTED_AT + echo '##[endgroup]' + fi else echo "Unsupported event: $GITHUB_EVENT_NAME" fi diff --git a/README.md b/README.md index 4ff249daa69..06872a31ad4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ To get up and running within the WooCommerce Monorepo, you will need to make sur ### Prerequisites - [NVM](https://github.com/nvm-sh/nvm#installing-and-updating): While you can always install Node through other means, we recommend using NVM to ensure you're aligned with the version used by our development teams. Our repository contains [an `.nvmrc` file](.nvmrc) which helps ensure you are using the correct version of Node. -- [PNPM](https://pnpm.io/installation): Our repository utilizes PNPM to manage project dependencies and run various scripts involved in building and testing projects. +- [PNPM](https://pnpm.io/installation): Our repository utilizes PNPM version 9.1.3 to manage project dependencies and run various scripts involved in building and testing projects. - [PHP 7.4+](https://www.php.net/manual/en/install.php): WooCommerce Core currently features a minimum PHP version of 7.4. It is also needed to run Composer and various project build scripts. See [troubleshooting](DEVELOPMENT.md#troubleshooting) for troubleshooting problems installing PHP. - [Composer](https://getcomposer.org/doc/00-intro.md): We use Composer to manage all of the dependencies for PHP packages and plugins. diff --git a/package.json b/package.json index fb79de58c39..eb8c83b0391 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "lint": "pnpm -r lint", "cherry-pick": "node ./tools/cherry-pick/bin/run", "clean": "rimraf -g '**/node_modules' '**/.wireit' && pnpm store prune", - "buildclean": "git clean --force -d -X ./packages ./plugins ./tools", + "clean:build": "rimraf -g 'packages/js/*/build' 'packages/js/*/build-*' 'packages/js/*/dist' 'plugins/*/build' 'plugins/woocommerce/client/legacy/build' && git clean --force -d -X --quiet ./plugins/woocommerce/assets", "preinstall": "npx only-allow pnpm", "postinstall": "husky", "sync-dependencies": "pnpm exec syncpack -- fix-mismatches", diff --git a/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx b/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx index 94e45e9dd47..cce1a21b986 100644 --- a/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx +++ b/plugins/woocommerce-admin/client/customize-store/intro/color-palettes.tsx @@ -1,8 +1,16 @@ +/** + * External dependencies + */ +import { useInstanceId } from '@wordpress/compose'; +import { __, sprintf } from '@wordpress/i18n'; + /** * Internal dependencies */ import { ColorPalette } from './types'; +const MAX_COLOR_PALETTES = 4; + export const ColorPalettes = ( { colorPalettes, totalPalettes, @@ -10,33 +18,71 @@ export const ColorPalettes = ( { colorPalettes: ColorPalette[]; totalPalettes: number; } ) => { - let extra = null; + const canFit = totalPalettes <= MAX_COLOR_PALETTES; - if ( totalPalettes > 4 ) { - extra =
+ { sprintf( + /* translators: $d is the total amount of color palettes */ + __( + 'There are a total of %d color palettes', + 'woocommerce' + ), + totalPalettes + ) } +
+ ); } return ( -