diff --git a/eng/common/README.md b/eng/common/README.md index 10fcb49f2a8..a8f013b05b7 100644 --- a/eng/common/README.md +++ b/eng/common/README.md @@ -20,6 +20,6 @@ The 'Sync eng/common directory' PRs will be created in the language repositories 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 make sure all checks in the **Sync PRs** are green and approved. The **Tools PR** contains links to all the **Sync PRs**. If for some reason the PRs is blocked by a CI gate get someone with permission to override and manually merge the PR. - - To test the state of all the **Sync PRs**, you can download the `PRsCreated.txt` artifact from the `azure-sdk-tools - sync - eng-common` pipeline, with that run the [Verify-And-Merge-PRs.ps1](https://github.com/Azure/azure-sdk-tools/blob/master/scripts/powershell/Verify-And-Merge-PRs.ps1) passing the downloaded `PRsCreated.txt` file path for `PRDataArtifactPath` and `false` to `ShouldMerge`. - - Next approve the `VerifyAndMerge` job for the `azure-sdk-tools - sync - eng-common` pipeline triggered by your **Tools PR** which will automatically merge all the **Sync PRs**. You need `azure-sdk` devops contributor permissions to reach the `azure-sdk-tools - sync - eng-common` pipeline. + - To test the state of all the **Sync PRs**, you can download the `PRsCreated.txt` artifact from your `azure-sdk-tools - sync - eng-common` pipeline, then run `./eng/scripts/Verify-And-Merge.ps1 ` which will output the status of each associated PR. + - Next approve the `VerifyAndMerge` job for the `azure-sdk-tools - sync - eng-common` pipeline triggered by your **Tools PR** which will automatically merge all the **Sync PRs**. You need `azure-sdk` devops contributor permissions to reach the `azure-sdk-tools - sync - eng-common` pipeline. - Finally merge the **Tools PR**. \ No newline at end of file diff --git a/eng/pipelines/eng-common-sync.yml b/eng/pipelines/eng-common-sync.yml index 17f4cd6d378..67cf1c63755 100644 --- a/eng/pipelines/eng-common-sync.yml +++ b/eng/pipelines/eng-common-sync.yml @@ -65,7 +65,7 @@ stages: inputs: artifactName: ${{ parameters.ArtifactName }} path: $(Build.ArtifactStagingDirectory)/${{ parameters.PRDataFileName }} - + - stage: VerifyAndMerge jobs: - deployment: VerifyandMergeSyncPrs @@ -89,9 +89,9 @@ stages: displayName: 'Verify then Merge Pull Requests' inputs: targetType: filePath - filePath: $(Build.SourcesDirectory)/scripts/powershell/Verify-And-Merge-PRs.ps1 + filePath: $(Build.SourcesDirectory)/eng/scripts/Verify-And-Merge-PRs.ps1 arguments: > - -AuthToken "$(azuresdk-github-pat)" -PRDataArtifactPath "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{ parameters.PRDataFileName }}" + -AuthToken "$(azuresdk-github-pat)" -devOpsLogging pwsh: true \ No newline at end of file diff --git a/scripts/powershell/Verify-And-Merge-PRs.ps1 b/eng/scripts/Verify-And-Merge-PRs.ps1 similarity index 82% rename from scripts/powershell/Verify-And-Merge-PRs.ps1 rename to eng/scripts/Verify-And-Merge-PRs.ps1 index 6d9856d5810..f14d6efbc3c 100644 --- a/scripts/powershell/Verify-And-Merge-PRs.ps1 +++ b/eng/scripts/Verify-And-Merge-PRs.ps1 @@ -1,6 +1,6 @@ param( - $AuthToken, $PRDataArtifactPath, + $AuthToken, $ShouldMerge, [switch]$devOpsLogging = $false ) @@ -46,27 +46,29 @@ foreach ($prDataLine in $PRData) $repoOwner, $repoName, $prNumber = $prDataLine.Split(";") $prApiUrl = "https://api.github.com/repos/${repoOwner}/${repoName}/pulls/${prNumber}" + $prUrl = "https://github.com/${repoOwner}/${repoName}/pull/${prNumber}" + try { $response = Invoke-RestMethod -Headers $headers $prApiUrl if ($response.merged) { - Write-Host "${prApiUrl} is merged." + Write-Host "${prUrl} is merged." } elseif ($response.state -eq "closed") { - LogWarning "${prApiUrl} is closed. Please investigate why was not merged." + LogWarning "${prUrl} is closed. Please investigate why was not merged." $ReadyForMerge = $false } elseif ($response.mergeable -and $response.mergeable_state -eq "clean") { - Write-Host "${prApiUrl} is ready to merge." + Write-Host "${prUrl} is ready to merge." $mergablePRs += @{ Url = $prApiUrl; HeadSHA = $response.head.sha } } elseif ($response.mergeable_state -ne "clean") { - LogWarning "${prApiUrl} is blocked ($($response.mergeable_state)). Please ensure all checks are green and reviewers have approved." + LogWarning "${prUrl} is blocked ($($response.mergeable_state)). Please ensure all checks are green and reviewers have approved." $ReadyForMerge = $false } else { - LogWarning "${prApiUrl} is in an unknown state please contact engineering system team to understand the state." + LogWarning "${prUrl} is in an unknown state please contact engineering system team to understand the state." LogWarning $response $ReadyForMerge = $false }