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 9, 2020
1 parent 25db820 commit fe35057
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 85 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.
1 change: 1 addition & 0 deletions eng/common/scripts/Invoke-GitHub-API.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function UpdateIssue {
$IssueNumber,
[string]$title,
[string]$body,
[ValidateSet("open","closed")]
[string]$state,
[int]$milestome,
[ValidateNotNullOrEmpty()]
Expand Down
86 changes: 14 additions & 72 deletions eng/pipelines/eng-common-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ parameters:
- name: PRDataFileName
type: string
default: PRsCreated.txt
- name: ArtifactName
type: string
default: pullrequestdata
- name: DirectoryToSync
type: string
default: eng/common
- name: BaseBranchName
type: string
- name: Repos
type: object
default:
Expand Down Expand Up @@ -69,17 +68,14 @@ stages:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
CommitMessage: "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository for Tools PR $(System.PullRequest.PullRequestNumber)"
DirectoryToSync: ${{ parameters.DirectoryToSync }}
PRBranchName: "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
UpStreamBranchName: "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
BaseBranchName: $(system.pullRequest.targetBranch)
SkipCheckingForChanges: true
${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
CommitMessage: Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository
DirectoryToSync: ${{ parameters.DirectoryToSync }}
PRBranchName: "sync-${{ parameters.DirectoryToSync }}"
PRTitle: Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository
PRBody: >
Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools repository.<br>
See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)
UpStreamBranchName: "sync-${{ parameters.DirectoryToSync }}"
BaseBranchName: ${{ coalesce(parameters.BaseBranchName, $(Build.SourceBranchName)) }}
Repos: ${{ parameters.Repos }}

- stage: CreateSyncPRs
Expand All @@ -97,10 +93,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,75 +110,25 @@ 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') }}:
arguments: >
-RepoOwner "Azure"
-RepoName "${{ repo }}"
-BaseBranch $(system.pullRequest.targetBranch)
-BaseBranch ${{ coalesce(parameters.BaseBranchName, $(Build.SourceBranchName)) }}
-PROwner "Azure"
-PRBranch "sync-${{ parameters.DirectoryToSync }}"
-AuthToken "$(azuresdk-github-pat)"
-PRTitle "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools for PR $(System.PullRequest.PullRequestNumber)"
-PRTitle "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools"
-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)`
-PRBody "Sync ${{ parameters.DirectoryToSync }} directory with azure-sdk-tools`
See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)"
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- 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()
. "$(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 Label 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)
6 changes: 3 additions & 3 deletions eng/pipelines/templates/steps/sync-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
Repos: []
DirectoryToSync: eng/common
CommitMessage: commit-message-not-set
PRBranchName: branch-name-not-set
UpStreamBranchName: branch-name-not-set
BaseBranchName: master
Sync: pr-data-artifact-path-not-set
SkipCheckingForChanges: false
Expand Down Expand Up @@ -54,7 +54,7 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)/${{ repo }}
filePath: ${{ parameters.ScriptDirectory }}/git-branch-push.ps1
arguments: >
-PRBranchName "${{ parameters.PRBranchName }}"
-PRBranchName "${{ parameters.UpStreamBranchName }}"
-CommitMsg "${{ parameters.CommitMessage }}"
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/${{ repo }}.git"
-PushArgs "${{ parameters.PushArgs }}"
Expand All @@ -70,7 +70,7 @@ steps:
arguments: >
-Organization "azure-sdk"
-Project "internal"
-SourceBranch "${{ parameters.PRBranchName }}"
-SourceBranch "${{ parameters.UpStreamBranchName }}"
-DefinitionId "$(${{repo}}-template-definition-id)"
-VsoQueuedPipelines "QueuedPipelines"
-AuthToken "$(azuresdk-azure-sdk-devops-build-queuing-pat)"
Expand Down

0 comments on commit fe35057

Please sign in to comment.