diff --git a/eng/common/README.md b/eng/common/README.md index 0c413a8ea5..f855e54ada 100644 --- a/eng/common/README.md +++ b/eng/common/README.md @@ -9,15 +9,4 @@ should not contain binary files as they don't play well with git. Any updates to files in the `eng/common` directory should be made in the [azure-sdk-tools](https://github.com/azure/azure-sdk-tools) repo. All changes made will cause a PR to created in all subscribed azure-sdk language repos which will blindly replace all contents of the `eng/common` directory in that repo. For that reason do **NOT** make changes to files in this directory in the individual azure-sdk -languages repos as they will be overwritten the next time an update is taken from the common azure-sdk-tools repo. - -### Workflow - -Starting from [these changes](https://github.com/Azure/azure-sdk-tools/commit/401dbcaa17075ceb94073b6a4d7acafce8687a5d) the 'Sync eng/common directory' PRs will be created in the language repositories once a pull request that touches the eng/common directory is submitted against the master branch. This will make it easier for changes to be tested in each individual language repo before merging the changes in the azure-sdk-tools repo. The workflow is explained bellow - -1. Create a PR against Azure/azure-sdk-tools:master. This is the **Tools PR**. -2. `azure-sdk-tools - sync - eng-common` is run automatically. It creates **Sync PRs** in each of the connected language repositories using the format `Sync eng/common directory with azure-sdk-tools for PR {Tools PR Number}`. Each **Sync PR** will contain a link back to the **Tools PR** that triggered it. -3. More changes pushed to the **Tools PR**, will automatically triggered new pipeline runs in the respective **Sync PRs**. The **Sync PRs** are used to make sure the changes would not break any of the connected pipelines. -4. Once satisfied with the changes; - - First merge all the **Sync PRs**. The **Tools PR** contains links to all the **Sync PRs** - - Finally merge the **Tools PR**. Each **Sync PR** contains the link to the corresponding **Tools PR**. \ No newline at end of file +languages repos as they will be overwritten the next time an update is taken from the common azure-sdk-tools repo. \ No newline at end of file diff --git a/eng/common/pipelines/templates/steps/create-pull-request.yml b/eng/common/pipelines/templates/steps/create-pull-request.yml index 7b3e3a75f4..10af61de11 100644 --- a/eng/common/pipelines/templates/steps/create-pull-request.yml +++ b/eng/common/pipelines/templates/steps/create-pull-request.yml @@ -11,7 +11,6 @@ parameters: PushArgs: WorkingDirectory: $(System.DefaultWorkingDirectory) PRTitle: not-specified - PRBody: not-specified ScriptDirectory: eng/common/scripts GHReviewersVariable: '' GHTeamReviewersVariable: '' @@ -66,7 +65,6 @@ steps: -PRBranch "${{ parameters.PRBranchName }}" -AuthToken "$(azuresdk-github-pat)" -PRTitle "${{ parameters.PRTitle }}" - -PRBody "${{ parameters.PRBody }}" - task: PowerShell@2 displayName: Tag a Reviewer on PR diff --git a/eng/common/pipelines/templates/steps/verify-links.yml b/eng/common/pipelines/templates/steps/verify-links.yml index 86d0013ac8..2cc38d4767 100644 --- a/eng/common/pipelines/templates/steps/verify-links.yml +++ b/eng/common/pipelines/templates/steps/verify-links.yml @@ -2,16 +2,17 @@ parameters: Directory: 'not-specified' IgnoreLinksFile: "$(Build.SourcesDirectory)/eng/ignore-links.txt" - 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 }} \ No newline at end of file +- 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/)master(/.*)" + -branchReplacementName $env:SYSTEM_PULLREQUEST_SOURCECOMMITID diff --git a/eng/common/scripts/Submit-PullRequest.ps1 b/eng/common/scripts/Submit-PullRequest.ps1 index 732d0d4b2b..5edabc599a 100644 --- a/eng/common/scripts/Submit-PullRequest.ps1 +++ b/eng/common/scripts/Submit-PullRequest.ps1 @@ -38,9 +38,7 @@ param( [Parameter(Mandatory = $true)] $PRTitle, - - [Parameter(Mandatory = $true)] - $PRBody + $PRBody = $PRTitle ) $headers = @{ diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1 index 8ef7d518ab..22a94f2a91 100644 --- a/eng/common/scripts/Verify-Links.ps1 +++ b/eng/common/scripts/Verify-Links.ps1 @@ -13,6 +13,10 @@ param ( [string] $rootUrl = "", # list of http status codes count as broken links. Defaults to 400, 401, 404, SocketError.HostNotFound = 11001, SocketError.NoData = 11004 [array] $errorStatusCodes = @(400, 401, 404, 11001, 11004), + # regex to check if the link needs to be replaced + [string] $branchReplaceRegex = "(https://github.com/.*/blob/)master(/.*)", + # the substitute branch name or SHA commit + [string] $branchReplacementName = "", # flag to allow checking against azure sdk link guidance. [bool] $checkLinkGuidance = $false ) @@ -183,6 +187,14 @@ function CheckLink ([System.Uri]$linkUri) return $linkValid } +function ReplaceGithubLink([string]$originLink) { + if (-not $branchReplacementName) { + return $originLink + } + $ReplacementPattern = "`${1}$branchReplacementName`$2" + return $originLink -replace $branchReplaceRegex, $ReplacementPattern +} + function GetLinks([System.Uri]$pageUri) { if ($pageUri.Scheme.StartsWith("http")) { @@ -259,6 +271,8 @@ while ($pageUrisToCheck.Count -ne 0) Write-Host "Found $($linkUris.Count) links on page $pageUri"; foreach ($linkUri in $linkUris) { + $linkUri = ReplaceGithubLink $linkUri + $isLinkValid = CheckLink $linkUri if (!$isLinkValid) { $script:badLinks += $linkUri @@ -274,4 +288,4 @@ while ($pageUrisToCheck.Count -ne 0) Write-Host "Found $($checkedLinks.Count) links with $($badLinks.Count) broken" $badLinks | ForEach-Object { Write-Host " $_" } -exit $badLinks.Count +exit $badLinks.Count \ No newline at end of file