diff options
author | v-susu1 <v-susu@microsoft.com> | 2022-05-20 04:26:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 04:26:27 +0300 |
commit | 6284e2830f59dc9e0661121ecad0839d6640785f (patch) | |
tree | e94af0b45a0b51c41925af0cda3b1d682f45a0d8 | |
parent | eb7fec62c3ec4759ae178bd601564aa4f4d66ed6 (diff) |
Split Mdoc Release check CI into multiple jobs since single job max timeout limit (#633)
* add Mdoc-ReleaseCheckCI yml
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
* Update compareXmlFiles.ps1
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
* Update compareXmlFiles.ps1
* Update compareXmlFiles.ps1
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
* Update Mdoc-ReleaseCheckCI.yml
* Update compareXmlFiles.ps1
* Update Mdoc-ReleaseCheckCI.yml
* Update compareXmlFiles.ps1
* Update Mdoc-ReleaseCheckCI.yml
* Update Mdoc-ReleaseCheckCI.yml
* Update compareXmlFiles.ps1
* Update Mdoc-ReleaseCheckCI.yml
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
* Update Mdoc-ReleaseCheckCI.yml
* Update Mdoc-ReleaseCheckCI.yml for Azure Pipelines
-rw-r--r-- | Mdoc-ReleaseCheckCI.yml | 109 | ||||
-rw-r--r-- | mdoc/compareXmlFiles.ps1 | 103 |
2 files changed, 162 insertions, 50 deletions
diff --git a/Mdoc-ReleaseCheckCI.yml b/Mdoc-ReleaseCheckCI.yml new file mode 100644 index 00000000..8b0be5f4 --- /dev/null +++ b/Mdoc-ReleaseCheckCI.yml @@ -0,0 +1,109 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: none +pr: +- main + +# Variable 'needRunReleaseMdoc' was defined in the Variables tab +# Variable 'params' was defined in the Variables tab +# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software +variables: + solution: 'apidoctools.sln' + buildConfiguration: 'Release' + buildPlatform: 'any cpu' +name: $(date:yyyyMMdd)$(rev:.r) +resources: + repositories: + - repository: self + type: git + ref: refs/heads/develop +jobs: +- job: Job_1 + displayName: Agent job 1 + timeoutInMinutes: 600 + pool: + name: Azure Pipelines + vmImage: windows-2022 + steps: + - checkout: self + clean: true + - task: AzureKeyVault@2 + displayName: 'Azure Key Vault: ReferenceAutomation-Prod' + inputs: + ConnectedServiceName: 886728b9-fc93-486c-ba21-26777bea99af + KeyVaultName: ReferenceAutomation-Prod + enabled: true + - task: NuGetAuthenticate@0 + displayName: NuGet Authenticate + - task: PowerShell@2 + displayName: Compare xml files + timeoutInMinutes: 600 + inputs: + filePath: mdoc/compareXmlFiles.ps1 + arguments: -paramsJson '$(params)' -githubTokenBase64 '$(githubTokenBase64)' -githubOptionsAccountName $(githubOptionsAccountName) -githubOptionsAccountEmail $(githubOptionsAccountEmail) -vstsTokenBase64 '$(vstsTokenBase64)' -step '1' -commit1 '' + enabled: true + name: job1output +- job: Job_2 + displayName: Agent job2 + timeoutInMinutes: 600 + dependsOn: Job_1 + variables: + commit1: $[ dependencies.Job_1.outputs['job1output.commit1'] ] + pool: + name: Azure Pipelines + vmImage: windows-2022 + steps: + - checkout: self + clean: true + - task: AzureKeyVault@2 + displayName: 'Azure Key Vault: ReferenceAutomation-Prod' + inputs: + ConnectedServiceName: 886728b9-fc93-486c-ba21-26777bea99af + KeyVaultName: ReferenceAutomation-Prod + enabled: true + - task: NuGetToolInstaller@0 + displayName: Use NuGet 4.4.1 + inputs: + versionSpec: 4.4.1 + enabled: true + - task: NuGetCommand@2 + displayName: NuGet restore + inputs: + solution: $(BuildParameters.solution) + enabled: true + - task: CmdLine@2 + displayName: Command Line Script + inputs: + script: make prepare + enabled: true + - task: VSBuild@1 + displayName: Build solution + inputs: + solution: $(solution) + msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" + platform: $(BuildPlatform) + configuration: $(BuildConfiguration) + enabled: true + - task: NuGetAuthenticate@0 + displayName: NuGet Authenticate + - task: PowerShell@2 + displayName: Compare xml files + timeoutInMinutes: 600 + inputs: + filePath: mdoc/compareXmlFiles.ps1 + arguments: -paramsJson '$(params)' -githubTokenBase64 '$(githubTokenBase64)' -githubOptionsAccountName $(githubOptionsAccountName) -githubOptionsAccountEmail $(githubOptionsAccountEmail) -vstsTokenBase64 '$(vstsTokenBase64)' -step '2' -commit1 '$(commit1)' + enabled: true + name: job2output + - task: PowerShell@2 + displayName: Print Compare Url + inputs: + targetType: inline + script: >- + # Write your PowerShell commands here. + + + Write-Host "Compare Url: $Env:CompareUrl" +... diff --git a/mdoc/compareXmlFiles.ps1 b/mdoc/compareXmlFiles.ps1 index e4710fa7..4b0dc914 100644 --- a/mdoc/compareXmlFiles.ps1 +++ b/mdoc/compareXmlFiles.ps1 @@ -4,7 +4,8 @@ param ( [string]$githubOptionsAccountName, [string]$githubOptionsAccountEmail, [string]$vstsTokenBase64, - [bool]$needRunReleaseMdoc + [string]$step, + [string]$commit1 ) function Git-Init([string]$githubAccountName, [string]$githubAccountEmail) @@ -41,6 +42,11 @@ function Git-Push([string]$rootPath, [string] $token, [string] $commitMessage, [ { & git add --all & git commit -m $commitMessage + + & git config pull.rebase false + Write-Host 'git -c http.extraHeader="Authorization: Basic '$token'" pull' + & git -c http.extraHeader="Authorization: Basic $token" pull + & git -c http.extraHeader="Authorization: Basic $token" push --set-upstream origin $branch --force-with-lease } } @@ -107,7 +113,6 @@ function Run($source_repo,$target_repo,$origin_target_repo) Write-Host "origin target repo folder is null or empty!" } - $sourceRepoUrl = $source_repo.url $sourceRepoBranch = $source_repo.branch $sourceFolder = $source_repo.folder @@ -138,6 +143,7 @@ function Run($source_repo,$target_repo,$origin_target_repo) Write-Host "==================== Clone target repo: $targetRepoUrl" Git-Clone $targetRepoUrl $targetRepoPath $githubTokenBase64 $targetRepoBranch + if (Test-Path $xmlPath) { Write-Host "Delete files under path: $xmlPath" @@ -145,62 +151,59 @@ function Run($source_repo,$target_repo,$origin_target_repo) Write-Host "Delete files done." } Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container - - if ($needRunReleaseMdoc -eq $true) - { + + # This part(if) run in Job_1 + if($step -eq "1"){ Write-Host "==================== Run Mdoc(release version) tool to generated xml files." Run-Mdoc $releaseMdocPath $frameworksPath $xmlPath if ($lastexitcode -ne 0) { exit $lastexitcode } - } - - Write-Host "==================== First to commit xml files" - $message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER - Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch - $commitid1 = & git rev-parse HEAD - Write-Host "Commit Id1: $commitid1" - Pop-Location - if (Test-Path $xmlPath) - { - Write-Host "Delete files under path: $xmlPath" - Remove-Item -Recurse -Force $xmlPath\* - Write-Host "Delete files done." - } - Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container - - Write-Host "==================== Run Mdoc(pr version) tool to generated xml files." - Run-Mdoc $prMdocPath $frameworksPath $xmlPath - if ($lastexitcode -ne 0) - { - exit $lastexitcode - } - - Write-Host "==================== Sencond to commit xml files" - $message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER - Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch - $commitid2 = & git rev-parse HEAD - Write-Host "Commit Id2: $commitid2" - Pop-Location + + Write-Host "==================== First to commit xml files" + $message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER + Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch + $commitid1 = & git rev-parse HEAD + Write-Host "Commit Id1: $commitid1" + Pop-Location + + Write-Host "##vso[task.setvariable variable=commit1;isOutput=true]$commitid1" + } else { # This part(else) run in Job_2 - Write-Host "==================== Compare two version xml files." - $shortCommitId1 = $commitid1.Substring(0, 7) - $shortCommitId2 = $commitid2.Substring(0, 7) - if($targetRepoUrl.EndsWith(".git")) - { - $compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4) - } - else - { - $compareUrl = $targetRepoUrl + Write-Host "==================== Run Mdoc(pr version) tool to generated xml files." + Run-Mdoc $prMdocPath $frameworksPath $xmlPath + if ($lastexitcode -ne 0) + { + exit $lastexitcode + } + + Write-Host "==================== Sencond to commit xml files" + $message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER + Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch + $commitid2 = & git rev-parse HEAD + Write-Host "Commit Id2: $commitid2" + Pop-Location + + Write-Host "==================== Compare two version xml files." + $commitid1 = $commit1 # commit1 from job_1 + $shortCommitId1 = $commitid1.Substring(0, 7) + $shortCommitId2 = $commitid2.Substring(0, 7) + if($targetRepoUrl.EndsWith(".git")) + { + $compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4) + } + else + { + $compareUrl = $targetRepoUrl + } + + $compareUrl = $compareUrl + "/compare/" + $compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/" + + Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl") + Write-Host "Compare Url: $compareUrl" } - - $compareUrl = $compareUrl + "/compare/" - $compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/" - - Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl") - Write-Host "Compare Url: $compareUrl" } $params = $paramsJson | ConvertFrom-Json |