Skip to content

Commit fdcf07b

Browse files
committed
pr valiration parallel jobs
1 parent 8dcf9a7 commit fdcf07b

3 files changed

Lines changed: 274 additions & 73 deletions

File tree

azure-pipelines/pr-validation/pr-validation-auth.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,26 @@ stages:
3131
jobs:
3232
- template: ../templates/docker-build-push-jobs.yml
3333
parameters:
34-
JobName: 'PR_Validation_${{ variables.appName }}'
34+
JobName: 'Docker_Push_${{ variables.appName }}'
35+
solution: '$(System.DefaultWorkingDirectory)/EventTriangleAPI.sln'
36+
buildConfiguration: 'Release'
37+
backendProjectPath: '$(System.DefaultWorkingDirectory)/src/authorization/EventTriangleAPI.Authorization.Presentation'
38+
shouldRunUnitTests: false
39+
shouldRunIntegrationTests: true
40+
integrationTestsProjectPath: '$(System.DefaultWorkingDirectory)/src/authorization/EventTriangleAPI.Authorization.IntegrationTests/EventTriangleAPI.Authorization.IntegrationTests.csproj'
41+
dockerRegistryUrl: 'docker.io/kaminome'
42+
dockerBuildParameterUrl: 'https://auth-eventtriangle.razumovsky.me/'
43+
imageRepository: 'auth-service'
44+
dockerfilePath: '$(System.DefaultWorkingDirectory)/src/authorization/Dockerfile'
45+
dockerServiceConnection: 'Docker_Hub_Connection'
46+
shouldPushToAcr: true
47+
acrRegistryUrl: 'acrsharedd01.azurecr.io'
48+
acrServiceConnection: 'Azure_ACR_Connection'
49+
workingDirectoryForDocker: '$(System.DefaultWorkingDirectory)/src'
50+
51+
- template: ../templates/runs-tests-and-security-checks-jobs.yml
52+
parameters:
53+
JobName: 'Run_Tests_${{ variables.appName }}'
3554
solution: '$(System.DefaultWorkingDirectory)/EventTriangleAPI.sln'
3655
buildConfiguration: 'Release'
3756
backendProjectPath: '$(System.DefaultWorkingDirectory)/src/authorization/EventTriangleAPI.Authorization.Presentation'

azure-pipelines/templates/docker-build-push-jobs.yml

Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ jobs:
9696
- checkout: self
9797
fetchDepth: 0
9898

99-
- task: UseDotNet@2
100-
displayName: 'Install .NET SDK ${{ parameters.dotnetSdkVersion }}'
101-
inputs:
102-
packageType: 'sdk'
103-
version: '${{ parameters.dotnetSdkVersion }}'
99+
# - task: UseDotNet@2
100+
# displayName: 'Install .NET SDK ${{ parameters.dotnetSdkVersion }}'
101+
# inputs:
102+
# packageType: 'sdk'
103+
# version: '${{ parameters.dotnetSdkVersion }}'
104104

105105
- task: gitversion-setup@4.5.0
106106
displayName: 'GitVersion Setup'
@@ -128,76 +128,67 @@ jobs:
128128
Write-Host "Build Source branch: $env:BUILD_SOURCEBRANCHNAME"
129129
displayName: Debug environment
130130
131-
# - task: PowerShell@2
132-
# displayName: 'Debug branch condition'
133-
# condition: ne(variables['Build.SourceBranchName'], 'main')
131+
# - task: DotNetCoreCLI@2
132+
# displayName: 'Dotnet restore'
134133
# inputs:
135-
# targetType: 'inline'
136-
# script: |
137-
# Write-Host "Running because branch is NOT main"
138-
# Write-Host "Branch: $env:BUILD_SOURCEBRANCHNAME"
139-
140-
- task: DotNetCoreCLI@2
141-
displayName: 'Dotnet restore'
142-
inputs:
143-
command: 'restore'
144-
projects: '${{ parameters.solution }}'
145-
arguments: '--verbosity minimal'
146-
nugetConfigPath: 'nuget.config'
147-
148-
- task: SonarCloudPrepare@4
149-
condition: and(
150-
succeeded(),
151-
${{ parameters.sonarCloudEnabled }},
152-
eq(variables['Build.SourceBranchName'], 'main'))
153-
inputs:
154-
SonarCloud: ${{ parameters.sonarCloudServiceConnection }}
155-
organization: event-triangle
156-
scannerMode: dotnet
157-
projectKey: event-triangle-api
158-
projectName: eventtriangleapi
159-
extraProperties: |
160-
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
161-
sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*opencover.xml
162-
sonar.exclusions=**/Properties/**, **/bin/**, **/obj/**, **/Migrations/**
163-
164-
- task: DotNetCoreCLI@2
165-
displayName: 'Build solution'
166-
inputs:
167-
command: 'build'
168-
projects: '${{ parameters.solution }}'
169-
arguments: '-c ${{ parameters.buildConfiguration }} -p:Version=$(version_step.semVer) --no-restore'
170-
171-
- task: SonarCloudAnalyze@4
172-
condition: and(
173-
succeeded(),
174-
${{ parameters.sonarCloudEnabled }},
175-
eq(variables['Build.SourceBranchName'], 'main'))
176-
inputs: {}
177-
178-
- task: SonarCloudPublish@4
179-
condition: and(
180-
succeeded(),
181-
${{ parameters.sonarCloudEnabled }},
182-
eq(variables['Build.SourceBranchName'], 'main'))
183-
inputs:
184-
pollingTimeoutSec: "300"
134+
# command: 'restore'
135+
# projects: '${{ parameters.solution }}'
136+
# arguments: '--verbosity minimal'
137+
# nugetConfigPath: 'nuget.config'
138+
139+
# - task: SonarCloudPrepare@4
140+
# condition: and(
141+
# succeeded(),
142+
# ${{ parameters.sonarCloudEnabled }},
143+
# eq(variables['Build.SourceBranchName'], 'main'))
144+
# inputs:
145+
# SonarCloud: ${{ parameters.sonarCloudServiceConnection }}
146+
# organization: event-triangle
147+
# scannerMode: dotnet
148+
# projectKey: event-triangle-api
149+
# projectName: eventtriangleapi
150+
# extraProperties: |
151+
# sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
152+
# sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*opencover.xml
153+
# sonar.exclusions=**/Properties/**, **/bin/**, **/obj/**, **/Migrations/**
154+
155+
# - task: DotNetCoreCLI@2
156+
# displayName: 'Build solution'
157+
# inputs:
158+
# command: 'build'
159+
# projects: '${{ parameters.solution }}'
160+
# arguments: '-c ${{ parameters.buildConfiguration }} -p:Version=$(version_step.semVer) --no-restore'
161+
162+
# - task: SonarCloudAnalyze@4
163+
# condition: and(
164+
# succeeded(),
165+
# ${{ parameters.sonarCloudEnabled }},
166+
# eq(variables['Build.SourceBranchName'], 'main'))
167+
# inputs: {}
168+
169+
# - task: SonarCloudPublish@4
170+
# condition: and(
171+
# succeeded(),
172+
# ${{ parameters.sonarCloudEnabled }},
173+
# eq(variables['Build.SourceBranchName'], 'main'))
174+
# inputs:
175+
# pollingTimeoutSec: "300"
185176

186-
- task: DotnetCoreCLI@2
187-
displayName: 'Run unit tests'
188-
condition: and(succeeded(), eq(${{ parameters.shouldRunUnitTests }}, true))
189-
inputs:
190-
command: 'test'
191-
projects: '${{ parameters.unitTestsProjectPath }}'
192-
arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
177+
# - task: DotnetCoreCLI@2
178+
# displayName: 'Run unit tests'
179+
# condition: and(succeeded(), eq(${{ parameters.shouldRunUnitTests }}, true))
180+
# inputs:
181+
# command: 'test'
182+
# projects: '${{ parameters.unitTestsProjectPath }}'
183+
# arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
193184

194-
- task: DotNetCoreCLI@2
195-
displayName: 'Run integration tests'
196-
condition: and(succeeded(), eq(${{ parameters.shouldRunIntegrationTests }}, true))
197-
inputs:
198-
command: 'test'
199-
projects: '${{ parameters.integrationTestsProjectPath }}'
200-
arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
185+
# - task: DotNetCoreCLI@2
186+
# displayName: 'Run integration tests'
187+
# condition: and(succeeded(), eq(${{ parameters.shouldRunIntegrationTests }}, true))
188+
# inputs:
189+
# command: 'test'
190+
# projects: '${{ parameters.integrationTestsProjectPath }}'
191+
# arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
201192

202193
- task: PowerShell@2
203194
displayName: 'Build Docker Image'
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
parameters:
2+
- name: JobName
3+
displayName: 'Job Name'
4+
type: string
5+
6+
- name: workingDirectoryForDocker
7+
displayName: 'Working directory for Docker Build'
8+
default: '$(System.DefaultWorkingDirectory)/src'
9+
type: string
10+
11+
- name: solution
12+
displayName: 'Solution file path'
13+
type: string
14+
15+
- name: buildConfiguration
16+
displayName: 'Build Configuration'
17+
default: 'Release'
18+
type: string
19+
20+
- name: backendProjectPath
21+
displayName: 'Backend project path'
22+
type: string
23+
24+
- name: unitTestsProjectPath
25+
displayName: 'Unit tests project path'
26+
default: ''
27+
type: string
28+
29+
- name: shouldRunUnitTests
30+
displayName: 'Flag should run unit tests'
31+
default: true
32+
type: boolean
33+
34+
- name: shouldRunIntegrationTests
35+
displayName: 'Flag should run integration tests'
36+
type: boolean
37+
38+
- name: integrationTestsProjectPath
39+
displayName: 'Integration tests project path'
40+
type: string
41+
42+
- name: gitVersionVersion
43+
displayName: 'GitVersion version'
44+
default: '6.x'
45+
type: string
46+
47+
- name: dockerRegistryUrl
48+
type: string
49+
displayName: 'DockerHub Registry URL. For Docker Hub it is: docker.io/kaminome.'
50+
51+
- name: shouldPushToAcr
52+
type: boolean
53+
default: false
54+
55+
- name: acrRegistryUrl
56+
type: string
57+
displayName: 'ACR Registry URL. For ACR it is FQDN URL of container registry: azuredevopsacrd01.azurecr.io'
58+
59+
- name: imageRepository
60+
displayName: 'Image Repository name'
61+
type: string
62+
63+
- name: dockerfilePath
64+
displayName: 'Dockerfile path'
65+
type: string
66+
67+
- name: dockerServiceConnection
68+
displayName: 'Docker container registry service connection in Azure DevOps.'
69+
type: string
70+
71+
- name: acrServiceConnection
72+
displayName: 'Azure container registry service connection in Azure DevOps.'
73+
type: string
74+
75+
- name: dockerBuildParameterUrl
76+
displayName: 'Build parameter for Docker: Base URL'
77+
default: 'https://auth.eventtriangle.razumovsky.me/'
78+
type: string
79+
80+
- name: dotnetSdkVersion
81+
type: string
82+
default: '10.x'
83+
84+
- name: sonarCloudEnabled
85+
type: boolean
86+
default: false
87+
88+
- name: sonarCloudServiceConnection
89+
type: string
90+
default: SonarCloud_Service_Connection
91+
92+
jobs:
93+
- job: ${{ parameters.JobName }}
94+
displayName: ${{ parameters.JobName }}
95+
steps:
96+
- checkout: self
97+
fetchDepth: 0
98+
99+
- task: UseDotNet@2
100+
displayName: 'Install .NET SDK ${{ parameters.dotnetSdkVersion }}'
101+
inputs:
102+
packageType: 'sdk'
103+
version: '${{ parameters.dotnetSdkVersion }}'
104+
105+
- task: gitversion-setup@4.5.0
106+
displayName: 'GitVersion Setup'
107+
inputs:
108+
versionSpec: ${{ parameters.gitVersionVersion }}
109+
110+
- task: gitversion-execute@4.5.0
111+
name: version_step # step id used as a reference for output values
112+
displayName: Determine Version
113+
114+
- bash: echo $Action$BuildVersion
115+
displayName: 'Set Build Version'
116+
env:
117+
Action: '##vso[build.updatebuildnumber]'
118+
BuildVersion: $(version_step.semVer)
119+
120+
- pwsh: |
121+
Write-Host "=== ENV VARIABLES ==="
122+
Get-ChildItem Env: | Sort-Object Name
123+
124+
Write-Host "=== PIPELINE VARIABLES ==="
125+
Write-Host "FullSemVer: $(version_step.FullSemVer)"
126+
Write-Host "SemVer: $(version_step.SemVer)"
127+
Write-Host "ShortSha: $(version_step.ShortSha)"
128+
Write-Host "Build Source branch: $env:BUILD_SOURCEBRANCHNAME"
129+
displayName: Debug environment
130+
131+
- task: DotNetCoreCLI@2
132+
displayName: 'Dotnet restore'
133+
inputs:
134+
command: 'restore'
135+
projects: '${{ parameters.solution }}'
136+
arguments: '--verbosity minimal'
137+
nugetConfigPath: 'nuget.config'
138+
139+
- task: SonarCloudPrepare@4
140+
condition: and(
141+
succeeded(),
142+
${{ parameters.sonarCloudEnabled }},
143+
eq(variables['Build.SourceBranchName'], 'main'))
144+
inputs:
145+
SonarCloud: ${{ parameters.sonarCloudServiceConnection }}
146+
organization: event-triangle
147+
scannerMode: dotnet
148+
projectKey: event-triangle-api
149+
projectName: eventtriangleapi
150+
extraProperties: |
151+
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
152+
sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*opencover.xml
153+
sonar.exclusions=**/Properties/**, **/bin/**, **/obj/**, **/Migrations/**
154+
155+
- task: DotNetCoreCLI@2
156+
displayName: 'Build solution'
157+
inputs:
158+
command: 'build'
159+
projects: '${{ parameters.solution }}'
160+
arguments: '-c ${{ parameters.buildConfiguration }} -p:Version=$(version_step.semVer) --no-restore'
161+
162+
- task: SonarCloudAnalyze@4
163+
condition: and(
164+
succeeded(),
165+
${{ parameters.sonarCloudEnabled }},
166+
eq(variables['Build.SourceBranchName'], 'main'))
167+
inputs: {}
168+
169+
- task: SonarCloudPublish@4
170+
condition: and(
171+
succeeded(),
172+
${{ parameters.sonarCloudEnabled }},
173+
eq(variables['Build.SourceBranchName'], 'main'))
174+
inputs:
175+
pollingTimeoutSec: "300"
176+
177+
- task: DotnetCoreCLI@2
178+
displayName: 'Run unit tests'
179+
condition: and(succeeded(), eq(${{ parameters.shouldRunUnitTests }}, true))
180+
inputs:
181+
command: 'test'
182+
projects: '${{ parameters.unitTestsProjectPath }}'
183+
arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'
184+
185+
- task: DotNetCoreCLI@2
186+
displayName: 'Run integration tests'
187+
condition: and(succeeded(), eq(${{ parameters.shouldRunIntegrationTests }}, true))
188+
inputs:
189+
command: 'test'
190+
projects: '${{ parameters.integrationTestsProjectPath }}'
191+
arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --collect "Code Coverage"'

0 commit comments

Comments
 (0)