From 15a4f2002a6c97f88bc9189c95929dc32c38102f Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 10:45:10 -0700 Subject: [PATCH 1/8] Updated test template to handle weekly runs by start time --- .../templates/stages/archetype-sdk-tests.yml | 32 +++++++++++++++- .../python-analyze-weekly-standalone.yml | 37 ++++++++++++++++--- .../stages/python-analyze-weekly.yml | 12 +++++- .../azure-sdk-tools/ci_tools/variables.py | 8 ++-- 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index e6e84f1c8170..e2b5a14dd3de 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -105,9 +105,33 @@ extends: template: /eng/pipelines/templates/stages/1es-redirect.yml parameters: stages: + # On scheduled runs, detect whether the run started on a weekend (in the schedule's timezone). + # Weekend scheduled runs additionally execute the analyze-weekly stage(s) further below. + - ${{ if eq(variables['Build.Reason'], 'Schedule') }}: + - stage: CheckSchedule + displayName: 'Check Schedule' + variables: + - template: /eng/pipelines/templates/variables/image.yml + jobs: + - job: check + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + steps: + - pwsh: | + # Use the same timezone the pipeline schedule is configured in so the + # weekend boundary matches when the run was actually scheduled. + $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) + $weekend = $now.DayOfWeek -in 'Saturday','Sunday' + Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" + Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" + name: setflag + displayName: 'Determine weekend from run start time' - ${{ 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 +192,13 @@ 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 started on a weekend (gated by CheckSchedule). + - ${{ if eq(variables['Build.Reason'], 'Schedule') }}: - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml parameters: BuildTargetingString: ${{ package }} ServiceDirectory: ${{ parameters.ServiceDirectory }} JobName: ${{ parameters.JobName }} + DependsOn: + - CheckSchedule + Condition: eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True') diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 10277b85fb3f..186797d96e7c 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -13,9 +13,34 @@ 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 + # Always present so the pipeline has at least one stage; also determines whether the + # run started on a weekend (in the schedule's timezone) for the analyze gate below. + - stage: CheckSchedule + displayName: 'Check Schedule' + variables: + - template: /eng/pipelines/templates/variables/image.yml + jobs: + - job: check + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + steps: + - pwsh: | + # Use the same timezone the pipeline schedule is configured in so the + # weekend boundary matches when the run was actually scheduled. + $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) + $weekend = $now.DayOfWeek -in 'Saturday','Sunday' + Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" + Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" + name: setflag + displayName: 'Determine weekend from run start time' + - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + BuildTargetingString: ${{ parameters.BuildTargetingString }} + JobName: ${{ parameters.JobName }} + DependsOn: + - CheckSchedule + Condition: and(eq(variables['Build.Reason'], 'Schedule'), eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True')) \ 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..cad450510ae1 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly.yml @@ -11,13 +11,23 @@ parameters: - name: JobName type: string default: 'Test' + - name: DependsOn + type: object + default: [] + - name: Condition + type: string + default: succeeded() stages: - stage: displayName: 'Analyze_${{ parameters.JobName }}' variables: - template: /eng/pipelines/templates/variables/image.yml - dependsOn: [] + # Signals the analyze-weekly context to the Python tooling (see ci_tools.variables.in_analyze_weekly). + - name: AZURE_SDK_ANALYZE_WEEKLY + value: '1' + dependsOn: ${{ parameters.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..f3a9ca3ad28a 100644 --- a/eng/tools/azure-sdk-tools/ci_tools/variables.py +++ b/eng/tools/azure-sdk-tools/ci_tools/variables.py @@ -84,12 +84,10 @@ 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 - if ( - "tests-weekly" in os.getenv("SYSTEM_DEFINITIONNAME", "") - and os.getenv("SYSTEM_STAGEDISPLAYNAME", "") == "Analyze_Test" - ): + # 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 return 0 From d68a6535c6bb44fac3e3995ee52fe779188c8f21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 18:01:21 +0000 Subject: [PATCH 2/8] Use queued time for weekly analyze gate Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> --- .../templates/stages/python-analyze-weekly-standalone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 186797d96e7c..18882f9fb0d7 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -30,7 +30,8 @@ extends: # Use the same timezone the pipeline schedule is configured in so the # weekend boundary matches when the run was actually scheduled. $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) + $runStart = ([datetimeoffset]'$(Build.QueuedTime)').UtcDateTime + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc($runStart, $tz) $weekend = $now.DayOfWeek -in 'Saturday','Sunday' Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" From 3a7183c2545235bd20a77e6f31d6381042a6ba1f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 18:09:44 +0000 Subject: [PATCH 3/8] Use pipeline start time for weekend gating Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> --- eng/pipelines/templates/stages/archetype-sdk-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index e2b5a14dd3de..32a2b110ee78 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -112,6 +112,8 @@ extends: displayName: 'Check Schedule' variables: - template: /eng/pipelines/templates/variables/image.yml + - name: PipelineStartTimeUtc + value: $[ format('{0:O}', pipeline.startTime) ] jobs: - job: check pool: @@ -123,7 +125,8 @@ extends: # Use the same timezone the pipeline schedule is configured in so the # weekend boundary matches when the run was actually scheduled. $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) + $runStart = ([datetimeoffset]'$(PipelineStartTimeUtc)').UtcDateTime + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc($runStart, $tz) $weekend = $now.DayOfWeek -in 'Saturday','Sunday' Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" From 4f37921819be5356d52547933c1756ca6159ed10 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 11:22:11 -0700 Subject: [PATCH 4/8] Reverted back to use utcnow --- eng/pipelines/templates/stages/archetype-sdk-tests.yml | 5 +---- .../templates/stages/python-analyze-weekly-standalone.yml | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index 32a2b110ee78..e2b5a14dd3de 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -112,8 +112,6 @@ extends: displayName: 'Check Schedule' variables: - template: /eng/pipelines/templates/variables/image.yml - - name: PipelineStartTimeUtc - value: $[ format('{0:O}', pipeline.startTime) ] jobs: - job: check pool: @@ -125,8 +123,7 @@ extends: # Use the same timezone the pipeline schedule is configured in so the # weekend boundary matches when the run was actually scheduled. $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $runStart = ([datetimeoffset]'$(PipelineStartTimeUtc)').UtcDateTime - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc($runStart, $tz) + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) $weekend = $now.DayOfWeek -in 'Saturday','Sunday' Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 18882f9fb0d7..186797d96e7c 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -30,8 +30,7 @@ extends: # Use the same timezone the pipeline schedule is configured in so the # weekend boundary matches when the run was actually scheduled. $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $runStart = ([datetimeoffset]'$(Build.QueuedTime)').UtcDateTime - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc($runStart, $tz) + $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) $weekend = $now.DayOfWeek -in 'Saturday','Sunday' Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" From 7c241e565d55c038106e62fee2a361aed07bc43f Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 11:45:54 -0700 Subject: [PATCH 5/8] Added back the change in_analyze_weekly function --- eng/tools/azure-sdk-tools/ci_tools/variables.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eng/tools/azure-sdk-tools/ci_tools/variables.py b/eng/tools/azure-sdk-tools/ci_tools/variables.py index f3a9ca3ad28a..421fc14b9c91 100644 --- a/eng/tools/azure-sdk-tools/ci_tools/variables.py +++ b/eng/tools/azure-sdk-tools/ci_tools/variables.py @@ -89,6 +89,12 @@ def in_analyze_weekly() -> int: # 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" + ): + return 4 return 0 From 9aaa774897acd8f5319a5a452c5c54040825efee Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 13:23:55 -0700 Subject: [PATCH 6/8] Extractred check schedule as shared template and use PipelineStartTime --- .../templates/stages/archetype-sdk-tests.yml | 22 +--------- .../templates/stages/check-schedule.yml | 42 +++++++++++++++++++ .../python-analyze-weekly-standalone.yml | 24 +---------- 3 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 eng/pipelines/templates/stages/check-schedule.yml diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index e2b5a14dd3de..06286a6c45de 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -108,27 +108,7 @@ extends: # On scheduled runs, detect whether the run started on a weekend (in the schedule's timezone). # Weekend scheduled runs additionally execute the analyze-weekly stage(s) further below. - ${{ if eq(variables['Build.Reason'], 'Schedule') }}: - - stage: CheckSchedule - displayName: 'Check Schedule' - variables: - - template: /eng/pipelines/templates/variables/image.yml - jobs: - - job: check - pool: - name: $(LINUXPOOL) - image: $(LINUXVMIMAGE) - os: linux - steps: - - pwsh: | - # Use the same timezone the pipeline schedule is configured in so the - # weekend boundary matches when the run was actually scheduled. - $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) - $weekend = $now.DayOfWeek -in 'Saturday','Sunday' - Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" - Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" - name: setflag - displayName: 'Determine weekend from run start time' + - template: /eng/pipelines/templates/stages/check-schedule.yml - ${{ each package in coalesce(parameters.Packages, split(parameters.BuildTargetingString, '|')) }}: - ${{ each cloud in parameters.CloudConfig }}: - ${{ if contains(parameters.Clouds, cloud.key) }}: diff --git a/eng/pipelines/templates/stages/check-schedule.yml b/eng/pipelines/templates/stages/check-schedule.yml new file mode 100644 index 000000000000..041f19eac5c7 --- /dev/null +++ b/eng/pipelines/templates/stages/check-schedule.yml @@ -0,0 +1,42 @@ +# Emits a lightweight 'CheckSchedule' stage that determines whether the run started on a +# weekend (in the configured timezone) and publishes the result as the output variable +# CheckSchedule.check.setflag.IsWeekend for downstream stages to gate on, e.g.: +# dependsOn: [ CheckSchedule ] +# condition: eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True') +parameters: + - name: TimeZoneId + type: string + default: 'America/Los_Angeles' + +stages: + - stage: CheckSchedule + displayName: 'Check Schedule' + variables: + - template: /eng/pipelines/templates/variables/image.yml + jobs: + - job: check + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + steps: + - pwsh: | + # Derive the weekend flag from the run's start time (System.PipelineStartTime), + # which is fixed at run start and immune to agent queue delay. The value carries a + # timezone offset, so parse it as a DateTimeOffset to get the true UTC instant + # (do NOT cast to [datetime], which would assume the agent's local zone), then + # convert to the timezone the schedule is configured in. + $raw = '$(System.PipelineStartTime)' + try { + $startUtc = [System.DateTimeOffset]::Parse($raw, [System.Globalization.CultureInfo]::InvariantCulture).UtcDateTime + } catch { + Write-Host "Could not parse System.PipelineStartTime ('$raw'); falling back to UtcNow. $_" + $startUtc = [datetime]::UtcNow + } + $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('${{ parameters.TimeZoneId }}') + $local = [System.TimeZoneInfo]::ConvertTimeFromUtc($startUtc, $tz) + $weekend = $local.DayOfWeek -in 'Saturday','Sunday' + Write-Host "PipelineStartTime raw='$raw' -> UTC='$startUtc' -> $($tz.Id)='$local' -> IsWeekend=$weekend" + Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" + name: setflag + displayName: 'Determine weekend from run start time' diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 186797d96e7c..297945185a02 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -13,29 +13,9 @@ extends: template: /eng/pipelines/templates/stages/1es-redirect.yml parameters: stages: - # Always present so the pipeline has at least one stage; also determines whether the + # Always present so the pipeline has at least one stage; determines whether the # run started on a weekend (in the schedule's timezone) for the analyze gate below. - - stage: CheckSchedule - displayName: 'Check Schedule' - variables: - - template: /eng/pipelines/templates/variables/image.yml - jobs: - - job: check - pool: - name: $(LINUXPOOL) - image: $(LINUXVMIMAGE) - os: linux - steps: - - pwsh: | - # Use the same timezone the pipeline schedule is configured in so the - # weekend boundary matches when the run was actually scheduled. - $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('America/Los_Angeles') - $now = [System.TimeZoneInfo]::ConvertTimeFromUtc([datetime]::UtcNow, $tz) - $weekend = $now.DayOfWeek -in 'Saturday','Sunday' - Write-Host "Local time ($($tz.Id)): $now -> IsWeekend=$weekend" - Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" - name: setflag - displayName: 'Determine weekend from run start time' + - template: /eng/pipelines/templates/stages/check-schedule.yml - template: /eng/pipelines/templates/stages/python-analyze-weekly.yml parameters: ServiceDirectory: ${{ parameters.ServiceDirectory }} From 66a853710fdf462397cf343357c0472d086d1da3 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 17:23:48 -0700 Subject: [PATCH 7/8] Removed extra stage and used inline conditions --- .../templates/stages/archetype-sdk-tests.yml | 10 +---- .../templates/stages/check-schedule.yml | 42 ------------------- .../python-analyze-weekly-standalone.yml | 8 +--- 3 files changed, 4 insertions(+), 56 deletions(-) delete mode 100644 eng/pipelines/templates/stages/check-schedule.yml diff --git a/eng/pipelines/templates/stages/archetype-sdk-tests.yml b/eng/pipelines/templates/stages/archetype-sdk-tests.yml index 06286a6c45de..3eeebbd99369 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-tests.yml @@ -105,10 +105,6 @@ extends: template: /eng/pipelines/templates/stages/1es-redirect.yml parameters: stages: - # On scheduled runs, detect whether the run started on a weekend (in the schedule's timezone). - # Weekend scheduled runs additionally execute the analyze-weekly stage(s) further below. - - ${{ if eq(variables['Build.Reason'], 'Schedule') }}: - - template: /eng/pipelines/templates/stages/check-schedule.yml - ${{ each package in coalesce(parameters.Packages, split(parameters.BuildTargetingString, '|')) }}: - ${{ each cloud in parameters.CloudConfig }}: - ${{ if contains(parameters.Clouds, cloud.key) }}: @@ -172,13 +168,11 @@ extends: ServiceConnection: ${{ coalesce(cloud.value.ServiceConnection, lower(format('azure-sdk-tests-{0}', cloud.key))) }} SubscriptionConfigurationFilePaths: ${{ cloud.value.SubscriptionConfigurationFilePaths }} - # Analyze-weekly runs only on scheduled runs that started on a weekend (gated by CheckSchedule). + # 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 }} - DependsOn: - - CheckSchedule - Condition: eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True') + Condition: and(succeeded(), in(format('{0:ddd}', pipeline.startTime), 'Sat', 'Sun')) diff --git a/eng/pipelines/templates/stages/check-schedule.yml b/eng/pipelines/templates/stages/check-schedule.yml deleted file mode 100644 index 041f19eac5c7..000000000000 --- a/eng/pipelines/templates/stages/check-schedule.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Emits a lightweight 'CheckSchedule' stage that determines whether the run started on a -# weekend (in the configured timezone) and publishes the result as the output variable -# CheckSchedule.check.setflag.IsWeekend for downstream stages to gate on, e.g.: -# dependsOn: [ CheckSchedule ] -# condition: eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True') -parameters: - - name: TimeZoneId - type: string - default: 'America/Los_Angeles' - -stages: - - stage: CheckSchedule - displayName: 'Check Schedule' - variables: - - template: /eng/pipelines/templates/variables/image.yml - jobs: - - job: check - pool: - name: $(LINUXPOOL) - image: $(LINUXVMIMAGE) - os: linux - steps: - - pwsh: | - # Derive the weekend flag from the run's start time (System.PipelineStartTime), - # which is fixed at run start and immune to agent queue delay. The value carries a - # timezone offset, so parse it as a DateTimeOffset to get the true UTC instant - # (do NOT cast to [datetime], which would assume the agent's local zone), then - # convert to the timezone the schedule is configured in. - $raw = '$(System.PipelineStartTime)' - try { - $startUtc = [System.DateTimeOffset]::Parse($raw, [System.Globalization.CultureInfo]::InvariantCulture).UtcDateTime - } catch { - Write-Host "Could not parse System.PipelineStartTime ('$raw'); falling back to UtcNow. $_" - $startUtc = [datetime]::UtcNow - } - $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById('${{ parameters.TimeZoneId }}') - $local = [System.TimeZoneInfo]::ConvertTimeFromUtc($startUtc, $tz) - $weekend = $local.DayOfWeek -in 'Saturday','Sunday' - Write-Host "PipelineStartTime raw='$raw' -> UTC='$startUtc' -> $($tz.Id)='$local' -> IsWeekend=$weekend" - Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend" - name: setflag - displayName: 'Determine weekend from run start time' diff --git a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml index 297945185a02..42b6c09b0e31 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml @@ -13,14 +13,10 @@ extends: template: /eng/pipelines/templates/stages/1es-redirect.yml parameters: stages: - # Always present so the pipeline has at least one stage; determines whether the - # run started on a weekend (in the schedule's timezone) for the analyze gate below. - - template: /eng/pipelines/templates/stages/check-schedule.yml + # 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 }} - DependsOn: - - CheckSchedule - Condition: and(eq(variables['Build.Reason'], 'Schedule'), eq(dependencies.CheckSchedule.outputs['check.setflag.IsWeekend'], 'True')) \ No newline at end of file + Condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule'), in(format('{0:ddd}', pipeline.startTime), 'Sat', 'Sun')) \ No newline at end of file From a79c76965965819d65facca0329d1edf22f6f851 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 31 Jul 2026 17:33:09 -0700 Subject: [PATCH 8/8] Removed dependson param --- eng/pipelines/templates/stages/python-analyze-weekly.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eng/pipelines/templates/stages/python-analyze-weekly.yml b/eng/pipelines/templates/stages/python-analyze-weekly.yml index cad450510ae1..ed318e3a67db 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly.yml @@ -11,9 +11,6 @@ parameters: - name: JobName type: string default: 'Test' - - name: DependsOn - type: object - default: [] - name: Condition type: string default: succeeded() @@ -26,7 +23,7 @@ stages: # Signals the analyze-weekly context to the Python tooling (see ci_tools.variables.in_analyze_weekly). - name: AZURE_SDK_ANALYZE_WEEKLY value: '1' - dependsOn: ${{ parameters.DependsOn }} + dependsOn: [] condition: ${{ parameters.Condition }} jobs: - job: 'Analyze'