-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sb-resend-received-message
- Loading branch information
Showing
89 changed files
with
2,639 additions
and
1,125 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
parameters: | ||
EmulatorMsiUrl: "https://aka.ms/cosmosdb-emulator" | ||
StartParameters: '' | ||
|
||
steps: | ||
- powershell: | | ||
$targetDir = $env:temp | ||
Write-Host "Downloading and extracting Cosmos DB Emulator - ${{ parameters.EmulatorMsiUrl }}" | ||
Write-Host "Target Dir: $targetDir" | ||
msiexec /a ${{ parameters.EmulatorMsiUrl }} TARGETDIR=$targetDir /qn | wait-process | ||
displayName: Download and Extract Public Cosmos DB Emulator | ||
- powershell: | | ||
Write-Host "Launching Cosmos DB Emulator" | ||
Import-Module "$env:temp\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator" | ||
Start-CosmosDbEmulator -NoUI ${{ parameters.StartParameters }} | ||
displayName: Start Cosmos DB Emulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
parameters: | ||
TargetVariable: '' | ||
ServiceDirectory: '' | ||
|
||
steps: | ||
- pwsh: | | ||
git clone https://github.com/Azure/azure-sdk-tools.git $(Build.SourcesDirectory)/tools_repo | ||
cd $(Build.SourcesDirectory)/tools_repo | ||
git checkout 564ad63ae72d18422533fa1da9d396e7703c1cb5 | ||
displayName: Setup Identity Resolver | ||
- pwsh: | | ||
$result = dotnet run -v q -- ` | ||
--aad-app-id-var APP_ID ` | ||
--aad-app-secret-var APP_SECRET ` | ||
--aad-tenant-var AAD_TENANT ` | ||
--kusto-url-var KUSTO_URL ` | ||
--kusto-database-var KUSTO_DB ` | ||
--kusto-table-var KUSTO_TABLE ` | ||
--identity "$(Build.QueuedBy)" | ||
$resolvedIdentity = $result[-1] | ConvertFrom-Json | ||
Write-Host $resolvedIdentity | ||
Write-Output "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$($resolvedIdentity.GithubUserName)" | ||
displayName: 'Resolving Queuing User' | ||
workingDirectory: $(Build.SourcesDirectory)/tools_repo/tools/notification-configuration/identity-resolver | ||
env: | ||
APP_ID: $(notification-aad-app-id) | ||
APP_SECRET: $(notification-aad-secret) | ||
AAD_TENANT: $(notification-aad-tenant) | ||
KUSTO_URL: $(notification-kusto-url) | ||
KUSTO_DB: $(notification-kusto-db) | ||
KUSTO_TABLE: $(notification-kusto-table) | ||
- pwsh: | | ||
Remove-Item -Force -Recurse $(Build.SourcesDirectory)/tools_repo | ||
displayName: Clean Up Cloned Tools Repo | ||
- pwsh: | | ||
$originalValue = "$(${{ parameters.TargetVariable }})" | ||
$result = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 -TargetDirectory /sdk/${{ parameters.ServiceDirectory }}/ -RootDirectory $(Build.SourcesDirectory) | ||
if ($result) { | ||
Write-Output "##vso[task.setvariable variable=${{ parameters.TargetVariable }}]$originalValue,$result" | ||
} | ||
displayName: Add CodeOwners if Present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
$RepoOwner, | ||
|
||
[Parameter(Mandatory = $true)] | ||
$RepoName, | ||
|
||
[Parameter(Mandatory = $false)] | ||
$GitHubUsers = "", | ||
|
||
[Parameter(Mandatory = $false)] | ||
$GitHubTeams = "", | ||
|
||
[Parameter(Mandatory = $true)] | ||
$PRNumber, | ||
|
||
[Parameter(Mandatory = $true)] | ||
$AuthToken | ||
) | ||
|
||
# at least one of these needs to be populated | ||
if (-not $GitHubUsers -and -not $GitHubTeams) { | ||
Write-Host "No user provided for addition, exiting." | ||
exit 0 | ||
} | ||
|
||
$userAdditions = @($GitHubUsers.Split(",") | % { $_.Trim() } | ? { return $_ }) | ||
$teamAdditions = @($GitHubTeams.Split(",") | % { $_.Trim() } | ? { return $_ }) | ||
|
||
$headers = @{ | ||
Authorization = "bearer $AuthToken" | ||
} | ||
$uri = "https://api.github.com/repos/$RepoOwner/$RepoName/pulls/$PRNumber/requested_reviewers" | ||
|
||
try { | ||
$resp = Invoke-RestMethod -Headers $headers $uri -MaximumRetryCount 3 | ||
} | ||
catch { | ||
Write-Error "Invoke-RestMethod [$uri] failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
# the response object takes this form: https://developer.github.com/v3/pulls/review_requests/#response-1 | ||
# before we can push a new reviewer, we need to pull the simple Ids out of the complex objects that came back in the response | ||
$userReviewers = @($resp.users | % { return $_.login }) | ||
$teamReviewers = @($resp.teams | % { return $_.slug }) | ||
|
||
if (!$usersReviewers) { $modifiedUserReviewers = @() } else { $modifiedUserReviewers = $usersReviewers.Clone() } | ||
$modifiedUserReviewers += ($modifiedUserReviewers | ? { !$usersReviews.Contains($_) }) | ||
|
||
if ($teamReviewers) { $modifiedTeamReviewers = @() } else { $modifiedTeamReviewers = $teamReviewers.Clone() } | ||
$modifiedTeamReviewers += ($modifiedUserReviewers | ? { !$teamReviewers.Contains($_) }) | ||
|
||
$detectedUserDiffs = Compare-Object -ReferenceObject $userReviewers -DifferenceObject $modifiedUserReviewers | ||
$detectedTeamDiffs = Compare-Object -ReferenceObject $teamReviewers -DifferenceObject $modifiedTeamReviewers | ||
|
||
# Compare-Object returns values when there is a difference between the comparied objects. | ||
# we only want to run the update if there IS a difference. | ||
if ($detectedUserDiffs -or $detectedTeamDiffs) { | ||
$postResp = @{} | ||
|
||
if ($modifiedUserReviewers) { $postResp["reviewers"] = $modifiedUserReviewers } | ||
if ($modifiedTeamReviewers) { $postResp["team_reviewers"] = $modifiedTeamReviewers } | ||
|
||
$postResp = $postResp | ConvertTo-Json | ||
|
||
try { | ||
$resp = Invoke-RestMethod -Method Post -Headers $headers -Body $postResp -Uri $uri -MaximumRetryCount 3 | ||
$resp | Write-Verbose | ||
} | ||
catch { | ||
Write-Error "Unable to update PR reviewers. `n$_" | ||
} | ||
} | ||
else { | ||
$results = $GitHubUsers + $GitHubTeams | ||
Write-Host "Reviewers $results already added. Exiting." | ||
exit(0) | ||
} |
Oops, something went wrong.