Skip to content
14 changes: 14 additions & 0 deletions .github/workflows/reusable-build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Runs the build script.
# - Prepares the directory structure for the ZIP.
Expand All @@ -34,6 +36,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is gutenberg/node_modules excluded?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, wouldn't we want to cache node_modules?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm experimenting to see what the effect of caching this has on the overall time it takes to run the workflow. The setup-node action already caches npm dependencies in an optimized way, so I'm not certain that it's required to cache the node_modules directory. Just testing an assumption before committing to storing an 800MB cache key (the entire repository is limited to 10GB at any given time).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed setup-node only caches the root node_modules directory, not the gutenberg/node_modules directory. But apparently it doesn't even cache the root one, per the docs:

Note: The action does not cache node_modules

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it caches the global npm download cache which has compressed tarballs. This is mainly because the resulting node_modules folder varies for different platforms/operating systems.

My assumption is that the global cache should contain any packages installed on the runner from any package.json file. But to confirm this, we'd have to find a specific dependency found only in the Gutenberg repository and confirm it ends up in the generated cache key (deleting the key manually and then rerunning a workflow that generates a new one with debug mode will output every file included).

If that is the case, then the changes here will actually have no effect at all since the cache already includes the necessary details.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like jest-jasmine2 is a dependency in gutenberg and is found nowhere in the dependency tree for wordpress-develop. Testing this now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With some assistance from Claude, it seems you have to take the sha512 integrity value in the lock file for the package, convert it from base64 to hexadecimal. Then the first 4 digits represent the directory path, and the rest is the name. So for jest-jasmine2 it should be .npm/_cacache/content-v2/sha512/83/c2/05d0c1e40d87834adf69b1e631dc7c7c9e3cba98f9e3d1bbd7e5fd7d4172e09cbe39ba9ccb2eefc45e34bb9b89047afe7b95f9e2791427b1f1ee1e0b7f44ddde0c3c9b5e7c2fc76

I don't see that in the log output, though. So seems it's not the case.

It looks like the reusable Gutenberg build process testing workflow specifies multiple lock files for setup-node. This is probably the best option, but the problem is that the file does not exist until npm install runs. So passing gutenberg/package-lock.json will result in an error.

Any other ideas @westonruter?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the package-lock.json file be pulled down beforehand and written into the gutenberg directory before running npm install at the root? The raw URL for the file should be easy to construct since we have the Gutenberg hash available.

key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-check-built-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Configures caching for Composer.
# - Installs Composer dependencies.
Expand All @@ -41,6 +43,18 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-coding-standards-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
Expand All @@ -39,6 +41,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
Expand Down Expand Up @@ -81,6 +83,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-javascript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
Expand All @@ -40,6 +42,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/reusable-performance-test-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ jobs:
# Performs the following steps:
# - Configure environment variables.
# - Checkout repository.
# - Set up Node.js.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Log debug information.
# - Install npm dependencies.
# - Install Playwright browsers.
Expand Down Expand Up @@ -121,6 +123,18 @@ jobs:
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && '2' || '1' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-phpunit-tests-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ jobs:
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Sets up PHP.
# - Installs Composer dependencies.
Expand Down Expand Up @@ -136,6 +138,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-test-core-build-process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
Expand All @@ -75,6 +77,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

# This date is used to ensure that the PHPCS cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/reusable-test-local-docker-environment-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Retrieves the pinned commit hash for the Gutenberg repository.
# - Configures caching for the /gutenberg directory.
# - Sets up Node.js.
# - Sets up PHP.
# - Installs Composer dependencies.
Expand Down Expand Up @@ -91,6 +93,18 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Retrieve the pinned Gutenberg SHA value
id: gutenberg-pinned-sha
run: echo "sha=$(jq -r '.gutenberg.ref' package.json)" >> "$GITHUB_OUTPUT"

- name: Configure caching for Gutenberg directory.
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
gutenberg
!gutenberg/node_modules/
key: gutenberg-${{ steps.gutenberg-pinned-sha.outputs.sha }}-${{ hashFiles( 'tools/gutenberg/*', 'package*.json', 'Gruntfile.js' ) }}

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand Down
Loading