Skip to content

Commit

Permalink
Merge branch 'main' into enableHttp2ForTest
Browse files Browse the repository at this point in the history
  • Loading branch information
annie-mac committed Nov 23, 2024
2 parents ed2b4ba + e9953c1 commit 641ecf2
Show file tree
Hide file tree
Showing 2,389 changed files with 115,975 additions and 30,232 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"sdk/keyvault/test-resources/test-resources.json",
"sdk/keyvault/test-resources-jca/test-resources.json",
"sdk/formrecognizer/azure-ai-formrecognizer/**",
"sdk/formrecognizer/test-resources.json",
"sdk/documentintelligence/azure-ai-documentintelligence/**",
"sdk/documentintelligence/test-resources.json",
"sdk/maps/azure-maps-render/**",
Expand Down
2 changes: 1 addition & 1 deletion common/smoke-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
<version>4.64.0</version> <!-- {x-version-update;com.azure:azure-cosmos;dependency} -->
<version>4.65.0</version> <!-- {x-version-update;com.azure:azure-cosmos;dependency} -->
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@
<!-- Only checks Public Api classes -->
<suppress checks="com.azure.tools.checkstyle.checks.DenyListedWordsCheck" files=".*[/\\](implementation|test)[/\\].*"/>

<!-- Checkstyle suppressions for the auto generated Chat Client Implementation -->
<suppress checks="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck" files="com.azure.communication.chat.implementation.AzureCommunicationChatServiceImpl.java"/>
<!-- Checkstyle suppressions for the auto generated Phone Number Administration Implementation -->
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicyCheck"
files="com.azure.communication.common.implementation.HmacAuthenticationPolicy.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.communication.identity.(CommunicationIdentityClient|CommunicationIdentityAsyncClient).java"/>

<!-- Cosmos sdk suppressions -->
<suppress checks="[a-zA-Z0-9]*" files="[/\\]azure-cosmos-encryption[/\\]src[/\\]test[/\\]"/>
<suppress checks="[a-zA-Z0-9]*" files="[/\\]azure-cosmos-kafka-connect[/\\]src[/\\]test[/\\]"/>
Expand Down Expand Up @@ -170,14 +163,6 @@
<suppress checks="MethodName" files="com.azure.spring.cloud.autoconfigure.implementation.compatibility.AzureSpringBootVersionVerifier.java"/>
<!-- ### end: Spring related suppression -->

<!-- Avoiding PagedFlux check if already using RetriableDownloadFlux. -->
<!-- Issue: https://github.com/Azure/azure-sdk-for-java/issues/22117 -->
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.communication.callingserver.CallingServerAsyncClient"/>

<!-- Checkstyle suppressions to keep HttpPipelinePolicy in implementation folder. -->
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicyCheck"
files="com.azure.communication.callingserver.implementation.RedirectPolicy.java"/>

<!-- Suppress checks for Core Perf package. -->
<suppress checks="Javadoc" files=".*[/\\]azure-core-perf[/\\].*\.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck"
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Cadl-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param (
$ErrorActionPreference = "Stop"
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
. $PSScriptRoot/common.ps1
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

function NpmInstallForProject([string]$workingDirectory) {
Push-Location $workingDirectory
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Cadl-Project-Sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param (

$ErrorActionPreference = "Stop"
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module
$sparseCheckoutFile = ".git/info/sparse-checkout"

function AddSparseCheckoutPath([string]$subDirectory) {
Expand Down
3 changes: 2 additions & 1 deletion eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function Process-ReviewStatusCode($statusCode, $packageName, $apiApprovalStatus,
{
$apiApproved = $false
$apiApprovalDetails = "API Review is not approved for package $($packageName). Release pipeline will fail if API review is not approved for a GA version release. You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
$apiApprovalDetails += " Once your API is approved, re-trigger the release pipeline again."

$packageNameApproved = $false
$packageNameApprovalDetails = ""
Expand Down Expand Up @@ -115,4 +116,4 @@ function Process-ReviewStatusCode($statusCode, $packageName, $apiApprovalStatus,

$packageNameStatus.IsApproved = $packageNameApproved
$packageNameStatus.Details = $packageNameApprovalDetails
}
}
144 changes: 91 additions & 53 deletions eng/common/scripts/Helpers/PSModule-Helpers.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$DefaultPSRepositoryUrl = "https://www.powershellgallery.com/api/v2"
$global:CurrentUserModulePath = ""

function Update-PSModulePathForCI()
Expand Down Expand Up @@ -47,6 +46,69 @@ function Update-PSModulePathForCI()
}
}

function Get-ModuleRepositories([string]$moduleName) {
$DefaultPSRepositoryUrl = "https://www.powershellgallery.com/api/v2"
# List of modules+versions we want to replace with internal feed sources for reliability, security, etc.
$packageFeedOverrides = @{
'powershell-yaml' = 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-tools/nuget/v2'
}

$repoUrls = if ($packageFeedOverrides.Contains("${moduleName}")) {
@($packageFeedOverrides["${moduleName}"], $DefaultPSRepositoryUrl)
} else {
@($DefaultPSRepositoryUrl)
}

return $repoUrls
}

function moduleIsInstalled([string]$moduleName, [string]$version) {
$modules = (Get-Module -ListAvailable $moduleName)
if ($version -as [Version]) {
$modules = $modules.Where({ [Version]$_.Version -ge [Version]$version })
if ($modules.Count -gt 0)
{
Write-Host "Using module $($modules[0].Name) with version $($modules[0].Version)."
return $modules[0]
}
}
return $null
}

function installModule([string]$moduleName, [string]$version, $repoUrl) {
$repo = (Get-PSRepository).Where({ $_.SourceLocation -eq $repoUrl })
if ($repo.Count -eq 0)
{
Register-PSRepository -Name $repoUrl -SourceLocation $repoUrl -InstallationPolicy Trusted
$repo = (Get-PSRepository).Where({ $_.SourceLocation -eq $repoUrl })
if ($repo.Count -eq 0) {
throw "Failed to register package repository $repoUrl."
}
}

if ($repo.InstallationPolicy -ne "Trusted") {
Set-PSRepository -Name $repo.Name -InstallationPolicy "Trusted"
}

Write-Host "Installing module $moduleName with min version $version from $repoUrl"
# Install under CurrentUser scope so that the end up under $CurrentUserModulePath for caching
Install-Module $moduleName -MinimumVersion $version -Repository $repo.Name -Scope CurrentUser -Force
# Ensure module installed
$modules = (Get-Module -ListAvailable $moduleName)
if ($version -as [Version]) {
$modules = $modules.Where({ [Version]$_.Version -ge [Version]$version })
}
if ($modules.Count -eq 0) {
throw "Failed to install module $moduleName with version $version"
}

# Unregister repository as it can cause overlap issues with `dotnet tool install`
# commands using the same devops feed
Unregister-PSRepository -Name $repoUrl

return $modules[0]
}

# Manual test at eng/common-tests/psmodule-helpers/Install-Module-Parallel.ps1
# If we want to use another default repository other then PSGallery we can update the default parameters
function Install-ModuleIfNotInstalled()
Expand All @@ -55,69 +117,45 @@ function Install-ModuleIfNotInstalled()
param(
[string]$moduleName,
[string]$version,
[string]$repositoryUrl = $DefaultPSRepositoryUrl
[string]$repositoryUrl
)

# Check installed modules
$modules = (Get-Module -ListAvailable $moduleName)
if ($version -as [Version]) {
$modules = $modules.Where({ [Version]$_.Version -ge [Version]$version })
}
# Check installed modules before after acquiring lock to avoid a big queue
$module = moduleIsInstalled -moduleName $moduleName -version $version
if ($module) { return $module }

if ($modules.Count -eq 0)
{
# Use double-checked locking to avoid locking when module is already installed
try {
$mutex = New-Object System.Threading.Mutex($false, "Install-ModuleIfNotInstalled")
$null = $mutex.WaitOne()

try {
# Check installed modules again after acquiring lock
$modules = (Get-Module -ListAvailable $moduleName)
if ($version -as [Version]) {
$modules = $modules.Where({ [Version]$_.Version -ge [Version]$version })
}

if ($modules.Count -eq 0)
{
$repositories = (Get-PSRepository).Where({ $_.SourceLocation -eq $repositoryUrl })
if ($repositories.Count -eq 0)
{
Register-PSRepository -Name $repositoryUrl -SourceLocation $repositoryUrl -InstallationPolicy Trusted
$repositories = (Get-PSRepository).Where({ $_.SourceLocation -eq $repositoryUrl })
if ($repositories.Count -eq 0) {
Write-Error "Failed to register package repository $repositoryUrl."
return
}
}
$repository = $repositories[0]

if ($repository.InstallationPolicy -ne "Trusted") {
Set-PSRepository -Name $repository.Name -InstallationPolicy "Trusted"
}

Write-Host "Installing module $moduleName with min version $version from $repositoryUrl"
# Install under CurrentUser scope so that the end up under $CurrentUserModulePath for caching
Install-Module $moduleName -MinimumVersion $version -Repository $repository.Name -Scope CurrentUser -Force

# Ensure module installed
$modules = (Get-Module -ListAvailable $moduleName)
if ($version -as [Version]) {
$modules = $modules.Where({ [Version]$_.Version -ge [Version]$version })
}

if ($modules.Count -eq 0) {
Write-Error "Failed to install module $moduleName with version $version"
return
# Check installed modules again after acquiring lock, in case it has been installed
$module = moduleIsInstalled -moduleName $moduleName -version $version
if ($module) { return $module }

$repoUrls = Get-ModuleRepositories $moduleName

foreach ($url in $repoUrls) {
try {
$module = installModule -moduleName $moduleName -version $version -repoUrl $url
} catch {
if ($url -ne $repoUrls[-1]) {
Write-Warning "Failed to install powershell module from '$url'. Retrying with fallback repository"
Write-Warning $_
continue
} else {
Write-Warning "Failed to install powershell module from $url"
throw
}
}
break
}
finally {
$mutex.ReleaseMutex()
}

Write-Host "Using module '$($module.Name)' with version '$($module.Version)'."
} finally {
$mutex.ReleaseMutex()
}

Write-Host "Using module $($modules[0].Name) with version $($modules[0].Version)."
return $modules[0]
return $module
}

if ($null -ne $env:SYSTEM_TEAMPROJECTID) {
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Helpers/Package-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function CompatibleConvertFrom-Yaml {
$yqPresent = Get-Command 'yq' -ErrorAction SilentlyContinue
if (-not $yqPresent) {
. (Join-Path $PSScriptRoot PSModule-Helpers.ps1)
Install-ModuleIfNotInstalled -WhatIf:$false "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled -WhatIf:$false "powershell-yaml" "0.4.7" | Import-Module
}

# Process the content (for example, you could convert from YAML here)
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/TypeSpec-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ErrorActionPreference = "Stop"
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
. $PSScriptRoot/Helpers/CommandInvocation-Helpers.ps1
. $PSScriptRoot/common.ps1
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

function NpmInstallForProject([string]$workingDirectory) {
Push-Location $workingDirectory
Expand Down
4 changes: 2 additions & 2 deletions eng/common/scripts/TypeSpec-Project-Process.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ param (

. $PSScriptRoot/common.ps1
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

function CreateUpdate-TspLocation([System.Object]$tspConfig, [string]$TypeSpecProjectDirectory, [string]$CommitHash, [string]$repo, [string]$repoRoot, [ref]$isNewSdkProject) {
$additionalDirs = @()
Expand Down Expand Up @@ -225,4 +225,4 @@ if ($SkipSyncAndGenerate -and !$isNewSdkProject) {
}
}

return $sdkProjectFolder
return $sdkProjectFolder
2 changes: 1 addition & 1 deletion eng/common/scripts/TypeSpec-Project-Sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ param (

$ErrorActionPreference = "Stop"
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module
$sparseCheckoutFile = ".git/info/sparse-checkout"

function AddSparseCheckoutPath([string]$subDirectory) {
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Update-DocsMsToc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ param(
. $PSScriptRoot/common.ps1
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1

Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

Set-StrictMode -Version 3

Expand Down
4 changes: 2 additions & 2 deletions eng/common/scripts/Verify-Resource-Ref.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
. (Join-Path $PSScriptRoot common.ps1)
Install-Module -Name powershell-yaml -RequiredVersion 0.4.1 -Force -Scope CurrentUser
Install-Module -Name powershell-yaml -RequiredVersion 0.4.7 -Force -Scope CurrentUser
$ymlfiles = Get-ChildItem $RepoRoot -recurse | Where-Object {$_ -like '*.yml'}
$affectedRepos = [System.Collections.ArrayList]::new()

Expand Down Expand Up @@ -48,4 +48,4 @@ if ($affectedRepos.Count -gt 0)
exit 1
}

Write-Output "All repository resources in yaml files reference a valid tag"
Write-Output "All repository resources in yaml files reference a valid tag"
2 changes: 1 addition & 1 deletion eng/common/scripts/Verify-RestApiSpecLocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (-not $GitHubPat) {

Write-Host "The spec used to release SDK should be from the main branch of Azure/azure-rest-api-specs repository."
Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName, ArtifactLocation:$ArtifactLocation, PackageInfoDirectory:$PackageInfoDirectory."
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

# This function is used to verify the 'require' and 'input-file' settings in autorest.md point to the main branch of Azure/azure-rest-api-specs repository
# input-file may be:
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function GetMatrixConfigFromFile([String] $config) {
}

function GetMatrixConfigFromYaml([String] $yamlConfig) {
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module
# ConvertTo then from json is to make sure the nested values are in PSCustomObject
[MatrixConfig]$config = ConvertFrom-Yaml $yamlConfig -Ordered | ConvertTo-Json -Depth 100 | ConvertFrom-Json
return GetMatrixConfig $config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function CheckDependencies()
}
)

Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module
Install-ModuleIfNotInstalled "powershell-yaml" "0.4.7" | Import-Module

$shouldError = $false
foreach ($dep in $deps) {
Expand Down
18 changes: 9 additions & 9 deletions eng/emitter-package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 641ecf2

Please sign in to comment.