Skip to content

Commit cbbdce7

Browse files
authored
Merge branch 'main' into AzCosmos_GatewayV2_QueryPlanSupport
2 parents 565c608 + 0095ecd commit cbbdce7

1,308 files changed

Lines changed: 21217 additions & 56498 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/breaking-changes-mitigation.md

Lines changed: 409 additions & 0 deletions
Large diffs are not rendered by default.

eng/common/TestResources/SubConfig-Helpers.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ function ShouldMarkValueAsSecret([string]$serviceName, [string]$key, [string]$va
8282
"SERVICE_MANAGEMENT_URL",
8383
"ENDPOINT_SUFFIX",
8484
"SERVICE_DIRECTORY",
85+
"RUST_TEST_THREADS",
86+
"RUST_BACKTRACE",
87+
"COSMOS_RUSTFLAGS",
88+
"DATABASE_NAME",
89+
"ACCOUNT_HOST",
8590
# This is used in many places and is harder to extract from the base subscription config, so hardcode it for now.
8691
"STORAGE_ENDPOINT_SUFFIX",
8792
# Parameters
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
parameters:
2+
- name: DependsOn
3+
type: object
4+
default:
5+
- Signing
6+
- name: Artifacts
7+
type: object
8+
default: []
9+
- name: Condition
10+
type: string
11+
default: succeeded()
12+
13+
stages:
14+
# Post-merge auto-release preparation, shared across language repos (this file lives in the synced
15+
# eng/common tree). Runs after the Signing stage: it resolves the merged PR for Build.SourceVersion,
16+
# requires the auto-release label, maps the PR's changed files to releasable packages via the language
17+
# repo's own package detection (Get-PrPkgProperties -> Get-AllPackageInfoFromRepo), and emits the
18+
# auto-release output variables consumed by each language's release stage.
19+
#
20+
# The stage/job/step names below (AutoReleasePrepare / ResolveAutoReleasePackages / resolve) are the
21+
# fixed cross-language output contract. Downstream release stages read outputs as:
22+
# condition: dependencies.AutoReleasePrepare.outputs['ResolveAutoReleasePackages.resolve.<var>']
23+
# variables: stageDependencies.AutoReleasePrepare.ResolveAutoReleasePackages.outputs['resolve.<var>']
24+
# Emitted variables: AutoReleasePrNumber, AutoReleaseLabelPresent, HasAutoReleaseArtifacts,
25+
# AutoReleaseArtifactsJson, and ReleaseArtifact_<safeName> per declared artifact.
26+
- stage: AutoReleasePrepare
27+
displayName: Auto-release prepare
28+
dependsOn: ${{ parameters.DependsOn }}
29+
condition: ${{ parameters.Condition }}
30+
variables:
31+
- template: /eng/pipelines/templates/variables/globals.yml
32+
- template: /eng/pipelines/templates/variables/image.yml
33+
jobs:
34+
- job: ResolveAutoReleasePackages
35+
displayName: Resolve releasable packages from merged PR
36+
pool:
37+
name: $(LINUXPOOL)
38+
image: $(LINUXVMIMAGE)
39+
os: linux
40+
steps:
41+
# Package detection reads package properties from source, so a checkout is required.
42+
- checkout: self
43+
fetchDepth: 1
44+
45+
- template: /eng/common/pipelines/templates/steps/login-to-github.yml
46+
47+
- task: PowerShell@2
48+
name: resolve
49+
displayName: Determine releasable packages
50+
env:
51+
# convertToJson emits multi-line JSON, so pass it via env instead of the command line.
52+
AUTORELEASE_ARTIFACTS: ${{ convertToJson(parameters.Artifacts) }}
53+
# Map the secret token to env so it is not written to the task command line.
54+
GH_TOKEN: $(GH_TOKEN)
55+
inputs:
56+
pwsh: true
57+
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Resolve-AutoReleasePackages.ps1
58+
arguments: >
59+
-CommitSha "$(Build.SourceVersion)"
60+
-RepoId "$(Build.Repository.Name)"
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Shared auto-release operations used by language repos to resolve the pull request and
2+
# changed-file set that drive post-merge auto-release. Generic GitHub API calls live in
3+
# Invoke-GitHubAPI.ps1; this file holds the auto-release policy and diff-shaping logic.
4+
5+
. "${PSScriptRoot}\logging.ps1"
6+
. "${PSScriptRoot}\Invoke-GitHubAPI.ps1"
7+
8+
# Resolves the auto-release pull request for a commit SHA.
9+
#
10+
# Applies the shared auto-release selection policy:
11+
# 1. Look up the pull requests associated with the commit.
12+
# 2. Keep only pull requests merged into the target branch.
13+
# 3. Select the most recently merged one.
14+
# 4. Re-fetch that pull request by number to read its authoritative merge state and labels.
15+
# 5. Require it to be merged into the target branch and to carry the auto-release label.
16+
#
17+
# Returns a result object:
18+
# PullRequest : the selected PR object, or $null
19+
# PullRequestNumber : the selected PR number, or $null
20+
# IsEligible : $true only when a merged, labeled PR was found
21+
# SkipReason : a human readable reason when IsEligible is $false
22+
function Get-GitHubAutoReleasePullRequestForCommit {
23+
param (
24+
$RepoOwner,
25+
$RepoName,
26+
$RepoId = "$RepoOwner/$RepoName",
27+
[Parameter(Mandatory = $true)]
28+
[ValidateNotNullOrEmpty()]
29+
$CommitSha,
30+
$TargetBranch = "main",
31+
$RequiredLabel = "auto-release",
32+
[ValidateNotNullOrEmpty()]
33+
[Parameter(Mandatory = $true)]
34+
$AuthToken
35+
)
36+
37+
$result = [PSCustomObject]@{
38+
PullRequest = $null
39+
PullRequestNumber = $null
40+
IsEligible = $false
41+
SkipReason = ""
42+
}
43+
44+
$associatedPullRequests = @(Get-GitHubPullRequestsForCommit -RepoId $RepoId -CommitSha $CommitSha -AuthToken $AuthToken)
45+
46+
$mergedToTarget = @(
47+
$associatedPullRequests |
48+
Where-Object { $_.merged_at -and $_.base.ref -eq $TargetBranch }
49+
)
50+
51+
if ($mergedToTarget.Count -eq 0) {
52+
$result.SkipReason = "No merged pull request targeting '$TargetBranch' was associated with commit '$CommitSha'."
53+
return $result
54+
}
55+
56+
$selectedPullRequest = $mergedToTarget |
57+
Sort-Object { [datetime]$_.merged_at } -Descending |
58+
Select-Object -First 1
59+
60+
$result.PullRequestNumber = $selectedPullRequest.number
61+
62+
# Re-fetch the pull request by number to read its authoritative state. The commit -> pulls payload is
63+
# a secondary representation whose labels and merge state can lag the canonical pull request, so
64+
# eligibility (merge target + required label) is decided against this authoritative payload.
65+
$pullRequest = Get-GitHubPullRequest -RepoId $RepoId -PullRequestNumber $selectedPullRequest.number -AuthToken $AuthToken
66+
$result.PullRequest = $pullRequest
67+
68+
if (-not $pullRequest.merged_at -or $pullRequest.base.ref -ne $TargetBranch) {
69+
$result.SkipReason = "Pull request #$($pullRequest.number) is not merged into '$TargetBranch'."
70+
return $result
71+
}
72+
73+
$labels = @($pullRequest.labels | ForEach-Object { $_.name })
74+
if ($RequiredLabel -notin $labels) {
75+
$result.SkipReason = "Pull request #$($pullRequest.number) does not have the required label '$RequiredLabel'."
76+
return $result
77+
}
78+
79+
$result.IsEligible = $true
80+
return $result
81+
}
82+
83+
# Converts GitHub pull request file entries into the Azure SDK PR diff object shape
84+
# consumed by package-detection tooling (compatible with Generate-PR-Diff.ps1 output).
85+
#
86+
# Parameters:
87+
# PullRequestNumber : the PR number recorded in the diff object.
88+
# PullRequestFiles : the file entries returned by Get-GitHubPullRequestFiles.
89+
# ExcludePaths : optional paths to record on the diff object.
90+
#
91+
# Returns a PSCustomObject with ChangedFiles, ChangedServices, ExcludePaths, DeletedFiles, PRNumber.
92+
function New-GitHubPullRequestDiffObject {
93+
param (
94+
[Parameter(Mandatory = $true)]
95+
$PullRequestNumber,
96+
[Parameter(Mandatory = $true)]
97+
[AllowEmptyCollection()]
98+
[array] $PullRequestFiles,
99+
[AllowEmptyCollection()]
100+
[array] $ExcludePaths = @()
101+
)
102+
103+
$changedFiles = @()
104+
$deletedFiles = @()
105+
106+
foreach ($file in $PullRequestFiles) {
107+
$filename = "$($file.filename)" -replace '\\', '/'
108+
109+
if ($file.status -eq 'removed') {
110+
$deletedFiles += $filename
111+
}
112+
else {
113+
$changedFiles += $filename
114+
}
115+
116+
# For renames, include the previous path as deleted so package detection sees both sides of the move.
117+
if ($file.status -eq 'renamed' -and $file.previous_filename) {
118+
$deletedFiles += ("$($file.previous_filename)" -replace '\\', '/')
119+
}
120+
}
121+
122+
$changedFiles = @($changedFiles | Where-Object { $_ } | Sort-Object -Unique)
123+
$deletedFiles = @($deletedFiles | Where-Object { $_ } | Sort-Object -Unique)
124+
125+
$changedServices = @(
126+
$changedFiles + $deletedFiles |
127+
ForEach-Object { if ($_ -match "^sdk/([^/]+)/") { $Matches[1] } } |
128+
Sort-Object -Unique
129+
)
130+
131+
if (-not $ExcludePaths) {
132+
$ExcludePaths = @()
133+
}
134+
135+
return [PSCustomObject]@{
136+
ChangedFiles = $changedFiles
137+
ChangedServices = $changedServices
138+
ExcludePaths = @($ExcludePaths)
139+
DeletedFiles = $deletedFiles
140+
PRNumber = "$PullRequestNumber"
141+
}
142+
}

eng/common/scripts/Invoke-GitHubAPI.ps1

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,66 @@ function Get-GitHubPullRequest {
114114
-MaximumRetryCount 3
115115
}
116116

117+
# Returns the pull requests associated with a commit SHA.
118+
# See https://docs.github.com/rest/commits/commits#list-pull-requests-associated-with-a-commit
119+
function Get-GitHubPullRequestsForCommit {
120+
param (
121+
$RepoOwner,
122+
$RepoName,
123+
$RepoId = "$RepoOwner/$RepoName",
124+
[Parameter(Mandatory = $true)]
125+
[ValidateNotNullOrEmpty()]
126+
$CommitSha,
127+
[ValidateNotNullOrEmpty()]
128+
[Parameter(Mandatory = $true)]
129+
$AuthToken
130+
)
131+
# A commit is associated with ~1 pull request, so a single request is sufficient.
132+
$uri = "$GithubAPIBaseURI/$RepoId/commits/$CommitSha/pulls"
133+
134+
return Invoke-RestMethod `
135+
-Method GET `
136+
-Uri $uri `
137+
-Headers (Get-GitHubApiHeaders -token $AuthToken) `
138+
-MaximumRetryCount 3
139+
}
140+
141+
# Returns the list of files changed in a pull request, following pagination.
142+
# See https://docs.github.com/rest/pulls/pulls#list-pull-requests-files
143+
function Get-GitHubPullRequestFiles {
144+
param (
145+
$RepoOwner,
146+
$RepoName,
147+
$RepoId = "$RepoOwner/$RepoName",
148+
[Parameter(Mandatory = $true)]
149+
[ValidateNotNullOrEmpty()]
150+
$PullRequestNumber,
151+
[ValidateNotNullOrEmpty()]
152+
[Parameter(Mandatory = $true)]
153+
$AuthToken
154+
)
155+
156+
$headers = Get-GitHubApiHeaders -token $AuthToken
157+
$pageSize = 100
158+
$page = 1
159+
$files = @()
160+
161+
do {
162+
$uri = "$GithubAPIBaseURI/$RepoId/pulls/$PullRequestNumber/files?per_page=$pageSize&page=$page"
163+
$response = Invoke-RestMethod `
164+
-Method GET `
165+
-Uri $uri `
166+
-Headers $headers `
167+
-MaximumRetryCount 3
168+
169+
$response = @($response)
170+
if ($response.Count -gt 0) { $files += $response }
171+
$page++
172+
} while ($response.Count -eq $pageSize)
173+
174+
return $files
175+
}
176+
117177
function New-GitHubPullRequest {
118178
param (
119179
$RepoOwner,

0 commit comments

Comments
 (0)