From 18e42b0bad23ab853814b0ebafc236368ad292ed Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 7 Dec 2021 16:58:27 -0800 Subject: [PATCH 1/4] Add logic for retrieving package infro from DevOps feed --- eng/common/scripts/Invoke-DevOpsAPI.ps1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/eng/common/scripts/Invoke-DevOpsAPI.ps1 b/eng/common/scripts/Invoke-DevOpsAPI.ps1 index 41f4796d42f3..c887237914ee 100644 --- a/eng/common/scripts/Invoke-DevOpsAPI.ps1 +++ b/eng/common/scripts/Invoke-DevOpsAPI.ps1 @@ -158,5 +158,26 @@ function Add-RetentionLease { -Headers (Get-DevOpsApiHeaders -Base64EncodedToken $Base64EncodedAuthToken) ` -MaximumRetryCount 3 ` -ContentType "application/json" +} + +function Get-PackagesInArtifactFeed { + param ( + $Organization="azure-sdk", + $Project="public", + [Parameter(Mandatory = $true)] + $FeedId, + $ApiVersion="6.1-preview.1", + $IncludeAllVersions="false", + $Base64EncodedAuthToken + ) + + $uri = "https://feeds.dev.azure.com/$Organization/$Project/_apis/packaging/Feeds/$FeedId/packages?api-version=$ApiVersion&includeAllVersions=$IncludeAllVersions" + + $packages = Invoke-RestMethod ` + -Method GET ` + -Uri $uri ` + -Headers (Get-DevOpsApiHeaders -Base64EncodedToken $Base64EncodedAuthToken) ` + -MaximumRetryCount 3 + return $packages.value } From 784d7cb8019b04a78567511a5440c1b12adefe37 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 8 Dec 2021 13:39:32 -0800 Subject: [PATCH 2/4] Add template for docwarden --- .../pipelines/templates/steps/verify-readme.yml | 17 +++++++++++++++++ eng/common/scripts/Verify-Readme.ps1 | 16 ++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 eng/common/pipelines/templates/steps/verify-readme.yml diff --git a/eng/common/pipelines/templates/steps/verify-readme.yml b/eng/common/pipelines/templates/steps/verify-readme.yml new file mode 100644 index 000000000000..9d8d92fb7cb7 --- /dev/null +++ b/eng/common/pipelines/templates/steps/verify-readme.yml @@ -0,0 +1,17 @@ +parameters: + ScanPath: $(Build.SourcesDirectory) + RepoRoot: $(Build.SourcesDirectory) + SettingsPath: '$(Build.SourcesDirectory)/eng/.docsettings.yml' + DocWardenVersion : '0.7.2' + +steps: +- task: PowerShell@2 + displayName: "Verify Readmes" + inputs: + filePath: "eng/common/scripts/Verify-Readme.ps1" + arguments: > + -DocWardenVersion ${{ parameters.DocWardenVersion }} + -ScanPath ${{ parameters.ScanPath }} + -RepoRoot ${{ parameters.RepoRoot }} + -SettingsPath ${{ parameters.SettingsPath }} + pwsh: true \ No newline at end of file diff --git a/eng/common/scripts/Verify-Readme.ps1 b/eng/common/scripts/Verify-Readme.ps1 index 67429fcc3b21..d7ed446522a3 100644 --- a/eng/common/scripts/Verify-Readme.ps1 +++ b/eng/common/scripts/Verify-Readme.ps1 @@ -1,15 +1,23 @@ # Wrapper Script for Readme Verification [CmdletBinding()] param ( - [string]$DocWardenVersion = "0.7.1", - + [string]$DocWardenVersion = "0.7.2", [Parameter(Mandatory = $true)] [string]$ScanPath, - + [string]$RepoRoot, [Parameter(Mandatory = $true)] [string]$SettingsPath ) pip install setuptools wheel --quiet pip install doc-warden==$DocWardenVersion --quiet -ward scan -d $ScanPath -c $SettingsPath + +if (-not [System.String]::IsNullOrWhiteSpace($RepoRoot)) +{ + ward scan -d $ScanPath -u $RepoRoot -c $SettingsPath +} +else +{ + ward scan -d $ScanPath -c $SettingsPath +} + From a410f3a7cbce3510b5329cd1aff1aec2f3c46b58 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 9 Dec 2021 13:06:07 -0800 Subject: [PATCH 3/4] Remove Invoke-DevOpsAPI changes --- eng/common/scripts/Invoke-DevOpsAPI.ps1 | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/eng/common/scripts/Invoke-DevOpsAPI.ps1 b/eng/common/scripts/Invoke-DevOpsAPI.ps1 index c887237914ee..72253089250c 100644 --- a/eng/common/scripts/Invoke-DevOpsAPI.ps1 +++ b/eng/common/scripts/Invoke-DevOpsAPI.ps1 @@ -159,25 +159,3 @@ function Add-RetentionLease { -MaximumRetryCount 3 ` -ContentType "application/json" } - -function Get-PackagesInArtifactFeed { - param ( - $Organization="azure-sdk", - $Project="public", - [Parameter(Mandatory = $true)] - $FeedId, - $ApiVersion="6.1-preview.1", - $IncludeAllVersions="false", - $Base64EncodedAuthToken - ) - - $uri = "https://feeds.dev.azure.com/$Organization/$Project/_apis/packaging/Feeds/$FeedId/packages?api-version=$ApiVersion&includeAllVersions=$IncludeAllVersions" - - $packages = Invoke-RestMethod ` - -Method GET ` - -Uri $uri ` - -Headers (Get-DevOpsApiHeaders -Base64EncodedToken $Base64EncodedAuthToken) ` - -MaximumRetryCount 3 - - return $packages.value -} From 45d4f4097b92f91453ef2640fc664bbda285dab5 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 9 Dec 2021 13:18:39 -0800 Subject: [PATCH 4/4] Update verify readme logic --- eng/common/scripts/Invoke-DevOpsAPI.ps1 | 1 + eng/common/scripts/Verify-Readme.ps1 | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Invoke-DevOpsAPI.ps1 b/eng/common/scripts/Invoke-DevOpsAPI.ps1 index 72253089250c..41f4796d42f3 100644 --- a/eng/common/scripts/Invoke-DevOpsAPI.ps1 +++ b/eng/common/scripts/Invoke-DevOpsAPI.ps1 @@ -158,4 +158,5 @@ function Add-RetentionLease { -Headers (Get-DevOpsApiHeaders -Base64EncodedToken $Base64EncodedAuthToken) ` -MaximumRetryCount 3 ` -ContentType "application/json" + } diff --git a/eng/common/scripts/Verify-Readme.ps1 b/eng/common/scripts/Verify-Readme.ps1 index d7ed446522a3..c0259934048b 100644 --- a/eng/common/scripts/Verify-Readme.ps1 +++ b/eng/common/scripts/Verify-Readme.ps1 @@ -1,7 +1,8 @@ # Wrapper Script for Readme Verification [CmdletBinding()] param ( - [string]$DocWardenVersion = "0.7.2", + [Parameter(Mandatory = $true)] + [string]$DocWardenVersion, [Parameter(Mandatory = $true)] [string]$ScanPath, [string]$RepoRoot, @@ -12,7 +13,7 @@ param ( pip install setuptools wheel --quiet pip install doc-warden==$DocWardenVersion --quiet -if (-not [System.String]::IsNullOrWhiteSpace($RepoRoot)) +if ($RepoRoot) { ward scan -d $ScanPath -u $RepoRoot -c $SettingsPath }