Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to feature/amqp starit up merge #4665

Merged
merged 13 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 17 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,26 @@ CompactNamespaces: true
Cpp11BracedListStyle: true
FixNamespaceComments: true
IndentWidth: 2
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IndentCaseLabels: true
NamespaceIndentation: Inner
PointerAlignment: Left
PenaltyReturnTypeOnItsOwnLine: 300
TabWidth: 2
UseTab: Never
IncludeCategories:
- Regex: '^<windows.h>$'
Priority: 80
# Note: get_env.hpp must be included before any other Azure SDK headers.
- Regex: '^["<]get_env.hpp'
Priority: 10
- Regex: '<[[:alnum:]_.]+>'
Priority: 90
- Regex: '<Azure/.*>'
Priority: 50
- Regex: '^<azure_uamqp_c.*/(amqp_definitions_sequence_no|amqp_definitions_milliseconds|amqp_definitions_terminus_expiry_policy|amqp_definitions_terminus_durability).h>$'
Priority: 60
- Regex: '<azure_.*>'
Priority: 70
- Regex: '^".+'
Priority: 20
2 changes: 2 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"LPSTR",
"LPWSTR",
"MHSM",
"mmdc",
"moxygen",
"MSAL",
"MSRC",
Expand Down Expand Up @@ -154,6 +155,7 @@
"usgoviowa",
"usgovvirginia",
"vcpkg",
"Verdana",
"Viet",
"Viktor",
"vusg",
Expand Down
119 changes: 0 additions & 119 deletions eng/common/pipelines/templates/steps/docs-metadata-release.yml

This file was deleted.

1 change: 1 addition & 0 deletions eng/common/scripts/Test-SampleMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ begin {
"azure-network-watcher",
"azure-notebooks",
"azure-notification-hubs",
"azure-openai",
"azure-open-datasets",
"azure-personalizer",
"azure-pipelines",
Expand Down
15 changes: 10 additions & 5 deletions eng/common/scripts/TypeSpec-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ param (
[Parameter(Position=0)]
[ValidateNotNullOrEmpty()]
[string] $ProjectDirectory,
[Parameter(Position=1)]
[string] $typespecAdditionalOptions ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2
[string] $TypespecAdditionalOptions = $null, ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2
[switch] $SaveInputs = $false ## saves the temporary files during execution, default false
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -80,12 +80,17 @@ try {
}
}
$typespecCompileCommand = "npx tsp compile $mainTypeSpecFile --emit $emitterName$emitterAdditionalOptions"
if ($typespecAdditionalOptions) {
$options = $typespecAdditionalOptions.Split(";");
if ($TypespecAdditionalOptions) {
$options = $TypespecAdditionalOptions.Split(";");
foreach ($option in $options) {
$typespecCompileCommand += " --option $emitterName.$option"
}
}

if ($SaveInputs) {
$typespecCompileCommand += " --option $emitterName.save-inputs=true"
}

Write-Host($typespecCompileCommand)
Invoke-Expression $typespecCompileCommand

Expand All @@ -95,7 +100,7 @@ finally {
Pop-Location
}

$shouldCleanUp = $configuration["cleanup"] ?? $true
$shouldCleanUp = !$SaveInputs
if ($shouldCleanUp) {
Remove-Item $tempFolder -Recurse -Force
}
135 changes: 135 additions & 0 deletions eng/common/scripts/TypeSpec-Project-Process.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# For details see https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/TypeSpec-Project-Scripts.md

[CmdletBinding()]
param (
[Parameter(Position = 0)]
[ValidateNotNullOrEmpty()]
[string] $TypeSpecProjectDirectory, # A directory of `tspconfig.yaml` or a remoteUrl of `tspconfig.yaml`
[Parameter(Position = 1)]
[string] $CommitHash,
[Parameter(Position = 2)]
[string] $RepoUrl
)

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

function CreateUpdate-TspLocation([System.Object]$tspConfig, [string]$TypeSpecProjectDirectory, [string]$CommitHash, [string]$repo, [string]$repoRoot) {
$serviceDir = ""
$additionalDirs = @()

# Parse tspcofig.yaml to get service-dir, additionalDirectories, and package-dir
if ($tspConfig["parameters"] -and $tspConfig["parameters"]["service-dir"]) {
$serviceDir = $tspConfig["parameters"]["service-dir"]["default"];
}
else {
Write-Error "Missing service-dir in parameters section of tspconfig.yaml."
exit 1
}
if ($tspConfig["parameters"]["dependencies"] -and $tspConfig["parameters"]["dependencies"]["additionalDirectories"]) {
$additionalDirs = $tspConfig["parameters"]["dependencies"]["additionalDirectories"];
}

$packageDir = Get-PackageDir $tspConfig

# Create service-dir if not exist
$serviceDir = Join-Path $repoRoot $serviceDir
if (!(Test-Path -Path $serviceDir)) {
New-Item -Path $serviceDir -ItemType Directory
Write-Host "created service folder $serviceDir"
}

# Create package-dir if not exist
$packageDir = Join-Path $serviceDir $packageDir
if (!(Test-Path -Path $packageDir)) {
New-Item -Path $packageDir -ItemType Directory
Write-Host "created package folder $packageDir"
}

# Load tsp-location.yaml if exist
$tspLocationYamlPath = Join-Path $packageDir "tsp-location.yaml"
$tspLocationYaml = @{}
if (Test-Path -Path $tspLocationYamlPath) {
$tspLocationYaml = Get-Content -Path $tspLocationYamlPath -Raw | ConvertFrom-Yaml
}
else {
Write-Host "creating tsp-location.yaml in $packageDir"
}

# Update tsp-location.yaml
$tspLocationYaml["commit"] = $CommitHash
$tspLocationYaml["repo"] = $repo
$tspLocationYaml["directory"] = $TypeSpecProjectDirectory
$tspLocationYaml["additionalDirectories"] = $additionalDirs
$tspLocationYaml |ConvertTo-Yaml | Out-File $tspLocationYamlPath
Write-Host "updated tsp-location.yaml in $packageDir"
return $packageDir
}

function Get-PackageDir([System.Object]$tspConfig) {
$emitterName = ""
if (Test-Path "Function:$GetEmitterNameFn") {
$emitterName = &$GetEmitterNameFn
}
else {
Write-Error "Missing $GetEmitterNameFn function in {$Language} SDK repo script."
exit 1
}
$packageDir = ""
if ($tspConfig["options"] -and $tspConfig["options"]["$emitterName"] -and $tspConfig["options"]["$emitterName"]["package-dir"]) {
$packageDir = $tspConfig["options"]["$emitterName"]["package-dir"]
}
else {
Write-Error "Missing package-dir in $emitterName options of tspconfig.yaml."
exit 1
}
return $packageDir
}

$repo = ""
if ($RepoUrl) {
if ($RepoUrl -match "^https://github.com/(?<repo>[^/]*/azure-rest-api-specs(-pr)?).*") {
$repo = $Matches["repo"]
}
else {
Write-Host "Parameter 'RepoUrl' has incorrect value: $RepoUrl. It should be similar like 'https://github.com/Azure/azure-rest-api-specs'"
exit 1
}
}

$repoRootPath = (Join-Path $PSScriptRoot .. .. ..)
$repoRootPath = Resolve-Path $repoRootPath
$repoRootPath = $repoRootPath -replace "\\", "/"
$tspConfigPath = Join-Path $repoRootPath 'tspconfig.yaml'
# example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml
if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$') {
try {
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "github.com", "raw.githubusercontent.com"
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "/blob/", "/"
Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3
}
catch {
Write-Host "Failed to download '$TypeSpecProjectDirectory'"
Write-Error $_.Exception.Message
return
}
$repo = $Matches["repo"]
$TypeSpecProjectDirectory = $Matches["path"]
$CommitHash = $Matches["commit"]
# TODO support the branch name in url then get the commithash from branch name
} else {
$tspConfigPath = Join-Path $TypeSpecProjectDirectory "tspconfig.yaml"
if (!(Test-Path $tspConfigPath)) {
Write-Error "Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory'"
exit 1
}
}
$tspConfigYaml = Get-Content $tspConfigPath -Raw | ConvertFrom-Yaml
# call CreateUpdate-TspLocation function
$sdkProjectFolder = CreateUpdate-TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $repoRootPath

# call TypeSpec-Project-Sync.ps1
& "$PSScriptRoot/TypeSpec-Project-Sync.ps1" $sdkProjectFolder
# call TypeSpec-Project-Generate.ps1
& "$PSScriptRoot/TypeSpec-Project-Generate.ps1" $sdkProjectFolder
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushIm
if (!$skipPushImages) {
$registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json
$registryName = ($registry | ConvertFrom-Json).name
RunOrExitOnFailure az acr login -n $registryName
RunOrExitOnFailure az acr login -n $registryName --subscription $subscription
}
}

Expand Down Expand Up @@ -387,6 +387,21 @@ function CheckDependencies()
throw "Please update helm to version >= $MIN_HELM_VERSION (current version: $helmVersionString)`nAdditional information for updating helm version can be found here: https://helm.sh/docs/intro/install/"
}

# Ensure docker is running via command and handle command hangs
if (!$skipPushImages) {
$LastErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
$job = Start-Job { docker ps; return $LASTEXITCODE }
$result = $job | Wait-Job -Timeout 5 | Receive-Job

$ErrorActionPreference = $LastErrorActionPreference
$job | Remove-Job -Force

if (($result -eq $null -and $job.State -ne "Completed") -or ($result | Select -Last 1) -ne 0) {
throw "Docker does not appear to be running. Start/restart docker."
}
}

if ($shouldError) {
exit 1
}
Expand Down
4 changes: 3 additions & 1 deletion eng/common/testproxy/publish-proxy-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ steps:
- pwsh: |
Copy-Item -Path "${{ parameters.rootFolder }}/test-proxy.log" -Destination "${{ parameters.rootFolder }}/proxy.log"
displayName: Copy Log File
condition: succeededOrFailed()

- template: ../pipelines/templates/steps/publish-artifact.yml
parameters:
ArtifactName: "$(System.JobName)-proxy-logs"
ArtifactName: "$(System.StageName)-$(System.JobName)-$(System.JobAttempt)-proxy-logs"
ArtifactPath: "${{ parameters.rootFolder }}/proxy.log"

- pwsh: |
Remove-Item -Force ${{ parameters.rootFolder }}/proxy.log
displayName: Cleanup Copied Log File
condition: succeededOrFailed()
Loading