From 06529fc7d98a72ef792401e171d9f5d37221f6b5 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Tue, 27 Aug 2024 14:24:31 -0700 Subject: [PATCH] [EngSys] re-enable rush build cache (#30818) Use AzureCLI@2 task to generate a SAS for cache write credential so we don't need to store secrets anymore. --- common/config/rush/build-cache.json | 6 +++--- eng/pipelines/templates/steps/build.yml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/config/rush/build-cache.json b/common/config/rush/build-cache.json index f989935aec5..d17431de697 100644 --- a/common/config/rush/build-cache.json +++ b/common/config/rush/build-cache.json @@ -1,12 +1,12 @@ { - "buildCacheEnabled": false, + "buildCacheEnabled": true, // Follow instructions at // https://rushjs.io/pages/maintainer/build_cache/#user-authentication // to authenticate. "cacheProvider": "azure-blob-storage", "azureBlobStorageConfiguration": { - "storageAccountName": "azsdkjsrush", - "storageContainerName": "rush-build-cache", + "storageAccountName": "azuresdkartifacts", + "storageContainerName": "azure-sdk-for-js-rush-cache", "isCacheWriteAllowed": false } } diff --git a/eng/pipelines/templates/steps/build.yml b/eng/pipelines/templates/steps/build.yml index 00f670fb0d6..804b85784a4 100644 --- a/eng/pipelines/templates/steps/build.yml +++ b/eng/pipelines/templates/steps/build.yml @@ -48,12 +48,28 @@ steps: - template: /eng/pipelines/templates/steps/set-artifact-packages.yml parameters: Artifacts: ${{ parameters.Artifacts }} + - ${{ if and(eq(variables['System.TeamProject'], 'internal'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) }}: + - task: AzureCLI@2 + inputs: + azureSubscription: 'Azure SDK Artifacts' + scriptType: 'bash' + scriptLocation: 'inlineScript' + inlineScript: | + az account show + expiry=`date -u -d "45 minutes" '+%Y-%m-%dT%H:%MZ'` + sasToken=$(az storage container generate-sas --account-name azuresdkartifacts --name azure-sdk-for-js-rush-cache --permissions dlrw --auth-mode login --as-user --expiry $expiry --https-only -o tsv) + echo "##vso[task.setvariable variable=rushBuildCacheCred;issecret=true;]$sasToken" # Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times. # The default on Windows is "cores - 1" (microsoft/rushstack#436). - script: | node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max displayName: "Build libraries" + env: + ${{ if and(eq(variables['System.TeamProject'], 'internal'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) }}: + RUSH_BUILD_CACHE_CREDENTIAL: $(rushBuildCacheCred) + RUSH_BUILD_CACHE_WRITE_ALLOWED: 1 + - script: | node eng/tools/rush-runner.js build:samples "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose displayName: "Build samples"