Skip to content

Commit

Permalink
prep build 04/05
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Apr 5, 2024
2 parents b7541d2 + ac60335 commit d6358ff
Show file tree
Hide file tree
Showing 79 changed files with 2,191 additions and 4,307 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:playwright -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
- name: Archive debug artifacts (screenshots, traces)
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/php-changes-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get changed PHP files
id: changed-files-php
uses: tj-actions/changed-files@20576b4b9ed46d41e2d45a2256e5e2316dde6834 # v43.0.1
uses: tj-actions/changed-files@2d756ea4c53f7f6b397767d8723b3a10a9f35bf2 # v44.0.0
with:
files: |
**.{php}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Use desired version of Java
uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'corretto'
java-version: '17'
Expand Down
93 changes: 77 additions & 16 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ concurrency:

jobs:
unit-js:
name: JavaScript (Node.js ${{ matrix.node }})
name: JavaScript (Node.js ${{ matrix.node }}) ${{ matrix.shard }}
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['20', '21']
shard: ['1/4', '2/4', '3/4', '4/4']

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

Expand All @@ -39,20 +41,55 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Get number of CPU cores
- name: Determine the number of CPU cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2.0.0
id: cpu-cores

- name: npm build
- name: Run build scripts
# It's not necessary to run the full build, since Jest can interpret
# source files with `babel-jest`. Some packages have their own custom
# build tasks, however. These must be run.
run: npx lerna run build

- name: Running the tests
run: npm run test:unit -- --ci --maxWorkers=${{ steps.cpu-cores.outputs.count }} --cacheDirectory="$HOME/.jest-cache"
run: |
npm run test:unit -- \
--ci \
--maxWorkers="${{ steps.cpu-cores.outputs.count }}" \
--shard="${{ matrix.shard }}" \
--cacheDirectory="$HOME/.jest-cache"
unit-js-date:
name: JavaScript Date Tests (Node.js ${{ matrix.node }})
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['20', '21']

steps:
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node
with:
node-version: ${{ matrix.node }}

- name: Determine the number of CPU cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2.0.0
id: cpu-cores

- name: Run build scripts
# It's not necessary to run the full build, since Jest can interpret
# source files with `babel-jest`. Some packages have their own custom
# build tasks, however. These must be run.
run: npx lerna run build

- name: Running the date tests
- name: Run the date tests
run: npm run test:unit:date -- --ci --maxWorkers=${{ steps.cpu-cores.outputs.count }} --cacheDirectory="$HOME/.jest-cache"

compute-previous-wordpress-version:
Expand Down Expand Up @@ -80,9 +117,29 @@ jobs:
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> $GITHUB_OUTPUT
rm versions.json
build-assets:
name: Build JavaScript assets for PHP unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Run build scripts
run: npm run build

- name: Upload built JavaScript assets
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: build-assets
path: ./build/

test-php:
name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.wordpress != '' && format( ' (WP {0}) ', matrix.wordpress ) || '' }} on ubuntu-latest
needs: compute-previous-wordpress-version
needs: [compute-previous-wordpress-version, build-assets]
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
Expand Down Expand Up @@ -114,7 +171,8 @@ jobs:
WP_ENV_CORE: ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

Expand All @@ -129,7 +187,7 @@ jobs:
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2.30.0
uses: shivammathur/setup-php@8872c784b04a1420e81191df5d64fbd59d3d3033 # v2.30.2
with:
php-version: '${{ matrix.php }}'
ini-file: development
Expand All @@ -152,8 +210,11 @@ jobs:
with:
custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")

- name: Npm build
run: npm run build
- name: Download built JavaScript assets
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: build-assets
path: ./build

- name: Docker debug information
run: |
Expand All @@ -165,7 +226,6 @@ jobs:
node --version
curl --version
git --version
svn --version
locale -a
- name: Start Docker environment
Expand Down Expand Up @@ -228,7 +288,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Set up PHP
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2.30.0
uses: shivammathur/setup-php@8872c784b04a1420e81191df5d64fbd59d3d3033 # v2.30.2
with:
php-version: '7.4'
coverage: none
Expand Down Expand Up @@ -292,18 +352,19 @@ jobs:
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Get number of CPU cores
- name: Determine the number of CPU cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2.0.0
id: cpu-cores

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Npm build
- name: Run build scripts
# It's not necessary to run the full build, since Jest can interpret
# source files with `babel-jest`. Some packages have their own custom
# build tasks, however. These must be run.
Expand Down
14 changes: 7 additions & 7 deletions docs/contributors/code/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ See the dedicated guide if you're working with the previous Jest + Puppeteer fra

```bash
# Run all available tests.
npm run test:e2e:playwright
npm run test:e2e

# Run in headed mode.
npm run test:e2e:playwright -- --headed
npm run test:e2e -- --headed

# Run tests with specific browsers (`chromium`, `firefox`, or `webkit`).
npm run test:e2e:playwright -- --project=webkit --project=firefox
npm run test:e2e -- --project=webkit --project=firefox

# Run a single test file.
npm run test:e2e:playwright -- <path_to_test_file> # E.g., npm run test:e2e:playwright -- site-editor/title.spec.js
npm run test:e2e -- <path_to_test_file> # E.g., npm run test:e2e -- site-editor/title.spec.js

# Debugging.
npm run test:e2e:playwright -- --debug
npm run test:e2e -- --debug
```

If you're developing in Linux, it currently requires testing Webkit browsers in headed mode. If you don't want to or can't run it with the GUI (e.g. if you don't have a graphic interface), prepend the command with [`xvfb-run`](https://manpages.ubuntu.com/manpages/xenial/man1/xvfb-run.1.html) to run it in a virtual environment.

```bash
# Run all available tests.
xvfb-run npm run test:e2e:playwright
xvfb-run npm run test:e2e

# Only run webkit tests.
xvfb-run -- npm run test:e2e:playwright -- --project=webkit
xvfb-run -- npm run test:e2e -- --project=webkit
```

## Best practices
Expand Down
5 changes: 1 addition & 4 deletions docs/contributors/code/testing-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,7 @@ However, if the change was intentional, follow these steps to update the snapsho
npm run test:unit -- --updateSnapshot --testPathPattern path/to/tests

# Update snapshot for e2e tests
npm run test:e2e -- --updateSnapshot --testPathPattern path/to/e2e-tests

# Update snapshot for Playwright
npm run test:e2e:playwright -- --update-snapshots path/to/spec
npm run test:e2e -- --update-snapshots path/to/spec
```
1. Review the diff and ensure the changes are expected and intentional.
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This refers to a collection of features that ultimately allows users to edit the

The CSS styles generated by WordPress and enqueued as an embedded stylesheet in the front end of the site. The stylesheet ID is `global-styles-inline-css`. The contents of this stylesheet come from the default `theme.json` of WordPress, the theme's `theme.json`, and the styles provided by the user via the global styles sidebar in the site editor.

See [theme.json reference docs](/docs/reference-guides/theme-json-reference.md)</a>, the [how to guide](/docs/how-to-guides/themes/global-settings-and-styles.md), and an introduction to [styles in the block editor](/docs/explanations/architecture/styles.md).
See [theme.json reference docs](/docs/reference-guides/theme-json-reference/README.md)</a>, the [how to guide](/docs/how-to-guides/themes/global-settings-and-styles.md), and an introduction to [styles in the block editor](/docs/explanations/architecture/styles.md).

Compare to <a href="#block-styles">block styles</a>.

Expand Down
10 changes: 10 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,16 @@ protected function get_layout_styles( $block_metadata ) {
! empty( $base_style_rule['rules'] )
) {
foreach ( $base_style_rule['rules'] as $css_property => $css_value ) {
// Skip rules that reference content size or wide size if they are not defined in the theme.json.
if (
is_string( $css_value ) &&
( str_contains( $css_value, '--global--content-size' ) || str_contains( $css_value, '--global--wide-size' ) ) &&
! isset( $this->theme_json['settings']['layout']['contentSize'] ) &&
! isset( $this->theme_json['settings']['layout']['wideSize'] )
) {
continue;
}

if ( static::is_safe_css_declaration( $css_property, $css_value ) ) {
$declarations[] = array(
'name' => $css_property,
Expand Down
Loading

0 comments on commit d6358ff

Please sign in to comment.