Skip to content

Commit 594447f

Browse files
aminyaDeeDeeG
andcommitted
CI: Cache/restore the npm network/package cache
This saves/restores the caches of just the packages as source code. Not the installed and/or compiled versions, which are in node_modules. (We have already been caching those for some time now.) Co-Authored-By: deedeeg <[email protected]>
1 parent cd3a463 commit 594447f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

script/vsts/platforms/templates/bootstrap.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ steps:
2828
GITHUB_TOKEN: $(GITHUB_TOKEN)
2929
CI: true
3030
CI_PROVIDER: VSTS
31+
npm_config_cache: $(Agent.BuildDirectory)/npm_package_cache_dir
3132
condition: or(ne(variables['MainNodeModulesRestored'], 'true'), ne(variables['ScriptNodeModulesRestored'], 'true'), ne(variables['ApmNodeModulesRestored'], 'true'))

script/vsts/platforms/templates/cache.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ steps:
3737
npm | "$(Agent.OS)" | "$(BUILD_ARCH)"
3838
path: 'apm/node_modules'
3939
cacheHitVar: ApmNodeModulesRestored
40+
41+
- task: Cache@2
42+
displayName: Cache npm package cache
43+
inputs:
44+
key: 'npm_package_cache | "$(Agent.OS)" | "$(BUILD_ARCH)" | script/package-lock.json, apm/package-lock.json, package-lock.json, script/vsts/platforms/${{ parameters.OS }}.yml'
45+
restoreKeys: |
46+
npm_package_cache | "$(Agent.OS)" | "$(BUILD_ARCH)" | script/package-lock.json, apm/package-lock.json, package-lock.json
47+
npm_package_cache | "$(Agent.OS)" | "$(BUILD_ARCH)"
48+
npm_package_cache
49+
path: $(Agent.BuildDirectory)/npm_package_cache_dir

0 commit comments

Comments
 (0)