Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions eng/pipelines/templates/stages/archetype-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ 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 or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'tests-weekly'), contains(parameters.SupportedClouds, cloud.key))) }}:
- ${{ if contains(parameters.Clouds, cloud.key) }}:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 services set it, but 9 set it to Public (same as the default) — those are unaffected. Only 3 set a non-Public value:

-- | -- | -- | --
Service | Clouds | CloudConfig | Affected?
personalizer | Canary | default (includes Public) | Yes (Can be ignored coz the last run was 2022)
formrecognizer | Prod | custom — only Prod | No
agrifood | Public_FarmBeats | custom — only Public_Farmbeats | No

- ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}:
- stage:
displayName: ${{ format('{0} {1} {2}', cloud.key, parameters.JobName, package) }}
Expand Down Expand Up @@ -168,9 +172,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')
42 changes: 42 additions & 0 deletions eng/pipelines/templates/stages/check-schedule.yml
Original file line number Diff line number Diff line change
@@ -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"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write-Host "##vso[task.setvariable variable=IsWeekend;isOutput=true]$weekend"
name: setflag
displayName: 'Determine weekend from run start time'
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ 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 }}
# 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
- 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'))
12 changes: 11 additions & 1 deletion eng/pipelines/templates/stages/python-analyze-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion eng/tools/azure-sdk-tools/ci_tools/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading