Skip to content

Commit

Permalink
Remove Verify an Merge Stage, Add auto-merge label to the Tools PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Oct 8, 2020
1 parent 25db820 commit 1c29ffd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 71 deletions.
17 changes: 8 additions & 9 deletions eng/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ languages repos as they will be overwritten the next time an update is taken fro

### Workflow

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 below:
The 'Sync eng/common directory' PRs will be created in the language repositories when 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 below:

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 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 your `azure-sdk-tools - sync - eng-common` pipeline, then run `./eng/scripts/Verify-And-Merge-PRs.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**.
1. Create a PR (**Tools PR**) in the `azure - sdk - tools` Repo with changes to eng/common directory.
2. `azure-sdk-tools - sync - eng-common` pipeline is triggered for the **Tools PR**
3. The sync pipeline queues test run using the dotnet, js, java and python template pipelines.
4. Test pipelines release respective template packages. You'll have to approve the release to pass the approval gate. The test (template) pipeline will automatically release the next eligible version without needing manual intervention for the versioning. Please approve your test releases as quickly as possible. A race condition may occur due to someone else queueing the pipeline and going all the way to release using your version while yours is still waiting. If this occurs manually rerun the pipeline that failed.
5. Repeat step 1 - 4 by pushing new changes to your **Tools PR** Do this till you have satisfactory test runs all the way to release of the template package.
5. Sign off on next stage of the sync pipeline using the approval gate. The CreateSyncPRs stage will create the sync PR in the various language repos. Before doing this you need to be satisfied with the testing from the previous steps. This stage will append the `auto-merge` label to the **Sync PRs** as well as the **Tools PR**.
6. Ensure you that **Sync PRs** and the **Tools PR** are green and approved. Merging wil happen automatically via the Fabric Bot.
67 changes: 6 additions & 61 deletions eng/pipelines/eng-common-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ stages:
steps:
- checkout: self

- pwsh: |
New-Item -Path $(Build.ArtifactStagingDirectory)/${{ parameters.PRDataFileName }} -ItemType File
displayName: Create PRData Artifact
- ${{ each repo in parameters.Repos }}:
- task: PowerShell@2
displayName: Create pull request
Expand All @@ -118,7 +114,7 @@ stages:
-PRBranch "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
-AuthToken "$(azuresdk-github-pat)"
-PRTitle "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR $(System.PullRequest.PullRequestNumber)"
-PRLabels "Central-EngSys, EngSys"
-PRLabels "Central-EngSys,EngSys,auto-merge"
-PRBody "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR https://github.com/Azure/azure-sdk-tools/pull/$(System.PullRequest.PullRequestNumber)`
See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)"
${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
Expand All @@ -134,59 +130,8 @@ stages:
-PRBody "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR https://github.com/Azure/azure-sdk-tools/pull/$(System.PullRequest.PullRequestNumber)`
See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)"
- pwsh: |
$PRData = "Azure;${{ repo }};$(Submitted.PullRequest.Number)"
Add-Content -Path "$(Build.ArtifactStagingDirectory)/${{ parameters.PRDataFileName }}" -Value $PRData
displayName: Write Sync PR Data to Artifact File
condition: succeeded()
- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish ${{ parameters.PRDataFileName }}
inputs:
artifactName: ${{ parameters.ArtifactName }}
path: $(Build.ArtifactStagingDirectory)/${{ parameters.PRDataFileName }}

- stage: VerifyAndMerge
jobs:
- deployment: VerifyandMergeSyncPrs
displayName: Verify and Merge Sync PRs
environment: githubmerges

pool:
vmImage: windows-2019

strategy:
runOnce:
deploy:
steps:
- checkout: self

- download: current
artifact: ${{parameters.ArtifactName}}
displayName: Download ${{ parameters.PRDataFileName }}

- task: PowerShell@2
displayName: 'Verify then Merge Pull Requests'
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/eng/scripts/Verify-And-Merge-PRs.ps1
arguments: >
-PRDataArtifactPath "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{ parameters.PRDataFileName }}"
-AuthToken "$(azuresdk-github-pat)"
-devOpsLogging
pwsh: true

- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
- ${{ each repo in parameters.Repos }}:
- pwsh: |
git clone https://github.com/azure/${{ repo }} --depth 1
pushd $(System.DefaultWorkingDirectory)/${{ repo }}
git push origin --delete "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
if ($lastExitCode -ne 0) {
Write-Host "Failed to delete [sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)] branch in ${{ repo }}"
exit 1
}
displayName: Write Sync PR Data to Artifact File
workingDirectory: $(System.DefaultWorkingDirectory)
condition: succeeded()
- pwsh: |
. "$(Build.SourcesDirectory)\eng\common\scripts\Invoke-GitHub-API.ps1" -AuthToken "$(azuresdk-github-pat)"
UpdateIssue -RepoOwner "Azure" -RepoName "azure-sdk-tools" -IssueNumber $(System.PullRequest.PullRequestNumber) -labels "auto-merge"
displayName: Add Auto Merge to Tool PR.
condition: succeeded()
2 changes: 1 addition & 1 deletion eng/pipelines/templates/jobs/tools-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
-RepoName ${{ repo }}
-BranchPrefix "sync-eng/common-"
-WorkingDirectory $(System.DefaultWorkingDirectory)
-AuthToken "$(azuresdk-github-pat)"
-AuthToken $(azuresdk-github-pat)

0 comments on commit 1c29ffd

Please sign in to comment.