Skip to content
Permalink
Browse files

Cache node_modules on Azure Pipelines based on package-lock.json

Co-Authored-By: Nathan Sobo <nathan@github.com>
Co-Authored-By: Rafael Oleza <rafeca@github.com>
  • Loading branch information...
3 people committed Jun 3, 2019
1 parent 6b9b4f9 commit 3be4889b77818b480fae34768e033f546baeb52f
@@ -12,11 +12,26 @@ jobs:
container: atom-linux-ci

steps:
- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: Restore node_modules cache
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'

- script: script/bootstrap
displayName: Bootstrap build environment
env:
CI: true
CI_PROVIDER: VSTS
condition: ne(variables['CacheRestored'], 'true')

- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
displayName: Save node_modules cache
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'

- script: script/lint
displayName: Run linter
@@ -19,12 +19,27 @@ jobs:
- script: npm install --global npm@6.2.0
displayName: Update npm

- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: Restore node_modules cache
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'

- script: script/bootstrap
displayName: Bootstrap build environment
env:
CI: true
CI_PROVIDER: VSTS
NPM_BIN_PATH: /usr/local/bin/npm
condition: ne(variables['CacheRestored'], 'true')

- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
displayName: Save node_modules cache
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'

- script: script/lint
displayName: Run linter
@@ -39,6 +39,22 @@ jobs:
npm install
displayName: Install Windows build dependencies
- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: Restore node_modules cache (x64)
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json, script/vsts/x64-cache-key'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'
condition: eq(variables['buildArch'], 'x64')

- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: Restore node_modules cache (x86)
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json, script/vsts/x86-cache-key'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'
condition: eq(variables['buildArch'], 'x86')

- script: |
node script\vsts\windows-run.js script\bootstrap.cmd
env:
@@ -47,6 +63,23 @@ jobs:
CI_PROVIDER: VSTS
NPM_BIN_PATH: "D:\\a\\_tool\\node\\8.9.3\\x64\\npm.cmd"
displayName: Bootstrap build environment
condition: ne(variables['CacheRestored'], 'true')
- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
displayName: Save node_modules cache (x64)
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json, script/vsts/x64-cache-key'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'
condition: eq(variables['buildArch'], 'x64')

- task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1
displayName: Save node_modules cache (x86)
inputs:
keyfile: '**/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json, script/vsts/x86-cache-key'
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'
condition: eq(variables['buildArch'], 'x86')

- script: node script\vsts\windows-run.js script\lint.cmd
env:
@@ -0,0 +1 @@
x64
@@ -0,0 +1 @@
x86

0 comments on commit 3be4889

Please sign in to comment.
You can’t perform that action at this time.