From 9128b31d894af50b5ae65463fb79076dcefd173a Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 11 Sep 2023 08:52:48 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools repository (#38606) --- .../Service-Level-Readme-Automation.ps1 | 42 +++++++++++++------ .../Verify-RequiredDocsJsonMembers.ps1 | 10 +++++ .../stress-test-deployment-lib.ps1 | 2 +- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/eng/common/scripts/Service-Level-Readme-Automation.ps1 b/eng/common/scripts/Service-Level-Readme-Automation.ps1 index 2d0e5c67920a9..e7dcbf7bf5fd5 100644 --- a/eng/common/scripts/Service-Level-Readme-Automation.ps1 +++ b/eng/common/scripts/Service-Level-Readme-Automation.ps1 @@ -1,12 +1,12 @@ <# .SYNOPSIS -The script is to generate service level readme if it is missing. +The script is to generate service level readme if it is missing. For exist ones, we do 2 things here: 1. Generate the client but not import to the existing service level readme. 2. Update the metadata of service level readme .DESCRIPTION -Given a doc repo location, and the credential for fetching the ms.author. +Given a doc repo location, and the credential for fetching the ms.author. Generate missing service level readme and updating metadata of the existing ones. .PARAMETER DocRepoLocation @@ -53,9 +53,9 @@ $fullMetadata = Get-CSVMetadata $monikers = @("latest", "preview") foreach($moniker in $monikers) { # The onboarded packages return is key-value pair, which key is the package index, and value is the package info from {metadata}.json - # E.g. + # E.g. # Key as: @azure/storage-blob - # Value as: + # Value as: # { # "Name": "@azure/storage-blob", # "Version": "12.10.0-beta.1", @@ -73,22 +73,38 @@ foreach($moniker in $monikers) { $onboardedPackages = &$GetOnboardedDocsMsPackagesForMonikerFn ` -DocRepoLocation $DocRepoLocation -moniker $moniker $csvMetadata = @() + foreach($metadataEntry in $fullMetadata) { if ($metadataEntry.Package -and $metadataEntry.Hide -ne 'true') { $pkgKey = GetPackageKey $metadataEntry - if($onboardedPackages.ContainsKey($pkgKey)) { - if ($onboardedPackages[$pkgKey] -and $onboardedPackages[$pkgKey].DirectoryPath) { - if (!($metadataEntry.PSObject.Members.Name -contains "DirectoryPath")) { - Add-Member -InputObject $metadataEntry ` - -MemberType NoteProperty ` - -Name DirectoryPath ` - -Value $onboardedPackages[$pkgKey].DirectoryPath - } - } + + if (!$onboardedPackages.ContainsKey($pkgKey)) { + continue + } + + $package = $onboardedPackages[$pkgKey] + + if (!$package) { $csvMetadata += $metadataEntry + continue } + + # If the metadata JSON entry has a DirectoryPath, but the CSV entry + # does not, add the DirectoryPath to the CSV entry + if (($package.PSObject.Members.Name -contains 'DirectoryPath') ` + -and !($metadataEntry.PSObject.Members.Name -contains "DirectoryPath") ) { + + Add-Member -InputObject $metadataEntry ` + -MemberType NoteProperty ` + -Name DirectoryPath ` + -Value $package.DirectoryPath + } + + $csvMetadata += $metadataEntry + } } + $packagesForService = @{} $allPackages = GetPackageLookup $csvMetadata foreach ($metadataKey in $allPackages.Keys) { diff --git a/eng/common/scripts/Verify-RequiredDocsJsonMembers.ps1 b/eng/common/scripts/Verify-RequiredDocsJsonMembers.ps1 index 4bdd5adfaf8ca..8875d80e4348b 100644 --- a/eng/common/scripts/Verify-RequiredDocsJsonMembers.ps1 +++ b/eng/common/scripts/Verify-RequiredDocsJsonMembers.ps1 @@ -91,6 +91,16 @@ function Test-RequiredDocsJsonMembers($moniker) { $script:FoundError = $true } + if ($fileObject.PSObject.Members.Name -contains 'DirectoryPath') { + if ($null -eq $fileObject.DirectoryPath) { + Write-Host "$path has a null DirectoryPath member. If the DirectoryPath is unknown please use the value `"`"." + $script:FoundError = $true + } + } else { + Write-Host "$path is missing its DirectoryPath member. If the DirectoryPath is unknown please use the value `"`"." + $script:FoundError = $true + } + if ($Language -eq "java") { if ($fileObject.PSObject.Members.Name -contains "Group") { diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 0f5ae468a98c0..bdaec9e711a90 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -401,7 +401,7 @@ function CheckDependencies() $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." + throw "Docker does not appear to be running. Start/restart docker or re-run this script with -SkipPushImages" } }