Skip to content

Commit

Permalink
Use a new branch for quing the TestPipeline, this should prevent chec…
Browse files Browse the repository at this point in the history
…k ffrom showing up on eng/common Sync PRs
  • Loading branch information
chidozieononiwu committed Oct 30, 2020
1 parent 7b1e235 commit 14fffc0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
22 changes: 12 additions & 10 deletions eng/common/scripts/git-branch-push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ param(
[Parameter(Mandatory = $false)]
[string] $PushArgs = "",

[string] $RemoteName = "azure-sdk-fork",

[Parameter(Mandatory = $false)]
[boolean] $SkipCommit = $false
)
Expand All @@ -36,16 +38,16 @@ param(
# would fail the first time git wrote command output.
$ErrorActionPreference = "Continue"

Write-Host "git remote add azure-sdk-fork $GitUrl"
git remote add azure-sdk-fork $GitUrl
Write-Host "git remote add $RemoteName $GitUrl"
git remote add $RemoteName $GitUrl
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to add remote LASTEXITCODE=$($LASTEXITCODE), see command output above."
exit $LASTEXITCODE
}

Write-Host "git fetch azure-sdk-fork"
git fetch azure-sdk-fork
Write-Host "git fetch $RemoteName"
git fetch $RemoteName
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand Down Expand Up @@ -84,15 +86,15 @@ $tryNumber = 0
do
{
$needsRetry = $false
Write-Host "git push azure-sdk-fork $PRBranchName $PushArgs"
git push azure-sdk-fork $PRBranchName $PushArgs
Write-Host "git push $RemoteName $PRBranchName $PushArgs"
git push $RemoteName $PRBranchName $PushArgs
$tryNumber++
if ($LASTEXITCODE -ne 0)
{
$needsRetry = $true
Write-Host "Git push failed with LASTEXITCODE=$($LASTEXITCODE) Need to fetch and rebase: attempt number=$($tryNumber)"
Write-Host "git fetch azure-sdk-fork"
git fetch azure-sdk-fork
Write-Host "git fetch $RemoteName"
git fetch $RemoteName
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand All @@ -110,8 +112,8 @@ do
continue
}

Write-Host "git reset --hard azure-sdk-fork/${PRBranchName}"
git reset --hard azure-sdk-fork/${PRBranchName}
Write-Host "git reset --hard $RemoteName/${PRBranchName}"
git reset --hard $RemoteName/${PRBranchName}
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to hard reset branch LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand Down
1 change: 0 additions & 1 deletion eng/common/scripts/modules/ChangeLog-Operations.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+.*(?<version>\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s(?<releaseStatus>\(Unreleased\)|\(\d{4}-\d{2}-\d{2}\)))?)"

# Returns a Collection of changeLogEntry object containing changelog info for all version present in the gived CHANGELOG
function Get-ChangeLogEntries {
param (
[Parameter(Mandatory = $true)]
Expand Down
14 changes: 14 additions & 0 deletions eng/pipelines/eng-common-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ stages:
-AuthToken "$(azuresdk-github-pat)"
pwsh: true

- ${{ each repo in parameters.Repos }}:
- task: PowerShell@2
displayName: Clean Up Sync Common Branches
condition: succeeded()
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: $(System.DefaultWorkingDirectory)/eng/common/scripts/Delete-RemoteBranches.ps1
arguments: >
-RepoOwner "Azure"
-RepoName ${{ repo }}
-BranchPrefix "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)"
-AuthToken $(azuresdk-github-pat)
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
- stage: CreateSync
jobs:
Expand Down
19 changes: 17 additions & 2 deletions eng/pipelines/templates/steps/sync-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)
- task: PowerShell@2
displayName: Push changes
displayName: Push changes for creating Sync PRs
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
inputs:
pwsh: true
Expand All @@ -54,6 +54,21 @@ steps:
-PushArgs "${{ parameters.PushArgs }}"
-SkipCommit $${{parameters.SkipCheckingForChanges}}
- task: PowerShell@2
displayName: Push changes for Queueing Test Pipeline
condition: and(succeeded(), ne(variables['${{repo}}-template-definition-id'], ''))
inputs:
pwsh: true
workingDirectory: $(System.DefaultWorkingDirectory)/${{ repo }}
filePath: ${{ parameters.ScriptDirectory }}/git-branch-push.ps1
arguments: >
-PRBranchName "${{ parameters.UpstreamBranchName }}-ForTestPipeline"
-CommitMsg "${{ parameters.CommitMessage }}"
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/${{ repo }}.git"
-PushArgs "${{ parameters.PushArgs }}"
-RemoteName "azure-sdk-test-fork"
-SkipCommit $${{parameters.SkipCheckingForChanges}}
- task: PowerShell@2
displayName: Queue test pipeline
condition: and(succeeded(), ne(variables['${{repo}}-template-definition-id'], ''))
Expand All @@ -64,7 +79,7 @@ steps:
arguments: >
-Organization "azure-sdk"
-Project "internal"
-SourceBranch "${{ parameters.UpstreamBranchName }}"
-SourceBranch "${{ parameters.UpstreamBranchName }}-ForTestPipeline"
-DefinitionId "$(${{repo}}-template-definition-id)"
-VsoQueuedPipelines "QueuedPipelines"
-AuthToken "$(azuresdk-azure-sdk-devops-build-queuing-pat)"
Expand Down

0 comments on commit 14fffc0

Please sign in to comment.