Sync eng/common directory with azure-sdk-tools repository for Tools PR 895 (#619)
This commit is contained in:
parent
0f262cd0e0
commit
928b0a2da2
@ -197,7 +197,7 @@ It is passed as to the ARM
|
||||
template as 'testApplicationOid'
|
||||
|
||||
For more information on the relationship between AAD Applications and Service
|
||||
Principals see: https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals
|
||||
Principals see: https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
@ -457,6 +457,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[Remove-TestResources.ps1]()
|
||||
|
||||
|
||||
@ -125,8 +125,8 @@ New-MarkdownHelp -Command .\New-TestResources.ps1 -OutputFolder . -Force
|
||||
|
||||
PowerShell markdown documentation created with [platyPS][].
|
||||
|
||||
[New-TestResources.ps1]: ./New-TestResources.ps1.md
|
||||
[Remove-TestResources.ps1]: ./Remove-TestResources.ps1.md
|
||||
[New-TestResources.ps1]: https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/TestResources/New-TestResources.ps1.md
|
||||
[Remove-TestResources.ps1]: https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/TestResources/Remove-TestResources.ps1.md
|
||||
[PowerShell]: https://github.com/PowerShell/PowerShell
|
||||
[PowerShellAz]: https://docs.microsoft.com/powershell/azure/install-az-ps
|
||||
[platyPS]: https://github.com/PowerShell/platyPS
|
||||
|
||||
@ -272,6 +272,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[New-TestResources.ps1]()
|
||||
|
||||
|
||||
@ -1,19 +1,27 @@
|
||||
parameters:
|
||||
Directory: 'not-specified'
|
||||
IgnoreLinksFile: "$(Build.SourcesDirectory)/eng/ignore-links.txt"
|
||||
|
||||
IgnoreLinksFile: '$(Build.SourcesDirectory)/eng/ignore-links.txt'
|
||||
WorkingDirectory: '$(System.DefaultWorkingDirectory)'
|
||||
ScriptDirectory: 'eng/common/scripts'
|
||||
Recursive: $false
|
||||
CheckLinkGuidance: $false
|
||||
Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)'
|
||||
BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)master(/.*)$"
|
||||
BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}"
|
||||
|
||||
steps:
|
||||
- task: PowerShell@2
|
||||
displayName: Link verification check
|
||||
inputs:
|
||||
pwsh: true
|
||||
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.Directory }}
|
||||
filePath: eng/common/scripts/Verify-Links.ps1
|
||||
arguments: >
|
||||
-urls $(dir -r -i *.md)
|
||||
-rootUrl "file://$(Build.SourcesDirectory)/${{ parameters.Directory }}"
|
||||
-recursive: $false
|
||||
-ignoreLinksFile ${{ parameters.IgnoreLinksFile }}
|
||||
-branchReplaceRegex "^($env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI.*/(?:blob|tree)/)master(/.*)$"
|
||||
-branchReplacementName $env:SYSTEM_PULLREQUEST_SOURCECOMMITID
|
||||
-devOpsLogging: $true
|
||||
- task: PowerShell@2
|
||||
displayName: Link verification check
|
||||
inputs:
|
||||
pwsh: true
|
||||
workingDirectory: '${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}'
|
||||
filePath: ${{ parameters.ScriptDirectory }}/Verify-Links.ps1
|
||||
arguments: >
|
||||
-urls ${{ parameters.Urls }}
|
||||
-rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}"
|
||||
-recursive: ${{ parameters.Recursive }}
|
||||
-ignoreLinksFile ${{ parameters.IgnoreLinksFile }}
|
||||
-branchReplaceRegex "${{ parameters.BranchReplaceRegex }}"
|
||||
-branchReplacementName ${{ parameters.BranchReplacementName }}
|
||||
-devOpsLogging: $true
|
||||
-checkLinkGuidance: ${{ parameters.CheckLinkGuidance }}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
param (
|
||||
# url list to verify links. Can either be a http address or a local file request. Local file paths support md and html files.
|
||||
# url list to verify links. Can either be a http address or a local file request. Local file paths support md and html files.
|
||||
[string[]] $urls,
|
||||
# file that contains a set of links to ignore when verifying
|
||||
[string] $ignoreLinksFile = "$PSScriptRoot/ignore-links.txt",
|
||||
@ -17,14 +17,14 @@ param (
|
||||
[string] $branchReplaceRegex = "^(https://github.com/.*/(?:blob|tree)/)master(/.*)$",
|
||||
# the substitute branch name or SHA commit
|
||||
[string] $branchReplacementName = "",
|
||||
# flag to allow checking against azure sdk link guidance.
|
||||
# flag to allow checking against azure sdk link guidance. Check link guidance here: https://aka.ms/azsdk/guideline/links
|
||||
[bool] $checkLinkGuidance = $false
|
||||
)
|
||||
|
||||
$ProgressPreference = "SilentlyContinue"; # Disable invoke-webrequest progress dialog
|
||||
# Regex of the locale keywords.
|
||||
$locale = "/en-us/"
|
||||
|
||||
$emptyLinkMessage = "There is at least one empty link in the page. Please replace with absolute link. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
|
||||
function NormalizeUrl([string]$url){
|
||||
if (Test-Path $url) {
|
||||
$url = "file://" + (Resolve-Path $url).ToString();
|
||||
@ -85,16 +85,18 @@ function ResolveUri ([System.Uri]$referralUri, [string]$link)
|
||||
$linkUri = [System.Uri]$link;
|
||||
# Our link guidelines do not allow relative links so only resolve them when we are not
|
||||
# validating links against our link guidelines (i.e. !$checkLinkGuideance)
|
||||
if(!$checkLinkGuidance) {
|
||||
if (!$linkUri.IsAbsoluteUri) {
|
||||
if ($checkLinkGuidance -and !$linkUri.IsAbsoluteUri) {
|
||||
return $linkUri
|
||||
}
|
||||
|
||||
if (!$linkUri.IsAbsoluteUri) {
|
||||
# For rooted paths resolve from the baseUrl
|
||||
if ($link.StartsWith("/")) {
|
||||
Write-Verbose "rooturl = $rootUrl"
|
||||
$linkUri = new-object System.Uri([System.Uri]$rootUrl, ".$link");
|
||||
}
|
||||
else {
|
||||
$linkUri = new-object System.Uri($referralUri, $link);
|
||||
}
|
||||
if ($link.StartsWith("/")) {
|
||||
Write-Verbose "rooturl = $rootUrl"
|
||||
$linkUri = new-object System.Uri([System.Uri]$rootUrl, ".$link");
|
||||
}
|
||||
else {
|
||||
$linkUri = new-object System.Uri($referralUri, $link);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,6 +136,10 @@ function ParseLinks([string]$baseUri, [string]$htmlContent)
|
||||
|
||||
function CheckLink ([System.Uri]$linkUri)
|
||||
{
|
||||
if(!$linkUri.ToString().Trim()) {
|
||||
LogWarning "Found Empty link. Please use absolute link instead. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
|
||||
return $false
|
||||
}
|
||||
if ($checkedLinks.ContainsKey($linkUri)) {
|
||||
if (!$checkedLinks[$linkUri]) {
|
||||
LogWarning "broken link $linkUri"
|
||||
@ -193,11 +199,19 @@ function CheckLink ([System.Uri]$linkUri)
|
||||
}
|
||||
}
|
||||
|
||||
# Check if link uri includes locale info.
|
||||
if ($checkLinkGuidance -and ($linkUri -match $locale)) {
|
||||
LogWarning "DO NOT include locale $locale information in links: $linkUri."
|
||||
$linkValid = $false
|
||||
if ($checkLinkGuidance) {
|
||||
# Check if the url is relative links, suppress the archor link validation.
|
||||
if (!$linkUri.IsAbsoluteUri -and !$linkUri.ToString().StartsWith("#")) {
|
||||
LogWarning "DO NOT use relative link $linkUri. Please use absolute link instead. Check here for more infomation: https://aka.ms/azsdk/guideline/links"
|
||||
$linkValid = $false
|
||||
}
|
||||
# Check if link uri includes locale info.
|
||||
if ($linkUri -match $locale) {
|
||||
LogWarning "DO NOT include locale $locale information in links: $linkUri. Check here for more information: https://aka.ms/azsdk/guideline/links"
|
||||
$linkValid = $false
|
||||
}
|
||||
}
|
||||
|
||||
$checkedLinks[$linkUri] = $linkValid
|
||||
return $linkValid
|
||||
}
|
||||
@ -270,7 +284,6 @@ $checkedPages = @{};
|
||||
$checkedLinks = @{};
|
||||
$badLinks = @{};
|
||||
$pageUrisToCheck = new-object System.Collections.Queue
|
||||
|
||||
foreach ($url in $urls) {
|
||||
$uri = NormalizeUrl $url
|
||||
$pageUrisToCheck.Enqueue($uri);
|
||||
@ -286,9 +299,12 @@ while ($pageUrisToCheck.Count -ne 0)
|
||||
Write-Host "Found $($linkUris.Count) links on page $pageUri";
|
||||
$badLinksPerPage = @();
|
||||
foreach ($linkUri in $linkUris) {
|
||||
$linkUri = ReplaceGithubLink $linkUri
|
||||
$isLinkValid = CheckLink $linkUri
|
||||
$replacedLink = ReplaceGithubLink $linkUri
|
||||
$isLinkValid = CheckLink $replacedLink
|
||||
if (!$isLinkValid -and !$badLinksPerPage.Contains($linkUri)) {
|
||||
if (!$linkUri.ToString().Trim()) {
|
||||
$linkUri = $emptyLinkMessage
|
||||
}
|
||||
$badLinksPerPage += $linkUri
|
||||
}
|
||||
if ($recursive -and $isLinkValid) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user