Update verify-and-merge script for easier local running (#969)
This commit is contained in:
Родитель
d5b219b9c1
Коммит
99baaea9b6
|
@ -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 <path to PRsCreated.txt>` 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**.
|
|
@ -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
|
|
@ -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
|
||||
}
|
Загрузка…
Ссылка в новой задаче