From c5fb8414a4e9cfb3d7e83d7e385361bc60544225 Mon Sep 17 00:00:00 2001 From: Bill Schnurr Date: Fri, 13 Dec 2024 15:14:54 -0800 Subject: [PATCH] cache glass binaries (#8107) (#8108) * cache glass binaries (#8107) * just cache $(Build.SourcesDirectory)\GlassTests * add a variable to skip glassCache * change variabel to param * run glass tests if we are manually trying to clear cache * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * fix param * try to fix param * try to use varaiable * try to fix condition * try to fix condition * fix condition * fix cache name * change skipcache logic * add missing bracket --- Build/templates/run_tests.yml | 22 ++++++++++++++++++++++ azure-pipelines.yml | 13 +++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Build/templates/run_tests.yml b/Build/templates/run_tests.yml index 30b309ffdf..c92b0d71e3 100644 --- a/Build/templates/run_tests.yml +++ b/Build/templates/run_tests.yml @@ -1,3 +1,8 @@ +parameters: +- name: skipGlassCache + type: boolean + default: false + steps: # Install different python versions - template: ./install_python.yml @@ -55,8 +60,17 @@ steps: configuration: $(BuildConfiguration) msbuildArguments: '/p:VSTarget=$(VSTarget) /bl:$(Build.SourcesDirectory)\logs\BuildProduct.binlog' + - task: CacheBeta@2 + displayName: 'Restore glass binaries from cache' + condition: eq('${{ parameters.skipGlassCache }}', 'false') + inputs: + key: 'glass' + path: '$(Build.SourcesDirectory)\GlassTests' + cacheHitVar: 'CACHE_RESTORED' + - task: AzureCLI@2 displayName: 'Acquire an AAD token from a User-Assigned Managed Identity and save it as secret variable DropToken' + condition: and(succeeded(), or(eq(variables['CACHE_RESTORED'], 'false'), eq('${{ parameters.skipGlassCache }}', 'true'))) inputs: azureSubscription: 'PylanceSecureVsIdePublishWithManagedIdentity' scriptType: 'pscore' @@ -72,6 +86,7 @@ steps: # Setup the glass test folder - task: PythonScript@0 displayName: 'Setup glass test folder' + condition: and(succeeded(), or(eq(variables['CACHE_RESTORED'], 'false'), eq('${{ parameters.skipGlassCache }}', 'true'))) env: SYSTEM_ACCESSTOKEN: $(DropToken) inputs: @@ -102,3 +117,10 @@ steps: testRunTitle: 'Glass Tests' testResultsFormat: 'VSTest' failTaskOnFailedTests: true + + - task: CacheBeta@2 + displayName: 'Cache glass binaries' + condition: and(succeeded(), or(eq(variables['CACHE_RESTORED'], 'false'), eq('${{ parameters.skipGlassCache }}', 'true'))) + inputs: + key: 'glass' + path: '$(Build.SourcesDirectory)\GlassTests' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 571c47bd37..81b040e190 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,6 +19,10 @@ parameters: displayName: Debugpy Version type: string default: latest +- name: skipGlassCache + displayName: Skip Glass Cache + type: boolean + default: false # build number format name: $(date:yy)$(DayOfYear)$(rev:.r) @@ -78,6 +82,8 @@ variables: value: false - name: Packaging.EnableSBOMSigning value: false # disabled for now because of known issue + - name: SkipGlassCache + value: ${{ parameters.skipGlassCache }} # If the build ran because of a nightly schedule, force pylance release type to preview - name: pylanceReleaseTypeVar @@ -208,12 +214,15 @@ extends: # Publish test data - template: /Build/templates/publish_test_data.yml@self - # Run tests on mixed mode debugger but only for PR builds - - ${{ if in(variables['Build.Reason'], 'PullRequest') }}: + # Run tests on mixed mode debugger but only for PR builds + - ${{ if or(eq(variables['Build.Reason'], 'PullRequest'), eq(variables['SkipGlassCache'], true)) }}: - job: test displayName: Test steps: - template: /Build/templates/run_tests.yml@self + parameters: + skipGlassCache: ${{ parameters.skipGlassCache }} +