-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Disable caching when publishing built assets #79835
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
b665f1c
8feb9ce
983b286
d1f5d01
03bd071
bee5cc9
27ae035
d111a36
95eabe8
d36d9b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,10 @@ inputs: | |
| node-version: | ||
| description: 'Optional. The Node.js version to use. When not specified, the version specified in .nvmrc will be used.' | ||
| required: false | ||
| enable-caching: | ||
| description: 'Whether to enable and configure caching for npm.' | ||
| required: true | ||
| default: 'true' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
|
|
@@ -13,8 +17,8 @@ runs: | |
| with: | ||
| node-version-file: ${{ inputs.node-version == '' && '.nvmrc' || '' }} | ||
| node-version: ${{ inputs.node-version }} | ||
| package-manager-cache: ${{ inputs.enable-caching == 'true' && 'true' || 'false' }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flagged during ai-assisted review The new guards correctly make the
Could we either remove the currently unused composite-action input, or preserve the explicit cache conditionally? cache: ${{ inputs.enable-caching == 'true' && 'npm' || '' }}
package-manager-cache: false |
||
| check-latest: true | ||
|
desrosj marked this conversation as resolved.
|
||
| cache: npm | ||
|
|
||
| - name: Get Node.js and npm version | ||
| id: node-version | ||
|
|
@@ -24,13 +28,14 @@ runs: | |
|
|
||
| - name: Cache node_modules | ||
| id: cache-node_modules | ||
| if: ${{ inputs.enable-caching == 'true' }} | ||
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | ||
| with: | ||
| path: '**/node_modules' | ||
| key: node_modules-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.NODE_VERSION }}-${{ hashFiles('package-lock.json', 'patches/**') }} | ||
|
|
||
| - name: Install npm dependencies | ||
| if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' }} | ||
| if: ${{ inputs.enable-caching == 'false' || steps.cache-node_modules.outputs.cache-hit != 'true' }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If caching is disabled the cache step is skipped, so |
||
| run: | | ||
| npm ci | ||
| shell: bash | ||
|
|
@@ -44,7 +49,7 @@ runs: | |
| # On cache hit, we run the post-install script to match the native `npm ci` behavior. | ||
| # An example of this is to patch `node_modules` using patch-package. | ||
| - name: Post-install | ||
| if: ${{ steps.cache-node_modules.outputs.cache-hit == 'true' }} | ||
| if: ${{ inputs.enable-caching == 'true' && steps.cache-node_modules.outputs.cache-hit == 'true' }} | ||
| run: | | ||
| # Run the post-install script for the root project. | ||
| npm run postinstall | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,6 +244,7 @@ jobs: | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| package-manager-cache: ${{ matrix.IS_GUTENBERG_PLUGIN == 'true' && github.event_name == 'pull_request' && 'true' || 'false' }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flagged during ai-assisted review Keeping npm caching for Gutenberg-plugin PR builds makes sense, but this condition never enables it. Could we make the intended cache input explicit instead, or remove the exception if caching should now stay disabled for all plugin builds? cache: ${{ matrix.IS_GUTENBERG_PLUGIN && github.event_name == 'pull_request' && 'npm' || '' }}
package-manager-cache: false
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'd just drop the string comparison (
ciampo marked this conversation as resolved.
|
||
| check-latest: true | ||
|
|
||
| - name: Configure build for wordpress-develop | ||
|
|
@@ -561,6 +562,7 @@ jobs: | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version-file: 'main/.nvmrc' | ||
| package-manager-cache: false | ||
| registry-url: 'https://registry.npmjs.org' | ||
| check-latest: true | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have a default for a required input?