From fc4dc84e4ff717e7cda5fea86bc04726a8b2c520 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Mon, 6 Jul 2020 21:46:22 -0400 Subject: [PATCH] CI: Use Cache@2 task in place of Lighthouse --- script/vsts/platforms/linux.yml | 33 ++++++++++------- script/vsts/platforms/macos.yml | 60 ++++++++++++++++++++----------- script/vsts/platforms/windows.yml | 47 ++++++++++-------------- 3 files changed, 78 insertions(+), 62 deletions(-) diff --git a/script/vsts/platforms/linux.yml b/script/vsts/platforms/linux.yml index 7342e3eee97..c2913a97253 100644 --- a/script/vsts/platforms/linux.yml +++ b/script/vsts/platforms/linux.yml @@ -30,12 +30,26 @@ jobs: - script: npm install --global npm@6.12.1 displayName: Update npm - - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1 - displayName: Restore node_modules cache + - task: Cache@2 + displayName: Cache node_modules inputs: - keyfile: 'package.json, script/vsts/platforms/linux.yml, **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json' - targetfolder: '**/node_modules, !**/node_modules/**/node_modules' - vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2' + key: 'npm | "$(Agent.OS)" | package.json, package-lock.json, script/vsts/platforms/linux.yml' + path: 'node_modules' + cacheHitVar: MainNodeModulesRestored + + - task: Cache@2 + displayName: Cache script/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | script/package.json, script/package-lock.json, script/vsts/platforms/linux.yml' + path: 'script/node_modules' + cacheHitVar: ScriptNodeModulesRestored + + - task: Cache@2 + displayName: Cache apm/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | apm/package.json, apm/package-lock.json, script/vsts/platforms/linux.yml' + path: 'apm/node_modules' + cacheHitVar: ApmNodeModulesRestored - script: script/bootstrap displayName: Bootstrap build environment @@ -45,14 +59,7 @@ jobs: CC: clang-5.0 CXX: clang++-5.0 npm_config_clang: 1 - condition: ne(variables['CacheRestored'], 'true') - - - task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1 - displayName: Save node_modules cache - inputs: - keyfile: 'package.json, script/vsts/platforms/linux.yml, **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json' - targetfolder: '**/node_modules, !**/node_modules/**/node_modules' - vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2' + condition: or(ne(variables['MainNodeModulesRestored'], 'true'), ne(variables['ScriptNodeModulesRestored'], 'true'), ne(variables['ApmNodeModulesRestored'], 'true')) - script: script/lint displayName: Run linter diff --git a/script/vsts/platforms/macos.yml b/script/vsts/platforms/macos.yml index fe03dce7d2a..cb2115547ac 100644 --- a/script/vsts/platforms/macos.yml +++ b/script/vsts/platforms/macos.yml @@ -20,12 +20,26 @@ jobs: - script: npm install --global npm@6.12.1 displayName: Update npm - - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1 - displayName: Restore node_modules cache + - task: Cache@2 + displayName: Cache node_modules inputs: - keyfile: 'package.json, script/vsts/platforms/macos.yml, **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json' - targetfolder: '**/node_modules, !**/node_modules/**/node_modules' - vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2' + key: 'npm | "$(Agent.OS)" | package.json, package-lock.json, script/vsts/platforms/macos.yml' + path: 'node_modules' + cacheHitVar: MainNodeModulesRestored + + - task: Cache@2 + displayName: Cache script/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | script/package.json, script/package-lock.json, script/vsts/platforms/macos.yml' + path: 'script/node_modules' + cacheHitVar: ScriptNodeModulesRestored + + - task: Cache@2 + displayName: Cache apm/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | apm/package.json, apm/package-lock.json, script/vsts/platforms/macos.yml' + path: 'apm/node_modules' + cacheHitVar: ApmNodeModulesRestored - script: script/bootstrap displayName: Bootstrap build environment @@ -34,14 +48,7 @@ jobs: CI_PROVIDER: VSTS NPM_BIN_PATH: /usr/local/bin/npm npm_config_build_from_source: true - condition: ne(variables['CacheRestored'], 'true') - - - task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1 - displayName: Save node_modules cache - inputs: - keyfile: 'package.json, script/vsts/platforms/macos.yml, **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json' - targetfolder: '**/node_modules, !**/node_modules/**/node_modules' - vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2' + condition: or(ne(variables['MainNodeModulesRestored'], 'true'), ne(variables['ScriptNodeModulesRestored'], 'true'), ne(variables['ApmNodeModulesRestored'], 'true')) - script: script/lint displayName: Run linter @@ -121,12 +128,26 @@ jobs: - script: npm install --global npm@6.12.1 displayName: Update npm - - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1 - displayName: Restore node_modules cache + - task: Cache@2 + displayName: Cache node_modules inputs: - keyfile: 'package.json, script/vsts/platforms/macos.yml, **/package-lock.json, !**/node_modules/**/package-lock.json, !**/.*/**/package-lock.json' - targetfolder: '**/node_modules, !**/node_modules/**/node_modules' - vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2' + key: 'npm | "$(Agent.OS)" | package.json, package-lock.json, script/vsts/platforms/macos.yml' + path: 'node_modules' + cacheHitVar: MainNodeModulesRestored + + - task: Cache@2 + displayName: Cache script/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | script/package.json, script/package-lock.json, script/vsts/platforms/macos.yml' + path: 'script/node_modules' + cacheHitVar: ScriptNodeModulesRestored + + - task: Cache@2 + displayName: Cache apm/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | apm/package.json, apm/package-lock.json, script/vsts/platforms/macos.yml' + path: 'apm/node_modules' + cacheHitVar: ApmNodeModulesRestored # The artifact caching task does not work on forks, so we need to # bootstrap again for pull requests coming from forked repositories. @@ -137,8 +158,7 @@ jobs: CI_PROVIDER: VSTS NPM_BIN_PATH: /usr/local/bin/npm npm_config_build_from_source: true - - condition: ne(variables['CacheRestored'], 'true') + condition: or(ne(variables['MainNodeModulesRestored'], 'true'), ne(variables['ScriptNodeModulesRestored'], 'true'), ne(variables['ApmNodeModulesRestored'], 'true')) - task: DownloadBuildArtifacts@0 displayName: Download atom-mac.zip diff --git a/script/vsts/platforms/windows.yml b/script/vsts/platforms/windows.yml index b0ec07cc447..74e551e9a40 100644 --- a/script/vsts/platforms/windows.yml +++ b/script/vsts/platforms/windows.yml @@ -48,21 +48,26 @@ jobs: npm install displayName: Install Windows build dependencies - - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1 - displayName: Restore node_modules cache (x64) + - task: Cache@2 + displayName: Cache node_modules inputs: - keyfile: 'package.json, script/vsts/platforms/windows.yml, **/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') + key: 'npm | "$(Agent.OS)" | "$(buildArch)" | package.json, package-lock.json, script/vsts/platforms/windows.yml' + path: 'node_modules' + cacheHitVar: MainNodeModulesRestored - - task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1 - displayName: Restore node_modules cache (x86) + - task: Cache@2 + displayName: Cache script/node_modules inputs: - keyfile: 'package.json, script/vsts/platforms/windows.yml, **/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') + key: 'npm | "$(Agent.OS)" | "$(buildArch)" | script/package.json, script/package-lock.json, script/vsts/platforms/windows.yml' + path: 'script/node_modules' + cacheHitVar: ScriptNodeModulesRestored + + - task: Cache@2 + displayName: Cache apm/node_modules + inputs: + key: 'npm | "$(Agent.OS)" | "$(buildArch)" | apm/package.json, apm/package-lock.json, script/vsts/platforms/windows.yml' + path: 'apm/node_modules' + cacheHitVar: ApmNodeModulesRestored - script: | node script\vsts\windows-run.js script\bootstrap.cmd @@ -73,23 +78,7 @@ jobs: NPM_BIN_PATH: "C:\\hostedtoolcache\\windows\\node\\12.13.1\\x64\\npm.cmd" npm_config_build_from_source: true displayName: Bootstrap build environment - condition: ne(variables['CacheRestored'], 'true') - - - task: 1ESLighthouseEng.PipelineArtifactCaching.SaveCacheV1.SaveCache@1 - displayName: Save node_modules cache (x64) - inputs: - keyfile: 'package.json, script/vsts/platforms/windows.yml, **/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.json, script/vsts/platforms/windows.yml, **/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') + condition: or(ne(variables['MainNodeModulesRestored'], 'true'), ne(variables['ScriptNodeModulesRestored'], 'true'), ne(variables['ApmNodeModulesRestored'], 'true')) - script: node script\vsts\windows-run.js script\lint.cmd env: