-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
228 lines (202 loc) · 8.17 KB
/
azure-pipelines.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- '*'
exclude:
- gh-pages
paths:
exclude:
- README.md
tags:
include:
- '*'
schedules:
- cron: "0 18 * * 0"
displayName: Weekly build
branches:
include:
- master
always: true
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
dBTestCompareGeneratorVersion: '0.1.0'
SQL_SERVER: 'localhost'
SQL_SERVERINSTANCE: 'SQLEXPRESS'
SQL_SERVERDBNAME: 'AdventureWorks2008R2'
SQL_SERVER_USERNAME: 'sa'
SQL_SERVER_PASSWORD: 'yourStrong22Password'
jobs:
- job: BuildOnLinux
pool:
vmImage: 'ubuntu-latest'
steps:
- task: PowerShell@2
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
inputs:
targetType: 'inline'
script: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=dBTestCompareGeneratorVersion]$tag"
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- script: dotnet build --configuration $(buildConfiguration) /p:Version=$(dBTestCompareGeneratorVersion)
- task: DockerCompose@0
inputs:
containerregistrytype: 'Container Registry'
dockerComposeFile: '**/docker-compose.yml'
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up -d'
- task: PowerShell@2
displayName: download backup and jdbc drivers
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0
./download-backup-and-jdbc-drivers.ps1
- task: PowerShell@2
displayName: download latest release
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0
echo $(Build.BuildNumber)
./download-latest-release.ps1
- task: PowerShell@2
displayName: restore backup
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0
rm -rfv test-definitions
rm -rfv README.md
rm -rfv LICENSE-3RD-PARTY
rm -rfv LICENSE
./restore-backup.ps1
- task: CmdLine@2
displayName: set chmod run DBTestCompareGenerator
inputs:
script: |
cd ./DBTestCompareGenerator/bin/$(buildConfiguration)/net8.0/
mv ./DBTestCompare*/DBTestCompare-*-SNAPSHOT-jar-with-dependencies.jar ./
chmod 777 ./DBTestCompareGenerator
chmod 777 ./DBTestCompare-*-SNAPSHOT-jar-with-dependencies.jar
ls -alR
./DBTestCompareGenerator
- task: PowerShell@2
displayName: run DBTestCompare
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0\
.\set-tokens-for-tests.ps1 -OutDir ".\test-definitions\" -FileType "cmpSqlResults-config.xml" -token "\$\{SQL_SERVER\}|\$\{SQL_SERVERDBNAME\}|\$\{SQL_SERVER_USERNAME\}|\$\{SQL_SERVER_PASSWORD\}" -Value "$(SQL_SERVER)|$(SQL_SERVERDBNAME)|$(SQL_SERVER_USERNAME)|$(SQL_SERVER_PASSWORD)"
$DBTestCompare = (Resolve-Path ".\DBTestCompare-*-SNAPSHOT-jar-with-dependencies.jar").ToString()
/usr/bin/java -jar $DBTestCompare
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/TEST-*.xml'
- task: PowerShell@2
displayName: run DBTestCompare
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0
.\set-appsettings.ps1 ".\" "appsettings.json" "appSettings" "ReadExcelFile|DacpacFolder|Folder|UnpackDacpac" "true|$(Build.SourcesDirectory)\Dacpac|$(Build.SourcesDirectory)\Current|true" $true
./DBTestCompareGenerator
.\set-tokens-for-tests.ps1 -OutDir ".\test-definitions\" -FileType "cmpSqlResults-config.xml" -token "\$\{SQL_SERVER\}|\$\{SQL_SERVERDBNAME\}|\$\{SQL_SERVER_USERNAME\}|\$\{SQL_SERVER_PASSWORD\}" -Value "$(SQL_SERVER)|$(SQL_SERVERDBNAME)|$(SQL_SERVER_USERNAME)|$(SQL_SERVER_PASSWORD)"
$DBTestCompare = (Resolve-Path ".\DBTestCompare-*-SNAPSHOT-jar-with-dependencies.jar").ToString()
/usr/bin/java -jar $DBTestCompare
- task: ArchiveFiles@2
displayName: 'Zip generated objects definition'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)\Current'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: 'Publish sql files'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
ArtifactName: 'definitions'
- task: PublishBuildArtifacts@1
displayName: 'Publish dacpack files'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)\Dacpac/$(SQL_SERVERDBNAME).dacpac'
ArtifactName: '$(SQL_SERVERDBNAME)'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/TEST-*.xml'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
cd .\DBTestCompareGenerator\bin\$(buildConfiguration)\net8.0
rm -rfv test-definitions zip deploy jdbc_drivers target test-output
rm -f *.bak *.jar *.log
- task: PublishPipelineArtifact@1
inputs:
targetPath: './DBTestCompareGenerator/bin/$(buildConfiguration)/net8.0'
artifact: 'DBTestCompareGeneratorLinux$(dBTestCompareGeneratorVersion)'
publishLocation: 'pipeline'
- task: GitHubRelease@1
condition: and(succeeded(),startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: 'github.com_dbtestcomparegenerator'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tagSource: 'gitTag'
tagPattern: '\d\.\d'
target: '$(Build.SourceVersion)'
tag: '$(dBTestCompareGeneratorVersion)'
title: 'Version $(dBTestCompareGeneratorVersion)'
changeLogCompareToRelease: 'lastNonDraftReleaseByTag'
changeLogType: 'commitBased'
assets: '$(Build.ArtifactStagingDirectory)/DBTestCompareGeneratorLinux$(dBTestCompareGeneratorVersion).zip'
- job: BuildOnWindows
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
inputs:
targetType: 'inline'
script: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=dBTestCompareGeneratorVersion]$tag"
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- script: dotnet build --configuration $(buildConfiguration) /p:Version=$(dBTestCompareGeneratorVersion)
- task: PublishPipelineArtifact@1
inputs:
targetPath: './DBTestCompareGenerator/bin/$(buildConfiguration)/net8.0'
artifact: 'DBTestCompareGeneratorWindows$(dBTestCompareGeneratorVersion)'
publishLocation: 'pipeline'
- task: GitHubRelease@1
condition: and(succeeded(),startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: 'github.com_dbtestcomparegenerator'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tagSource: 'gitTag'
tagPattern: '\d\.\d.\d'
target: '$(Build.SourceVersion)'
tag: '$(dBTestCompareGeneratorVersion)'
title: 'Version $(dBTestCompareGeneratorVersion)'
changeLogCompareToRelease: 'lastNonDraftReleaseByTag'
changeLogType: 'commitBased'
assets: '$(Build.ArtifactStagingDirectory)/DBTestCompareGeneratorWindows$(dBTestCompareGeneratorVersion).zip'
addChangeLog: false