Skip to content

Commit

Permalink
Fix github verb names
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Oct 12, 2020
1 parent 6cf8b50 commit efb05cf
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 47 deletions.
12 changes: 7 additions & 5 deletions eng/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ languages repos as they will be overwritten the next time an update is taken fro

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 (**Tools PR**) in the `azure - sdk - tools` Repo with changes to eng/common directory.
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 `azure-sdk-tools - sync - eng-common` pipeline queues test runs using the dotnet, js, java and python template pipelines. This help to test the recent changes in the **Tools PR**
3. The `azure-sdk-tools - sync - eng-common` pipeline queues test runs for template pipelines in various languages. These help you test your changes in the **Tools PR**.
4. If there are changes in the **Tools PR** that will affect the release stage you should approve the release test pipelines by clicking 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 until you have satisfactory test runs all the way to release of the template package if necessary.
6. 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. Go review and approve each of your **Sync PRs**. The merging will happen automatically.
5. If you make additional changes to your **Tools PR** repeat steps 1 - 4 until you have completed the necessary testing of your changes. This includes full releases of the template package, if necessary.
6. Sign off on CreateSyncPRs stage of the sync pipeline using the approval gate. This stage will create the **Sync PRs** in the various language repos with the `auto-merge` label applied. A link to each of the **Sync PRs** will show up in the **Tools PR** for you to click and review.
7. Go review and approve each of your **Sync PRs**. The merging will happen automatically.
8. Sign off on VerifyAndMerge stage of the sync pipeline using the approval gate. This stage will merge any remaining open **Sync PRs** and also append `auto-merge` to the **Tools PR** so it will automatically merge once the pipeline finishes.
7. Sign Off on the VerifyAndMerge stage. This will merge any remaining open **Sync PR** and also append `auto-merge` to the **Tools PR**.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ param(
. "${PSScriptRoot}\common.ps1"

try {
AddIssueComment -RepoOwner $RepoOwner -RepoName $RepoName `
Add-IssueComment -RepoOwner $RepoOwner -RepoName $RepoName `
-IssueNumber $IssueNumber -Comment $Comment -AuthToken $AuthToken
}
catch {
LogError "AddIssueComment failed with exception:`n$_"
LogError "Add-IssueComment failed with exception:`n$_"
exit 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ param(
. "${PSScriptRoot}\common.ps1"

try {
AddIssueLabels -RepoOwner $RepoOwner -RepoName $RepoName `
Add-IssueLabels -RepoOwner $RepoOwner -RepoName $RepoName `
-IssueNumber $IssueNumber -Labels $Labels -AuthToken $AuthToken
}
catch {
LogError "AddIssueLabels failed with exception:`n$_"
LogError "Add-IssueLabels failed with exception:`n$_"
exit 1
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
$GithubAPIBaseURI = "https://api.github.com/repos"

function Get-Headers ($token) {
function Get-GitHubHeaders ($token) {
$headers = @{
Authorization = "bearer $token"
}
return $headers
}

function InvokePost {
function Invoke-GitHubAPIPost {
param (
[Parameter(Mandatory = $true)]
$apiURI,
Expand All @@ -21,13 +21,13 @@ function InvokePost {
-Method POST `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-Headers -token $token) `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3

return $resp
}

function InvokePatch {
function Invoke-GitHubAPIPatch {
param (
[Parameter(Mandatory = $true)]
$apiURI,
Expand All @@ -41,13 +41,13 @@ function InvokePatch {
-Method PATCH `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-Headers -token $token) `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3

return $resp
}

function InvokeGet {
function Invoke-GitHubAPIGet {
param (
[Parameter(Mandatory = $true)]
$apiURI,
Expand All @@ -59,7 +59,7 @@ function InvokeGet {
$resp = Invoke-RestMethod `
-Method GET `
-Uri $apiURI `
-Headers (Get-Headers -token $token) `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
}
else {
Expand All @@ -78,7 +78,7 @@ function SplitMembers ($membersString)
return @($membersString.Split(",") | % { $_.Trim() } | ? { return $_ })
}

function ListPullRequests {
function List-PullRequests {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
Expand All @@ -102,10 +102,10 @@ function ListPullRequests {
if ($Sort) { $uri += "sort=$Sort&" }
if ($Direction){ $uri += "direction=$Direction&" }

return InvokeGet -apiURI $uri
return Invoke-GitHubAPIGet -apiURI $uri
}

function AddIssueComment {
function Add-IssueComment {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
Expand All @@ -125,11 +125,11 @@ function AddIssueComment {
body = $Comment
}

return InvokePost -apiURI $uri -body $parameters -token $AuthToken
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}

# Will add labels to existing labels on the issue
function AddIssueLabels {
function Add-IssueLabels {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
Expand All @@ -144,17 +144,23 @@ function AddIssueLabels {
$AuthToken
)

if ($Labels.Trim().Length -eq 0)
{
throw "The 'Labels' parameter should not not be whitespace..`
You can use the 'Update-Issue' function if you plan to reset the labels"
}

$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues/$IssueNumber/labels"
$labelAdditions = SplitMembers -membersString $Labels
$parameters = @{
labels = $labelAdditions
labels = @($labelAdditions)
}

return InvokePost -apiURI $uri -body $parameters -token $AuthToken
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}

# Will add assignees to existing assignees on the issue
function AddIssueAssignees {
function Add-IssueAssignees {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
Expand All @@ -169,18 +175,24 @@ function AddIssueAssignees {
$AuthToken
)

if ($Assignees.Trim().Length -eq 0)
{
throw "The 'Assignees' parameter should not be whitespace.`
You can use the 'Update-Issue' function if you plan to reset the Assignees"
}

$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues/$IssueNumber/assignees"
$assigneesAdditions = SplitMembers -membersString $Assignees
$parameters = @{
assignees = $assigneesAdditions
assignees = @($assigneesAdditions)
}

return InvokePost -apiURI $uri -body $parameters -token $AuthToken
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}

# For labels and assignee pass comma delimited string, to replace existing labels or assignees.
# Or pass white space " " to remove all labels or assignees
function UpdateIssue {
function Update-Issue {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
Expand Down Expand Up @@ -209,12 +221,12 @@ function UpdateIssue {
if ($Milestone) { $parameters["milestone"] = $Milestone }
if ($Labels) {
$labelAdditions = SplitMembers -membersString $Labels
$parameters["labels"] = $labelAdditions
$parameters["labels"] = @($labelAdditions)
}
if ($Assignees) {
$assigneesAdditions = SplitMembers -membersString $Assignees
$parameters["assignees"] = $assigneesAdditions
$parameters["assignees"] = @($assigneesAdditions)
}

return InvokePatch -apiURI $uri -body $parameters -token $AuthToken
return Invoke-GitHubAPIPatch -apiURI $uri -body $parameters -token $AuthToken
}
2 changes: 1 addition & 1 deletion eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts"
. (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1)
. (Join-Path $EngCommonScriptsDir Package-Properties.ps1)
. (Join-Path $EngCommonScriptsDir logging.ps1)
. (Join-Path $EngCommonScriptsDir Invoke-GitHub-API.ps1)
. (Join-Path $EngCommonScriptsDir Invoke-GitHubAPI.ps1)

# Setting expected from common languages settings
$Language = "Unknown"
Expand Down
43 changes: 29 additions & 14 deletions eng/pipelines/eng-common-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parameters:
default: eng/common
- name: BaseBranchName
type: string
default: master
- name: Repos
type: object
default:
Expand Down Expand Up @@ -147,23 +148,23 @@ stages:
path: $(Build.ArtifactStagingDirectory)/${{ parameters.PRDataFileName }}

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

pool:
vmImage: windows-2019
pool:
vmImage: windows-2019

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

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

- task: PowerShell@2
displayName: 'Verify then Merge Pull Requests'
Expand All @@ -174,3 +175,17 @@ stages:
-PRDataArtifactPath "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{ parameters.PRDataFileName }}"
-AuthToken "$(azuresdk-github-pat)"
pwsh: true

- task: PowerShell@2
displayName: 'Add Auto merge Label'
condition: succeeded()
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Add-IssueLabels.ps1
arguments: >
-RepoOwner "Azure"
-RepoName "azure-sdk-tools"
-IssueNumber $(System.PullRequest.PullRequestNumber)
-Labels "auto-merge"
-AuthToken "$(azuresdk-github-pat)"
pwsh: true
6 changes: 4 additions & 2 deletions eng/pipelines/templates/steps/sync-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ steps:
inputs:
pwsh: true
workingDirectory: ${{ parameters.WorkingDirectory }}
filePath: ${{ parameters.ScriptDirectory }}/Add-Issue-Comment.ps1
filePath: ${{ parameters.ScriptDirectory }}/Add-IssueComment.ps1
arguments: >
-RepoOwner "Azure"
-RepoName "azure-sdk-tools"
-IssueNumber "$(System.PullRequest.PullRequestNumber)"
-Comment "The following pipelines have been queued for testing:<br>$env:QueuedPipelines<br>Sign off on the approval gate to test the release stage of each pipeline."
-Comment "The following pipelines have been queued for testing:<br>$env:QueuedPipelines`
<br>You can sign off on the approval gate to test the release stage of each pipeline.`
<br>See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)"
-AuthToken "$(azuresdk-github-pat)"

0 comments on commit efb05cf

Please sign in to comment.