Skip to content

Commit 47a11ac

Browse files
Add appVeyor build file.
1 parent 82ded5d commit 47a11ac

File tree

1 file changed

+335
-0
lines changed

1 file changed

+335
-0
lines changed

appveyor.yml

Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
version: 5.1.0.{build}
2+
image: Visual Studio 2017
3+
configuration:
4+
- Debug
5+
- Release
6+
environment:
7+
global:
8+
targetFx: net461
9+
matrix:
10+
- db: Firebird
11+
- db: MySQL
12+
- db: Odbc
13+
- db: PostgreSQL
14+
- db: SQLite
15+
- db: SqlServerCe
16+
- db: SqlServer2008
17+
- db: SqlServer2012
18+
19+
matrix:
20+
exclude:
21+
- configuration: Release
22+
db: Firebird
23+
- configuration: Release
24+
db: MySQL
25+
- configuration: Release
26+
db: Odbc
27+
- configuration: Release
28+
db: PostgreSQL
29+
- configuration: Release
30+
db: SQLite
31+
- configuration: Release
32+
db: SqlServerCe
33+
- configuration: Release
34+
db: SqlServer2008
35+
36+
init:
37+
# Required for having windows endlines in sources zip
38+
- git config --global core.autocrlf true
39+
40+
cache:
41+
- C:\firebird\Firebird-3.0.2.32703-0_x64.zip
42+
43+
before_build:
44+
- ps: >-
45+
Invoke-Command -ScriptBlock {
46+
# Package sources if this is a release build.
47+
If ($env:CONFIGURATION -ne 'Release') {
48+
return
49+
}
50+
51+
$srcPackage = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'NHibernate-5.0.3-src')
52+
mkdir $srcPackage
53+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'build-common') $srcPackage -recurse
54+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'lib') $srcPackage -recurse
55+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'src') $srcPackage -recurse
56+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER "*.build") $srcPackage
57+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'LICENSE.txt') $srcPackage
58+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'releasenotes.txt') $srcPackage
59+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'README.md') $srcPackage
60+
}
61+
62+
- which msbuild.exe
63+
- nuget restore src/NHibernate.sln
64+
65+
# Disable automated build, use build script instead
66+
build: off
67+
build_script:
68+
- ps: >-
69+
Invoke-Command -ScriptBlock {
70+
$nugetPath = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'nuget')
71+
mkdir $nugetPath
72+
dotnet msbuild (Join-Path $env:APPVEYOR_BUILD_FOLDER 'src\NHibernate.sln') /verbosity:minimal `
73+
'/p:Platform="Any CPU"' /p:GeneratePackageOnBuild=True /p:IncludeSymbols=True `
74+
/p:IncludeSource=True "/p:PackageOutputPath=$nugetPath"
75+
}
76+
77+
before_test:
78+
- ps: >-
79+
Invoke-Command -ScriptBlock {
80+
$configDir = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'current-test-configuration')
81+
82+
#Configuration matrix
83+
$allSettings = @{
84+
'Firebird' = @{
85+
'connection.connection_string' = 'DataSource=localhost;Database=nhibernate;User ID=SYSDBA;Password=masterkey;MaxPoolSize=200;';
86+
'connection.driver_class' = 'NHibernate.Driver.FirebirdClientDriver';
87+
'dialect' = 'NHibernate.Dialect.FirebirdDialect'
88+
};
89+
'MySQL' = @{
90+
'connection.connection_string' = 'Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;';
91+
'connection.driver_class' = 'NHibernate.Driver.MySqlDataDriver';
92+
'dialect' = 'NHibernate.Dialect.MySQL5Dialect'
93+
};
94+
'Odbc' = @{
95+
# The OdbcDriver inherits SupportsMultipleOpenReaders=true from DriverBase, which requires Mars_Connection=yes for SQL Server.
96+
'connection.connection_string' = 'Server=(local)\SQL2017;Uid=sa;Pwd=Password12!;Database=nhibernateOdbc;Driver={SQL Server Native Client 11.0};Mars_Connection=yes;';
97+
'connection.driver_class' = 'NHibernate.Driver.OdbcDriver';
98+
'odbc.explicit_datetime_scale' = '3';
99+
<# We need to use a dialect that avoids mapping DbType.Time to TIME on MSSQL. On modern SQL Server
100+
this becomes TIME(7). Later, such values cannot be read back over ODBC. The
101+
error we get is "System.ArgumentException : Unknown SQL type - SS_TIME_EX.". I don't know for certain
102+
why this occurs, but MS docs do say that for a client "compiled using a version of SQL Server Native
103+
Client prior to SQL Server 2008", TIME(7) cannot be converted back to the client. Assuming that .Net's
104+
OdbcDriver would be considered a "client compiled with a previous version", it would make sense. Anyway,
105+
using the MsSql2005Dialect avoids these test failures. #>
106+
'dialect' = 'NHibernate.Dialect.MsSql2005Dialect'
107+
};
108+
'PostgreSQL' = @{
109+
'connection.connection_string' = 'Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true';
110+
'connection.driver_class' = 'NHibernate.Driver.NpgsqlDriver';
111+
'dialect' = 'NHibernate.Dialect.PostgreSQL83Dialect'
112+
};
113+
'SQLite' = @{
114+
<#
115+
DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
116+
which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
117+
See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
118+
and https://github.com/nhibernate/nhibernate-core/issues/1362 #>
119+
# Please note the connection string is formated for putting the db file in $configDir.
120+
'connection.connection_string' = "Data Source=$configDir\NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;";
121+
'connection.driver_class' = 'NHibernate.Driver.SQLite20Driver';
122+
'dialect' = 'NHibernate.Dialect.SQLiteDialect'
123+
};
124+
'SqlServerCe' = @{
125+
# Please note the connection string is formated for putting the db file in $configDir.
126+
'connection.connection_string' = "Data Source=$configDir\NHibernate.sdf;";
127+
'connection.driver_class' = 'NHibernate.Driver.SqlServerCeDriver';
128+
'command_timeout' = '0';
129+
'dialect' = 'NHibernate.Dialect.MsSqlCe40Dialect'
130+
};
131+
'SqlServer2008' = @{'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'};
132+
'SqlServer2012' = @{
133+
'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;';
134+
'dialect' = 'NHibernate.Dialect.MsSql2012Dialect'
135+
}
136+
}
137+
138+
#Settings for current build
139+
$settings = $allSettings.Get_Item($env:db)
140+
if (!$settings) {
141+
Write-Host "Unable to find $env:db settings" -foregroundcolor 'white' -backgroundcolor 'red'
142+
exit 1
143+
}
144+
145+
#Create settings file
146+
$configFile = (Join-Path $configDir 'hibernate.cfg.xml')
147+
New-Item $configDir -Type Directory
148+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'build-common\teamcity-hibernate.cfg.xml') $configFile
149+
150+
#Patch settings file
151+
$config = [xml] (Get-Content $configFile)
152+
$allProps = $config.'hibernate-configuration'.'session-factory'.property
153+
foreach($key in $settings.keys)
154+
{
155+
$value = $settings[$key]
156+
$property = $allProps | where {$_.name -eq $key}
157+
if (!$property) {
158+
Write-Host "Unable to find $key property" -foregroundcolor 'white' -backgroundcolor 'red'
159+
exit 1
160+
}
161+
$property.InnerText = $value
162+
}
163+
$config.Save($configFile)
164+
}
165+
166+
- ps: >-
167+
Invoke-Command -ScriptBlock {
168+
switch ($env:db) {
169+
'Firebird' {
170+
# Install Firebird
171+
# Firebird zip is cached, check if we have it, otherwise download it
172+
If (-Not (Test-Path C:\firebird\Firebird-3.0.2.32703-0_x64.zip)) {
173+
Write-Host "Firebird zip seemingly not cached, fetching it..."
174+
If (-Not (Test-Path C:\firebird)) {
175+
mkdir C:\firebird
176+
}
177+
cd C:\firebird
178+
# Download FireBird zip from Sourceforge. Mirror on free.fr due to my ISP, likely not the best one for AppVeyor VM.
179+
Start-FileDownload 'https://freefr.dl.sourceforge.net/project/firebird/firebird-win64/3.0.2-Release/Firebird-3.0.2.32703-0_x64.zip'
180+
}
181+
Else {
182+
cd C:\firebird
183+
}
184+
7z x Firebird-3.0.2.32703-0_x64.zip
185+
mkdir Data
186+
# Declare nhibernate db
187+
Add-Content -Path '.\databases.conf' -Value "`r`nnhibernate = C:\firebird\Data\nhibernate.fdb"
188+
# Minimal db settings
189+
Add-Content -Path '.\firebird.conf' -Value "`r`nAuthServer = Srp`r`nAuthClient = Srp`r`nUserManager = Srp`r`nWireCrypt = Enabled"
190+
# Create SYSDBA account
191+
New-Item SYSDBA.sql -Type File
192+
Add-Content -Path '.\SYSDBA.sql' -Value "create user SYSDBA password 'masterkey';`r`ncommit;`r`nquit;"
193+
.\isql -user sysdba employee -input SYSDBA.sql
194+
# Start Firebird
195+
.\firebird -a
196+
}
197+
'MySQL' {
198+
Start-Service 'MySQL57'
199+
# Create nhibernate database (not handled by NHibernate.TestDatabaseSetup.dll)
200+
$env:MYSQL_PWD = 'Password12!'
201+
$cmd = '"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql" -e "create database nhibernate;" --user=root'
202+
iex "& $cmd"
203+
}
204+
'Odbc' { Start-Service 'MSSQL$SQL2017' }
205+
'PostgreSQL' {
206+
# Enable prepared transactions
207+
Add-Content -Path 'C:\Program Files\PostgreSQL\10\data\postgresql.conf' -Value "`r`nmax_prepared_transactions = 100"
208+
Start-Service 'postgresql-x64-10'
209+
}
210+
'SqlServer2008' { Start-Service 'MSSQL$SQL2017' }
211+
'SqlServer2012' { Start-Service 'MSSQL$SQL2017' }
212+
}
213+
}
214+
215+
# Disable automatic tests: they do run multiple times the whole series otherwise. (Due to: NHibernate.Test.dll
216+
# duplication in many folders, since it is a dependency of other projects; NUnit test adapter which seems to cause
217+
# AppVeyor to also run tests as MsTests after having run them as NUnit tests.)
218+
# Moreover, it runs NUnit test assemblies in parallel, which NHibernate setup does not support.
219+
test: off
220+
221+
test_script:
222+
- ps: >-
223+
nunit3-console (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate.TestDatabaseSetup\bin\$env:CONFIGURATION\$env:targetFx\NHibernate.TestDatabaseSetup.dll") '--result=myresults.xml;format=AppVeyor'
224+
225+
- ps: >-
226+
nunit3-console (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate.Test.VisualBasic\bin\$env:CONFIGURATION\$env:targetFx\NHibernate.Test.VisualBasic.dll") '--result=myresults.xml;format=AppVeyor'
227+
228+
- ps: >-
229+
nunit3-console (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate.Test\bin\$env:CONFIGURATION\$env:targetFx\NHibernate.Test.dll") '--result=myresults.xml;format=AppVeyor'
230+
231+
after_test:
232+
- ps: >-
233+
Invoke-Command -ScriptBlock {
234+
# Package artificats if this is a release build.
235+
If ($env:CONFIGURATION -ne 'Release') {
236+
return
237+
}
238+
239+
# Binaries package
240+
$binPackage = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'NHibernate-5.0.3-bin')
241+
mkdir $binPackage
242+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'HowInstall.txt') $binPackage
243+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'LICENSE.txt') $binPackage
244+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'releasenotes.txt') $binPackage
245+
cscript (Join-Path $env:APPVEYOR_BUILD_FOLDER 'Tools\showdown\showdown.wsf') (Join-Path $env:APPVEYOR_BUILD_FOLDER 'README.md') (Join-Path $binPackage 'readme.html')
246+
247+
$cfgTemplates = (Join-Path $binPackage 'Configuration_Templates')
248+
mkdir $cfgTemplates
249+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'src\NHibernate.Config.Templates\*') $cfgTemplates
250+
251+
$reqBin = (Join-Path $binPackage 'Required_Bins')
252+
mkdir $reqBin
253+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate\bin\$env:CONFIGURATION\$env:targetFx\*") $reqBin -recurse
254+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate\*.xsd") $reqBin
255+
256+
$tests = (Join-Path $binPackage 'Tests')
257+
mkdir $tests
258+
$vbBin = (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate.Test.VisualBasic\bin\$env:CONFIGURATION\$env:targetFx")
259+
cp (Join-Path $vbBin 'DbScripts') $tests -recurse
260+
cp (Join-Path $vbBin "NHibernate.Test.*") $tests
261+
cp (Join-Path $vbBin "NHibernate.DomainModel.*") $tests
262+
cp (Join-Path $vbBin "nunit*") $tests
263+
cp (Join-Path $vbBin "*.xml") $tests -Exclude 'NHibernate.xml'
264+
cp (Join-Path $vbBin 'log4net.dll') $tests
265+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER "src\NHibernate.TestDatabaseSetup\bin\$env:CONFIGURATION\$env:targetFx\NHibernate.TestDatabaseSetup.*") $tests
266+
267+
cd $env:APPVEYOR_BUILD_FOLDER
268+
7z a NHibernate-5.0.3-bin.zip NHibernate-5.0.3-bin\
269+
270+
# Reference package
271+
choco install html-help-workshop
272+
choco install sandcastle
273+
$refPackage = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'NHibernate-5.0.3-reference')
274+
mkdir $refPackage
275+
cp (Join-Path $env:APPVEYOR_BUILD_FOLDER 'doc\LICENSE.txt') $refPackage
276+
#Common variables
277+
$refFolder = (Join-Path $env:APPVEYOR_BUILD_FOLDER 'doc\reference')
278+
$saxonClassPath = 'support/lib/avalon-framework-cvs-20020806.jar', 'support/lib/batik.jar', 'support/lib/fop-0.20.5-RFC3066-patched.jar', `
279+
'support/lib/jai_codec.jar', 'support/lib/jai_core.jar', 'support/lib/rowan-0.1.jar', 'support/lib/saxon.jar', 'support/lib/saxon-dbxsl-extensions.jar'
280+
for ($i=0; $i -lt $saxonClassPath.length; $i++) {
281+
$saxonClassPath[$i] = (Join-Path $refFolder $saxonClassPath[$i])
282+
}
283+
$saxonClassPath = $saxonClassPath -Join ';'
284+
$masterFile = (Join-Path $refFolder 'master.xml')
285+
#Html
286+
$html = (Join-Path $refPackage 'html')
287+
mkdir $html
288+
cd $html
289+
java -classpath $saxonClassPath com.icl.saxon.StyleSheet $masterFile (Join-Path $refFolder 'styles/html_chunk.xsl')
290+
#Html single page
291+
$htmlSingle = (Join-Path $refPackage 'html_single')
292+
mkdir $htmlSingle
293+
cd $htmlSingle
294+
java -classpath $saxonClassPath com.icl.saxon.StyleSheet $masterFile (Join-Path $refFolder 'styles/html.xsl')
295+
#Shared files
296+
$shared = (Join-Path $refPackage 'shared')
297+
mkdir $shared
298+
$sharedImages = (Join-Path $shared 'images')
299+
mkdir $sharedImages
300+
cp (Join-Path $refFolder "images/*") $sharedImages
301+
$sharedStyles = (Join-Path $shared 'css')
302+
mkdir $sharedStyles
303+
cp (Join-Path $refFolder "styles/*.css") $sharedStyles
304+
#CHM
305+
$tmpChm = (Join-Path $refFolder 'tmpChm')
306+
mkdir $tmpChm
307+
cd $tmpChm
308+
java -classpath $saxonClassPath com.icl.saxon.StyleSheet $masterFile (Join-Path $refFolder 'styles/chm_help.xsl')
309+
cp $shared $tmpChm -Recurse
310+
C:\Program` Files` `(x86`)\HTML` Help` Workshop\hhc (Join-Path $tmpChm 'htmlhelp.hhp')
311+
Rename-Item (Join-Path $tmpChm 'htmlhelp.chm') 'NHibernate.Reference.chm'
312+
cp (Join-Path $tmpChm 'NHibernate.Reference.chm') $refPackage
313+
#PDF
314+
$tmpPdf = (Join-Path $refFolder 'tmpPdf')
315+
mkdir $tmpPdf
316+
cd $tmpPdf
317+
$pdfImages = (Join-Path $tmpPdf 'images')
318+
mkdir $pdfImages
319+
cp (Join-Path $refFolder "images/*") $pdfImages
320+
$tmpPdfFile = (Join-Path $tmpPdf 'docbook_fop.tmp')
321+
java -classpath $saxonClassPath com.icl.saxon.StyleSheet -o $tmpPdfFile $masterFile (Join-Path $refFolder 'styles/fopdf.xsl')
322+
java -classpath $saxonClassPath org.apache.fop.apps.Fop $tmpPdfFile (Join-Path $refPackage 'nhibernate_reference.pdf')
323+
324+
cd $env:APPVEYOR_BUILD_FOLDER
325+
7z a NHibernate-5.0.3-reference.zip NHibernate-5.0.3-reference\
326+
327+
# Sources package
328+
7z a NHibernate-5.0.3-src.zip NHibernate-5.0.3-src\
329+
330+
# Push artifacts
331+
Get-ChildItem (Join-Path $env:APPVEYOR_BUILD_FOLDER 'nuget\*.nupkg') | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
332+
Push-AppveyorArtifact NHibernate-5.0.3-bin.zip
333+
Push-AppveyorArtifact NHibernate-5.0.3-reference.zip
334+
Push-AppveyorArtifact NHibernate-5.0.3-src.zip
335+
}

0 commit comments

Comments
 (0)