Skip to content

Commit

Permalink
Cache Yarn Packages on build
Browse files Browse the repository at this point in the history
  • Loading branch information
Qstick committed Sep 7, 2020
1 parent 7e701e5 commit d26f38b
Showing 1 changed file with 99 additions and 19 deletions.
118 changes: 99 additions & 19 deletions azure-pipelines.yml
Expand Up @@ -14,6 +14,7 @@ variables:
sentryOrg: 'servarr'
sentryUrl: 'https://sentry.servarr.com'
dotnetVersion: '3.1.401'
yarnCacheFolder: $(Pipeline.Workspace)/.yarn

trigger:
branches:
Expand All @@ -25,9 +26,32 @@ pr:
- develop

stages:
- stage: Setup
displayName: Setup
jobs:
- job:
displayName: Build Variables
pool:
vmImage: 'ubuntu-18.04'
steps:
# Set the build name properly. The 'name' property won't recursively expand so hack here:
- bash: echo "##vso[build.updatebuildnumber]$LIDARRVERSION"
displayName: Set Build Name
- bash: |
if [[ $BUILD_REASON == "PullRequest" ]]; then
git diff origin/develop...HEAD --name-only | grep -E "^(src/|azure-pipelines.yml)"
echo $? > not_backend_update
else
echo 0 > not_backend_update
fi
cat not_backend_update
displayName: Check for Backend File Changes
- publish: not_backend_update
artifact: not_backend_update
displayName: Publish update type
- stage: Build_Backend
displayName: Build Backend
dependsOn: Setup
jobs:
- job: Backend
strategy:
Expand All @@ -48,9 +72,6 @@ stages:
# Disable stylecop here - linting errors get caught by the analyze task
EnableAnalyzers: 'false'
steps:
# Set the build name properly. The 'name' property won't recursively expand so hack here:
- powershell: Write-Host "##vso[build.updatebuildnumber]$($env:LIDARRVERSION)"
displayName: Set Build Name
- checkout: self
submodules: true
fetchDepth: 1
Expand All @@ -77,7 +98,7 @@ stages:
condition: and(succeeded(), eq(variables['osName'], 'Windows'))
- publish: '$(testsFolder)/net462/linux-x64/publish'
artifact: LinuxTests
displayName: Publish Linux Test Package
displayName: Publish Linux Mono Test Package
condition: and(succeeded(), eq(variables['osName'], 'Windows'))
- publish: '$(testsFolder)/netcoreapp3.1/linux-x64/publish'
artifact: LinuxCoreTests
Expand All @@ -94,8 +115,7 @@ stages:

- stage: Build_Frontend
displayName: Frontend
dependsOn: []

dependsOn: Setup
jobs:
- job: Build
strategy:
Expand All @@ -119,10 +139,19 @@ stages:
- checkout: self
submodules: true
fetchDepth: 1
- task: Cache@2
inputs:
key: 'yarn | "$(osName)" | yarn.lock'
restoreKeys: |
yarn | "$(osName)"
yarn
path: $(yarnCacheFolder)
displayName: Cache Yarn packages
- bash: ./build.sh --frontend
displayName: Build Lidarr Frontend
env:
FORCE_COLOR: 0
YARN_CACHE_FOLDER: $(yarnCacheFolder)
- publish: $(outputFolder)
artifact: '$(osName)Frontend'
displayName: Publish Frontend
Expand Down Expand Up @@ -299,8 +328,24 @@ stages:
dependsOn: Build_Backend
condition: succeeded()
jobs:
- job: Prepare
pool:
vmImage: 'ubuntu-18.04'
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'not_backend_update'
targetPath: '.'
- bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)"
name: setVar

- job: Unit
displayName: Unit Native
dependsOn: Prepare
condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0'))

strategy:
matrix:
MacCore:
Expand Down Expand Up @@ -369,12 +414,10 @@ stages:

- job: Unit_Docker
displayName: Unit Docker
dependsOn: Prepare
condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0'))
strategy:
matrix:
mono508:
testName: 'Mono 5.8'
artifactName: LinuxTests
containerImage: servarr/testimages:mono-5.8
mono520:
testName: 'Mono 5.20'
artifactName: LinuxTests
Expand Down Expand Up @@ -431,9 +474,23 @@ stages:
displayName: Integration
dependsOn: Packages
jobs:

- job: Prepare
pool:
vmImage: 'ubuntu-18.04'
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'not_backend_update'
targetPath: '.'
- bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)"
name: setVar

- job: Integration_Native
displayName: Integration Native
dependsOn: Prepare
condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0'))
strategy:
matrix:
MacCore:
Expand Down Expand Up @@ -505,13 +562,10 @@ stages:

- job: Integration_Docker
displayName: Integration Docker
dependsOn: Prepare
condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0'))
strategy:
matrix:
mono508:
testName: 'Mono 5.8'
artifactName: LinuxTests
containerImage: servarr/testimages:mono-5.8
pattern: 'Lidarr.**.linux.tar.gz'
mono520:
testName: 'Mono 5.20'
artifactName: LinuxTests
Expand Down Expand Up @@ -652,7 +706,7 @@ stages:
- bash: |
chmod a+x ${TESTSFOLDER}/test.sh
${TESTSFOLDER}/test.sh ${OSNAME} Automation Test
displayName: Run Integration Tests
displayName: Run Automation Tests
- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
Expand All @@ -662,9 +716,23 @@ stages:
displayName: Publish Test Results

- stage: Analyze
dependsOn: []
dependsOn:
- Setup
displayName: Analyze
jobs:
- job: Prepare
pool:
vmImage: 'ubuntu-18.04'
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'not_backend_update'
targetPath: '.'
- bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)"
name: setVar

- job: Lint_Frontend
displayName: Lint Frontend
strategy:
Expand All @@ -685,10 +753,19 @@ stages:
- checkout: self
submodules: true
fetchDepth: 1
- task: Cache@2
inputs:
key: 'yarn | "$(osName)" | yarn.lock'
restoreKeys: |
yarn | "$(osName)"
yarn
path: $(yarnCacheFolder)
displayName: Cache Yarn packages
- bash: ./build.sh --lint
displayName: Lint Lidarr Frontend
env:
FORCE_COLOR: 0
YARN_CACHE_FOLDER: $(yarnCacheFolder)

- job: Analyze_Frontend
displayName: Frontend
Expand All @@ -713,6 +790,9 @@ stages:

- job: Analyze_Backend
displayName: Backend
dependsOn: Prepare
condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0'))

variables:
disable.coverage.autogenerate: 'true'
pool:
Expand Down

0 comments on commit d26f38b

Please sign in to comment.