-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild.yml
138 lines (132 loc) · 4.27 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
variables:
srcPattern: 'src/**/*.csproj'
samplesPattern: 'samples/**/*.csproj'
testPattern: 'tests/**/*.Test.csproj'
integrationTestPattern: 'tests/**/*.IntegrationTest.csproj'
buildConfiguration: 'Release'
trigger:
branches:
include: [ 'develop', 'main' ]
paths:
include: [ 'src', 'samples' ]
stages:
- stage : Build
jobs:
- job: Build
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore src packages'
inputs:
command: restore
projects: '$(srcPattern)'
- task: DotNetCoreCLI@2
displayName: 'Restore samples packages'
inputs:
command: restore
projects: '$(samplesPattern)'
- task: DotNetCoreCLI@2
displayName: 'Build sources'
inputs:
command: build
arguments: '--configuration $(BuildConfiguration)'
projects: '$(srcPattern)'
- task: DotNetCoreCLI@2
displayName: 'Build samples'
inputs:
command: build
arguments: '--configuration $(BuildConfiguration)'
projects: '$(samplesPattern)'
- task: DotNetCoreCLI@2
displayName: 'Run unit tests'
inputs:
command: test
arguments: >
--configuration $(buildConfiguration)
/p:CollectCoverage=true
/p:CoverletOutputFormat=opencover%2ccobertura
projects: '$(testPattern)'
- task: reportgenerator@4
inputs:
reports: '$(Build.SourcesDirectory)/**/*cobertura.xml'
targetdir: '$(Build.ArtifactStagingDirectory)/coveragereport'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/coveragereport/Cobertura.xml'
- task: ArchiveFiles@2
displayName: 'Archive binaries'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/src/LightningPay.DependencyInjection/bin/Release/'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/binaries.zip'
- task: DotNetCoreCLI@2
displayName: 'Build nuget packages'
inputs:
command: pack
configuration: '$(buildConfiguration)'
packagesToPack: '$(srcPattern)'
versioningScheme: 'byBuildNumber'
packDirectory: '$(Build.ArtifactStagingDirectory)/nuget'
- publish: '$(Build.ArtifactStagingDirectory)/nuget'
artifact: 'nuget'
- publish: '$(Build.ArtifactStagingDirectory)/binaries.zip'
artifact: 'binaries'
- stage : IntegrationTest
dependsOn:
- Build
jobs:
- job: IntegrationTest
steps:
- task: DockerCompose@0
displayName: 'Docker Compose up'
inputs:
dockerComposeFile: '$(Build.SourcesDirectory)/docker/docker-compose.yml'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up -d'
- task: DotNetCoreCLI@2
displayName: 'Run integration tests'
inputs:
command: test
arguments: >
--configuration $(buildConfiguration)
projects: '$(integrationTestPattern)'
- task: DockerCompose@0
displayName: 'Docker Compose down'
condition: always()
inputs:
dockerComposeFile: '$(Build.SourcesDirectory)/docker/docker-compose.yml'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'down'
- stage : Release
dependsOn:
- IntegrationTest
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
jobs:
- job: PublishNugetPackages
steps:
- download: current
artifact: 'nuget'
- task: DotNetCoreCLI@2
enabled: false
displayName: 'Push nuget packages'
inputs:
command: push
packagesToPack: $(Pipeline.Workspace)/**/nuget/*.nupkg
nuGetFeedType: 'external'
publishFeedCredentials: 'NugetOrg'
- job: AddGithubRelease
steps:
- download: current
artifact: 'binaries'
- task: GithubRelease@0
displayName: 'Add github release'
inputs:
gitHubConnection: github.com_using-system
packagesToPack: using-system/LightningPay
assets: $(Pipeline.Workspace)/binaries/binaries.zip
tagSource: manual
tag: $(Build.BuildNumber)
title: $(Build.BuildNumber)
isDraft: true