diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index e6e84f1c8170..3eeebbd99369 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -107,7 +107,7 @@ extends: stages: - ${{ each package in coalesce(parameters.Packages, split(parameters.BuildTargetingString, '|')) }}: - ${{ each cloud in parameters.CloudConfig }}: - - ${{ if or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'tests-weekly'), contains(parameters.SupportedClouds, cloud.key))) }}: + - ${{ if contains(parameters.Clouds, cloud.key) }}: - ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}: - stage: displayName: ${{ format('{0} {1} {2}', cloud.key, parameters.JobName, package) }} @@ -168,9 +168,11 @@ extends: ServiceConnection: ${{ coalesce(cloud.value.ServiceConnection, lower(format('azure-sdk-tests-{0}', cloud.key))) }} SubscriptionConfigurationFilePaths: ${{ cloud.value.SubscriptionConfigurationFilePaths }} - - ${{ if contains(variables['Build.DefinitionName'], 'tests-weekly') }}: + # Analyze-weekly runs only on scheduled runs that start on a weekend (Sat/Sun, UTC). + - ${{ if eq(variables['Build.Reason'], 'Schedule') }}: - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml parameters: BuildTargetingString: ${{ package }} ServiceDirectory: ${{ parameters.ServiceDirectory }} JobName: ${{ parameters.JobName }} + Condition: and(succeeded(), in(format('{0:ddd}', pipeline.startTime), 'Sat', 'Sun')) diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 10277b85fb3f..42b6c09b0e31 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -13,9 +13,10 @@ extends: template: /eng/pipelines/templates/stages/1es-redirect.yml parameters: stages: - - ${{ if contains(variables['Build.DefinitionName'], 'tests-weekly') }}: - - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml - parameters: - ServiceDirectory: ${{ parameters.ServiceDirectory }} - BuildTargetingString: ${{ parameters.BuildTargetingString }} - JobName: ${{ parameters.JobName }} \ No newline at end of file + # Analyze-weekly runs only on scheduled runs that start on a weekend (Sat/Sun, UTC). + - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + BuildTargetingString: ${{ parameters.BuildTargetingString }} + JobName: ${{ parameters.JobName }} + Condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule'), in(format('{0:ddd}', pipeline.startTime), 'Sat', 'Sun')) \ No newline at end of file diff --git a/eng/pipelines/templates/stages/python-analyze-weekly.yml b/eng/pipelines/templates/stages/python-analyze-weekly.yml index 06976f300a98..ed318e3a67db 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly.yml @@ -11,13 +11,20 @@ parameters: - name: JobName type: string default: 'Test' + - name: Condition + type: string + default: succeeded() stages: - stage: displayName: 'Analyze_${{ parameters.JobName }}' variables: - template: /eng/pipelines/templates/variables/image.yml + # Signals the analyze-weekly context to the Python tooling (see ci_tools.variables.in_analyze_weekly). + - name: AZURE_SDK_ANALYZE_WEEKLY + value: '1' dependsOn: [] + condition: ${{ parameters.Condition }} jobs: - job: 'Analyze' timeoutInMinutes: 90 diff --git a/eng/tools/azure-sdk-tools/ci_tools/variables.py b/eng/tools/azure-sdk-tools/ci_tools/variables.py index 5732d3deb9f0..421fc14b9c91 100644 --- a/eng/tools/azure-sdk-tools/ci_tools/variables.py +++ b/eng/tools/azure-sdk-tools/ci_tools/variables.py @@ -84,8 +84,12 @@ def in_public() -> int: def in_analyze_weekly() -> int: - # Returns 4 if the build originates from the tests-weekly analyze job + # Returns 4 if the build originates from the analyze-weekly job # 0 otherwise + # The analyze-weekly stage sets AZURE_SDK_ANALYZE_WEEKLY=1 (see python-analyze-weekly.yml). + if os.getenv("AZURE_SDK_ANALYZE_WEEKLY", "") == "1": + return 4 + # Fallback for pipelines still keyed on the 'tests-weekly' definition name (e.g. identity). if ( "tests-weekly" in os.getenv("SYSTEM_DEFINITIONNAME", "") and os.getenv("SYSTEM_STAGEDISPLAYNAME", "") == "Analyze_Test"