Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into brownfield-notice-w…
Browse files Browse the repository at this point in the history
…orkflow-run
  • Loading branch information
mikeharder committed Dec 5, 2024
2 parents 3e5710c + 2bde125 commit 1c49774
Show file tree
Hide file tree
Showing 781 changed files with 102,612 additions and 6,942 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
/specification/domainservices/ @jihochang

# PRLabel: %Event Grid
/specification/eventgrid/ @Kishp01 @ahamad-MS
/specification/eventgrid/ @lmazuel @jsquire @JoshLove-msft @l0lawrence

# PRLabel: %Event Hubs
/specification/eventhub/ @v-ajnava @dsouzaarun @damodaravadhani
Expand Down
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ updates:
# Updated manually to align with repo microsoft/typespec
- dependency-name: "typescript"
- dependency-name: "prettier"
# Updated manually by the Liftr team
- dependency-name: "@azure-tools/typespec-liftr-base"
# minimatch@9 is the last version to support Node 18
- dependency-name: "minimatch"
versions: [ ">= 10.0.0"]
Expand Down
7 changes: 7 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,13 @@
"billables"
]
},
{
"filename": "**/specification/storage/data-plane/Microsoft.FileStorage/**/*.json",
"words": [
"symboliclink",
"hardlink"
]
},
{
"filename": "**/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-09-01/costmanagement.pricesheets.json",
"words": [
Expand Down
6 changes: 3 additions & 3 deletions eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ function FindOrCreatePackageGroupParent($serviceName, $packageDisplayName, $outp
{
$existingItem = FindParentWorkItem $serviceName $packageDisplayName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag
if ($existingItem) {
Write-Host "Found existing product work item [$($existingItem.id)]"
Write-Verbose "Found existing product work item [$($existingItem.id)]"
$newparentItem = FindOrCreateServiceParent $serviceName -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag
UpdateWorkItemParent $existingItem $newParentItem
return $existingItem
Expand All @@ -552,7 +552,7 @@ function FindOrCreateServiceParent($serviceName, $outputCommand = $true, $ignore
{
$serviceParent = FindParentWorkItem $serviceName -packageDisplayName $null -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag
if ($serviceParent) {
Write-Host "Found existing service work item [$($serviceParent.id)]"
Write-Verbose "Found existing service work item [$($serviceParent.id)]"
return $serviceParent
}

Expand Down Expand Up @@ -1014,4 +1014,4 @@ function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $Pipeli
$workItem = UpdateWorkItem -id $workItem.id -fields $fields
Write-Host "[$($workItem.id)]$LanguageDisplayName - $pkgName($versionMajorMinor) - Updated"
return $true
}
}
6 changes: 3 additions & 3 deletions eng/common/scripts/Helpers/PSModule-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ 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
Register-PSRepository -Name $repoUrl -SourceLocation $repoUrl -InstallationPolicy Trusted | Out-Null
$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"
Set-PSRepository -Name $repo.Name -InstallationPolicy "Trusted" | Out-Null
}

Write-Host "Installing module $moduleName with min version $version from $repoUrl"
Expand All @@ -104,7 +104,7 @@ function installModule([string]$moduleName, [string]$version, $repoUrl) {

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

return $modules[0]
}
Expand Down
144 changes: 91 additions & 53 deletions eng/scripts/Create-APIView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,53 @@
. $PSScriptRoot/ChangedFiles-Functions.ps1
. $PSScriptRoot/../common/scripts/logging.ps1

$defaultTagRegex = "^tag:\s*(?<tag>.+)"
$tagRegex = '^```\s*yaml\s*\$\(tag\)\s*==\s*''(?<tag>.+)'''

<#
.DESCRIPTION
Get the readme.md file associated with a swagger file.
Gets configuration info (tags and configFilePath) associated with a swagger file.
.PARAMETER SwaggerFile
Path to a swagger files inside the 'specification' directory.
.OUTPUTS
the readme.md file associated with the swagger file or null if not found.
the configuration info (tags and configFilePath) or null if not found.
#>
function Get-SwaggerReadMeFile {
param (
[Parameter(Mandatory = $true)]
[string]$SwaggerFile
)
$currentPath = Resolve-Path $SwaggerFile
function Get-AutoRestConfigInfo {
param (
[Parameter(Mandatory = $true)]
[string]$SwaggerFile
)

$currentPath = Resolve-Path $SwaggerFile

while ($currentPath -ne [System.IO.Path]::GetPathRoot($currentPath)) {
$currentPath = [System.IO.Path]::GetDirectoryName($currentPath)
$currentFilePath = [System.IO.Path]::GetFileName($currentPath)
while ($currentPath -ne [System.IO.Path]::GetPathRoot($currentPath)) {
$currentPath = [System.IO.Path]::GetDirectoryName($currentPath)
$currentFilePath = [System.IO.Path]::GetFileName($currentPath)

if ($currentFilePath -eq "specification") {
break
}
if ($currentFilePath -eq "specification") {
break
}

$readmeFile = Get-ChildItem -Path $currentPath -Filter "readme.md" -File -ErrorAction SilentlyContinue
if ($readmeFile -and $readmeFile.Name -eq "readme.md") {
return $readmeFile.FullName
$readmeFile = Get-ChildItem -Path $currentPath -Filter "readme.md" -File -ErrorAction SilentlyContinue
if ($readmeFile -and $readmeFile.Name -eq "readme.md") {
$tagInfo = Get-TagInformationFromReadMeFile -ReadMeFilePath $readmeFile.FullName

if ($tagInfo.DefaultTag) {
$tagInfo | Add-Member -MemberType NoteProperty -Name "ConfigPath" -Value $readmeFile
return $tagInfo
}
}
}

return $null
return $null
}

<#
.DESCRIPTION
Use the directory structure convention to get the resource provider name.
Append the service directory name if there are multiple services in the same resource provider
.PARAMETER ReadMeFilePath
ReadMe File Path for a resource provider.
Expand All @@ -49,13 +58,32 @@ function Get-SwaggerReadMeFile {
#>
function Get-ResourceProviderFromReadMePath {
param (
[Parameter(Mandatory = $true)]
[string]$ReadMeFilePath
[Parameter(Mandatory = $true)]
[string]$ReadMeFilePath
)

$directoryPath = [System.IO.Path]::GetDirectoryName($ReadMeFilePath)
$resourceProviderDirectory = Get-ChildItem -Path $directoryPath -Directory | Select-Object -First 1
return $resourceProviderDirectory.Name
$pathName = [System.IO.Path]::GetFileName($directoryPath)

if ($pathName -eq "resource-manager" -or $pathName -eq "data-plane") {
$resourceProviderDirectory = Get-ChildItem -Path $directoryPath -Directory | Select-Object -First 1
return $resourceProviderDirectory.Name
}
else {
$currentPath = Resolve-Path $directoryPath
$serviceName = $pathName

while ($currentPath -ne [System.IO.Path]::GetPathRoot($currentPath)) {
$pathName = [System.IO.Path]::GetFileName($currentPath)

if ($pathName -eq "resource-manager" -or $pathName -eq "data-plane") {
$resourceProviderDirectory = Get-ChildItem -Path $currentPath -Directory | Select-Object -First 1
return $resourceProviderDirectory.Name + "-" + $serviceName
}
$currentPath = Resolve-Path ([System.IO.Path]::GetDirectoryName($currentPath))
}
}
return $null
}

<#
Expand Down Expand Up @@ -185,18 +213,18 @@ function New-SwaggerAPIViewTokens {
}
LogGroupEnd

# Get Related Swagger ReadMe Files
$swaggerReadMeFiles = [System.Collections.Generic.HashSet[string]]::new()
# Get Related AutoRest Configuration Information
$autoRestConfigInfo = [System.Collections.Generic.Dictionary[string, object]]::new()
$changedSwaggerFiles | ForEach-Object {
$readmeFile = Get-SwaggerReadMeFile -swaggerFile $_
if ($readmeFile) {
$swaggerReadMeFiles.Add($readmeFile) | Out-Null
$configInfo = Get-AutoRestConfigInfo -swaggerFile $_
if ($null -ne $configInfo -and -not $autoRestConfigInfo.ContainsKey($configInfo.ConfigPath)) {
$autoRestConfigInfo[$configInfo.ConfigPath] = $configInfo
}
}

LogGroupStart " Swagger APIView Tokens will be generated for the following configuration files..."
$swaggerReadMeFiles | ForEach-Object {
LogInfo " - $_"
$autoRestConfigInfo.GetEnumerator() | ForEach-Object {
LogInfo " - $($_.Key)"
}
LogGroupEnd

Expand All @@ -205,27 +233,36 @@ function New-SwaggerAPIViewTokens {
$swaggerAPIViewArtifactsDirectory = [System.IO.Path]::Combine($ArtiFactsStagingDirectory, $APIViewArtifactsDirectoryName)

# Generate Swagger APIView Tokens
foreach ($readMeFile in $swaggerReadMeFiles) {
$resourceProvider = Get-ResourceProviderFromReadMePath -ReadMeFilePath $readMeFile
$tokenDirectory = [System.IO.Path]::Combine($swaggerAPIViewArtifactsDirectory, $resourceProvider)
New-Item -ItemType Directory -Path $tokenDirectory | Out-Null

# Generate New APIView Token using default tag on source branch
foreach ($entry in $autoRestConfigInfo.GetEnumerator()) {
$configInfo = $entry.Value
$readMeFile = $entry.Key
git checkout $SourceCommitId
$sourceTagInfo = Get-TagInformationFromReadMeFile -ReadMeFilePath $readMeFile
Invoke-SwaggerAPIViewParser -Type "New" -ReadMeFilePath $readMeFile -ResourceProvider $resourceProvider -TokenDirectory $tokenDirectory `
-TempDirectory $TempDirectory -Tag $sourceTagInfo.DefaultTag | Out-Null

# Generate BaseLine APIView Token using source commit tag on target branch or defaukt tag if source commit tag does not exist
git checkout $TargetCommitId
if (Test-Path -Path $readMeFile) {
$targetTagInfo = Get-TagInformationFromReadMeFile -ReadMeFilePath $readMeFile
$baseLineTag = $targetTagInfo.DefaultTag
if ($targetTagInfo.Tags.Contains($sourceTagInfo.DefaultTag)) {
$baseLineTag = $sourceTagInfo.DefaultTag
if (Test-Path -Path $readmeFile) {
$resourceProvider = Get-ResourceProviderFromReadMePath -ReadMeFilePath $readMeFile
$tokenDirectory = [System.IO.Path]::Combine($swaggerAPIViewArtifactsDirectory, $resourceProvider)
New-Item -ItemType Directory -Path $tokenDirectory -Force | Out-Null

# Generate New APIView Token using default tag on source branch
Invoke-SwaggerAPIViewParser -Type "New" -ReadMeFilePath $readMeFile -ResourceProvider $resourceProvider -TokenDirectory $tokenDirectory `
-TempDirectory $TempDirectory -Tag $configInfo.DefaultTag | Out-Null

# Generate BaseLine APIView Token using source commit tag on target branch or defaukt tag if source commit tag does not exist
git checkout $TargetCommitId
if (Test-Path -Path $readMeFile) {
$targetTagInfo = Get-TagInformationFromReadMeFile -ReadMeFilePath $readMeFile
$baseLineTag = $targetTagInfo.DefaultTag
if ($targetTagInfo.Tags.Contains($configInfo.DefaultTag)) {
$baseLineTag = $configInfo.DefaultTag
}
Invoke-SwaggerAPIViewParser -Type "Baseline" -ReadMeFilePath $readMeFile -ResourceProvider $resourceProvider -TokenDirectory $tokenDirectory `
-TempDirectory $TempDirectory -Tag $baseLineTag | Out-Null
}
else {
LogWarning " Swagger ReadMe file '$readMeFile' not found on TargetBranch. Skipping APIView token generation."
}
Invoke-SwaggerAPIViewParser -Type "Baseline" -ReadMeFilePath $readMeFile -ResourceProvider $resourceProvider -TokenDirectory $tokenDirectory `
-TempDirectory $TempDirectory -Tag $baseLineTag | Out-Null
}
else {
LogWarning " Swagger ReadMe file '$readMeFile' not found on SourceBranch. Skipping APIView token generation."
}
}

Expand Down Expand Up @@ -359,18 +396,19 @@ function Get-TagInformationFromReadMeFile {
$defaultTag = $null

foreach ($line in $markDownContent) {
if ($line -match "### Basic Information") {
$line = $line.Trim()
if ($line -match "###\s+Basic\s+Information") {
$checkForDefaultTag = $true
}

if ($checkForDefaulttag -and ($null -eq $defaultTag)) {
if ($line -match "^tag:\s*(?<tag>.+)") {
if ($line -match $defaultTagRegex) {
$defaultTag = $matches["tag"]
$checkForDefaultTag = $false
}
}

if ($line -match '^```\s*yaml\s*\$\(tag\)\s*==\s*''(?<tag>.+)''') {
if ($line -match $tagRegex) {
$tag = $matches["tag"]
$tags.Add($tag) | Out-Null
}
Expand All @@ -380,4 +418,4 @@ function Get-TagInformationFromReadMeFile {
Tags = $tags
DefaultTag = $defaultTag
}
}
}
Loading

0 comments on commit 1c49774

Please sign in to comment.