Skip to content

Commit 817e168

Browse files
committed
feat: add optional node and npm dependency caching
Similar to #181 but for node and npm. This has to be manually enabled because we don't know the user's package manager.
1 parent 87549ef commit 817e168

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/cd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ on:
8787
type: boolean
8888
required: false
8989
default: false
90+
node-cache-dependency-path:
91+
description: Used to specify the path to a dependency file - package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies (https://github.com/actions/setup-node#caching-global-packages-data)
92+
type: string
93+
required: false
9094

9195
# Playwright
9296
run-playwright:
@@ -334,6 +338,8 @@ jobs:
334338
npm-registry-auth: ${{ inputs.npm-registry-auth }}
335339
go-version: ${{ inputs.go-version }}
336340
go-setup-caching: ${{ inputs.go-setup-caching }}
341+
node-cache: ${{ inputs.package-manager }}
342+
node-cache-dependency-path: ${{ inputs.node-cache-dependency-path }}
337343
node-version: ${{ inputs.node-version }}
338344
golangci-lint-version: ${{ inputs.golangci-lint-version }}
339345
run-playwright: ${{ inputs.run-playwright }}

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ on:
3131
type: string
3232
required: false
3333
go-setup-caching:
34-
description: Defines if setup-go action should have caching enabled (https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs)olangci-lint version to use
34+
description: Defines if setup-go action should have caching enabled (https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs)
3535
type: boolean
3636
required: false
3737
trufflehog-version:
@@ -62,6 +62,10 @@ on:
6262
type: boolean
6363
required: false
6464
default: false
65+
node-cache-dependency-path:
66+
description: Used to specify the path to a dependency file - package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies (https://github.com/actions/setup-node#caching-global-packages-data)
67+
type: string
68+
required: false
6569

6670
# Playwright
6771
run-playwright:
@@ -279,6 +283,8 @@ jobs:
279283
node-version-file: ${{ inputs.plugin-directory }}/.nvmrc
280284
golangci-lint-version: ${{ inputs.golangci-lint-version || env.DEFAULT_GOLANGCI_LINT_VERSION }}
281285
go-setup-caching: ${{ inputs.go-setup-caching }}
286+
node-cache: ${{ inputs.package-manager }}
287+
node-cache-dependency-path: ${{ inputs.node-cache-dependency-path }}
282288

283289
- name: Get secrets from Vault
284290
id: get-secrets

actions/plugins/setup/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ inputs:
1919
description: Node.js version file to use.
2020
required: false
2121
default: ""
22+
node-cache:
23+
description: Used to specify a package manager for caching in the default directory. Supported values npm, yarn, pnpm (https://github.com/actions/setup-node#caching-global-packages-data)
24+
required: false
25+
default: ""
26+
node-cache-dependency-path:
27+
description: Used to specify the path to a dependency file - package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies (https://github.com/actions/setup-node#caching-global-packages-data)
28+
required: false
29+
default: ""
2230

2331
runs:
2432
using: composite
@@ -28,6 +36,8 @@ runs:
2836
with:
2937
node-version: "${{ inputs.node-version }}"
3038
node-version-file: "${{ inputs.node-version-file }}"
39+
cache: "${{ inputs.node-cache }}"
40+
cache-dependency-path: "${{ inputs.node-cache-dependency-path }}"
3141

3242
- name: Go
3343
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0

0 commit comments

Comments
 (0)