Skip to content

Commit 6284e28

Browse files
authored
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
1 parent eb7fec6 commit 6284e28

2 files changed

Lines changed: 162 additions & 50 deletions

File tree

Mdoc-ReleaseCheckCI.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
6+
trigger: none
7+
pr:
8+
- main
9+
10+
# Variable 'needRunReleaseMdoc' was defined in the Variables tab
11+
# Variable 'params' was defined in the Variables tab
12+
# 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
13+
variables:
14+
solution: 'apidoctools.sln'
15+
buildConfiguration: 'Release'
16+
buildPlatform: 'any cpu'
17+
name: $(date:yyyyMMdd)$(rev:.r)
18+
resources:
19+
repositories:
20+
- repository: self
21+
type: git
22+
ref: refs/heads/develop
23+
jobs:
24+
- job: Job_1
25+
displayName: Agent job 1
26+
timeoutInMinutes: 600
27+
pool:
28+
name: Azure Pipelines
29+
vmImage: windows-2022
30+
steps:
31+
- checkout: self
32+
clean: true
33+
- task: AzureKeyVault@2
34+
displayName: 'Azure Key Vault: ReferenceAutomation-Prod'
35+
inputs:
36+
ConnectedServiceName: 886728b9-fc93-486c-ba21-26777bea99af
37+
KeyVaultName: ReferenceAutomation-Prod
38+
enabled: true
39+
- task: NuGetAuthenticate@0
40+
displayName: NuGet Authenticate
41+
- task: PowerShell@2
42+
displayName: Compare xml files
43+
timeoutInMinutes: 600
44+
inputs:
45+
filePath: mdoc/compareXmlFiles.ps1
46+
arguments: -paramsJson '$(params)' -githubTokenBase64 '$(githubTokenBase64)' -githubOptionsAccountName $(githubOptionsAccountName) -githubOptionsAccountEmail $(githubOptionsAccountEmail) -vstsTokenBase64 '$(vstsTokenBase64)' -step '1' -commit1 ''
47+
enabled: true
48+
name: job1output
49+
- job: Job_2
50+
displayName: Agent job2
51+
timeoutInMinutes: 600
52+
dependsOn: Job_1
53+
variables:
54+
commit1: $[ dependencies.Job_1.outputs['job1output.commit1'] ]
55+
pool:
56+
name: Azure Pipelines
57+
vmImage: windows-2022
58+
steps:
59+
- checkout: self
60+
clean: true
61+
- task: AzureKeyVault@2
62+
displayName: 'Azure Key Vault: ReferenceAutomation-Prod'
63+
inputs:
64+
ConnectedServiceName: 886728b9-fc93-486c-ba21-26777bea99af
65+
KeyVaultName: ReferenceAutomation-Prod
66+
enabled: true
67+
- task: NuGetToolInstaller@0
68+
displayName: Use NuGet 4.4.1
69+
inputs:
70+
versionSpec: 4.4.1
71+
enabled: true
72+
- task: NuGetCommand@2
73+
displayName: NuGet restore
74+
inputs:
75+
solution: $(BuildParameters.solution)
76+
enabled: true
77+
- task: CmdLine@2
78+
displayName: Command Line Script
79+
inputs:
80+
script: make prepare
81+
enabled: true
82+
- task: VSBuild@1
83+
displayName: Build solution
84+
inputs:
85+
solution: $(solution)
86+
msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
87+
platform: $(BuildPlatform)
88+
configuration: $(BuildConfiguration)
89+
enabled: true
90+
- task: NuGetAuthenticate@0
91+
displayName: NuGet Authenticate
92+
- task: PowerShell@2
93+
displayName: Compare xml files
94+
timeoutInMinutes: 600
95+
inputs:
96+
filePath: mdoc/compareXmlFiles.ps1
97+
arguments: -paramsJson '$(params)' -githubTokenBase64 '$(githubTokenBase64)' -githubOptionsAccountName $(githubOptionsAccountName) -githubOptionsAccountEmail $(githubOptionsAccountEmail) -vstsTokenBase64 '$(vstsTokenBase64)' -step '2' -commit1 '$(commit1)'
98+
enabled: true
99+
name: job2output
100+
- task: PowerShell@2
101+
displayName: Print Compare Url
102+
inputs:
103+
targetType: inline
104+
script: >-
105+
# Write your PowerShell commands here.
106+
107+
108+
Write-Host "Compare Url: $Env:CompareUrl"
109+
...

mdoc/compareXmlFiles.ps1

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ param (
44
[string]$githubOptionsAccountName,
55
[string]$githubOptionsAccountEmail,
66
[string]$vstsTokenBase64,
7-
[bool]$needRunReleaseMdoc
7+
[string]$step,
8+
[string]$commit1
89
)
910

1011
function Git-Init([string]$githubAccountName, [string]$githubAccountEmail)
@@ -41,6 +42,11 @@ function Git-Push([string]$rootPath, [string] $token, [string] $commitMessage, [
4142
{
4243
& git add --all
4344
& git commit -m $commitMessage
45+
46+
& git config pull.rebase false
47+
Write-Host 'git -c http.extraHeader="Authorization: Basic '$token'" pull'
48+
& git -c http.extraHeader="Authorization: Basic $token" pull
49+
4450
& git -c http.extraHeader="Authorization: Basic $token" push --set-upstream origin $branch --force-with-lease
4551
}
4652
}
@@ -107,7 +113,6 @@ function Run($source_repo,$target_repo,$origin_target_repo)
107113
Write-Host "origin target repo folder is null or empty!"
108114
}
109115

110-
111116
$sourceRepoUrl = $source_repo.url
112117
$sourceRepoBranch = $source_repo.branch
113118
$sourceFolder = $source_repo.folder
@@ -138,69 +143,67 @@ function Run($source_repo,$target_repo,$origin_target_repo)
138143

139144
Write-Host "==================== Clone target repo: $targetRepoUrl"
140145
Git-Clone $targetRepoUrl $targetRepoPath $githubTokenBase64 $targetRepoBranch
146+
141147
if (Test-Path $xmlPath)
142148
{
143149
Write-Host "Delete files under path: $xmlPath"
144150
Remove-Item -Recurse -Force $xmlPath\*
145151
Write-Host "Delete files done."
146152
}
147153
Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container
148-
149-
if ($needRunReleaseMdoc -eq $true)
150-
{
154+
155+
# This part(if) run in Job_1
156+
if($step -eq "1"){
151157
Write-Host "==================== Run Mdoc(release version) tool to generated xml files."
152158
Run-Mdoc $releaseMdocPath $frameworksPath $xmlPath
153159
if ($lastexitcode -ne 0)
154160
{
155161
exit $lastexitcode
156162
}
157-
}
158-
159-
Write-Host "==================== First to commit xml files"
160-
$message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER
161-
Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch
162-
$commitid1 = & git rev-parse HEAD
163-
Write-Host "Commit Id1: $commitid1"
164-
Pop-Location
165-
if (Test-Path $xmlPath)
166-
{
167-
Write-Host "Delete files under path: $xmlPath"
168-
Remove-Item -Recurse -Force $xmlPath\*
169-
Write-Host "Delete files done."
170-
}
171-
Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container
172-
173-
Write-Host "==================== Run Mdoc(pr version) tool to generated xml files."
174-
Run-Mdoc $prMdocPath $frameworksPath $xmlPath
175-
if ($lastexitcode -ne 0)
176-
{
177-
exit $lastexitcode
178-
}
179-
180-
Write-Host "==================== Sencond to commit xml files"
181-
$message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER
182-
Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch
183-
$commitid2 = & git rev-parse HEAD
184-
Write-Host "Commit Id2: $commitid2"
185-
Pop-Location
163+
164+
Write-Host "==================== First to commit xml files"
165+
$message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER
166+
Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch
167+
$commitid1 = & git rev-parse HEAD
168+
Write-Host "Commit Id1: $commitid1"
169+
Pop-Location
170+
171+
Write-Host "##vso[task.setvariable variable=commit1;isOutput=true]$commitid1"
172+
} else { # This part(else) run in Job_2
186173

187-
Write-Host "==================== Compare two version xml files."
188-
$shortCommitId1 = $commitid1.Substring(0, 7)
189-
$shortCommitId2 = $commitid2.Substring(0, 7)
190-
if($targetRepoUrl.EndsWith(".git"))
191-
{
192-
$compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4)
193-
}
194-
else
195-
{
196-
$compareUrl = $targetRepoUrl
174+
Write-Host "==================== Run Mdoc(pr version) tool to generated xml files."
175+
Run-Mdoc $prMdocPath $frameworksPath $xmlPath
176+
if ($lastexitcode -ne 0)
177+
{
178+
exit $lastexitcode
179+
}
180+
181+
Write-Host "==================== Sencond to commit xml files"
182+
$message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER
183+
Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch
184+
$commitid2 = & git rev-parse HEAD
185+
Write-Host "Commit Id2: $commitid2"
186+
Pop-Location
187+
188+
Write-Host "==================== Compare two version xml files."
189+
$commitid1 = $commit1 # commit1 from job_1
190+
$shortCommitId1 = $commitid1.Substring(0, 7)
191+
$shortCommitId2 = $commitid2.Substring(0, 7)
192+
if($targetRepoUrl.EndsWith(".git"))
193+
{
194+
$compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4)
195+
}
196+
else
197+
{
198+
$compareUrl = $targetRepoUrl
199+
}
200+
201+
$compareUrl = $compareUrl + "/compare/"
202+
$compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/"
203+
204+
Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl")
205+
Write-Host "Compare Url: $compareUrl"
197206
}
198-
199-
$compareUrl = $compareUrl + "/compare/"
200-
$compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/"
201-
202-
Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl")
203-
Write-Host "Compare Url: $compareUrl"
204207
}
205208

206209
$params = $paramsJson | ConvertFrom-Json

0 commit comments

Comments
 (0)