Skip to content

Commit 3c6cd76

Browse files
Add AppVeyor build configuration
Co-authored-by: Frédéric Delaporte <[email protected]>
1 parent 75f4216 commit 3c6cd76

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed

appveyor.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
version: 5.1.0.{build}
2+
image: Visual Studio 2017
3+
environment:
4+
matrix:
5+
- DB: SqlServer2008
6+
CONNECTION_STRING: Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;
7+
- DB: PostgreSQL
8+
CONNECTION_STRING: Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true;
9+
- DB: Firebird
10+
- DB: MySQL
11+
CONNECTION_STRING: Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;
12+
init:
13+
# Required for having windows endlines in sources zip
14+
- git config --global core.autocrlf true
15+
matrix:
16+
allow_failures:
17+
- DB: MySQL
18+
build: off
19+
before_test:
20+
- ps: |-
21+
switch ($env:DB) {
22+
'Firebird' {
23+
$FireBirdPath = 'C:\firebird'
24+
# Install Firebird
25+
New-Item -ItemType Directory -Force $FireBirdPath > $null
26+
Push-Location $FireBirdPath
27+
Invoke-WebRequest 'https://github.com/FirebirdSQL/firebird/releases/download/R3_0_3/Firebird-3.0.3.32900-0_x64.zip' -OutFile firebird.zip
28+
Unblock-File firebird.zip
29+
7z x firebird.zip
30+
New-Item -ItemType Directory -Force Data
31+
# Declare nhibernate db
32+
Add-Content -Path '.\databases.conf' -Value "`r`nnhibernate = $FireBirdPath\Data\nhibernate.fdb"
33+
# Minimal db settings
34+
Add-Content -Path '.\firebird.conf' -Value "`r`nAuthServer = Srp`r`nAuthClient = Srp`r`nUserManager = Srp`r`nWireCrypt = Enabled"
35+
# Create SYSDBA account
36+
New-Item SYSDBA.sql -Type File
37+
Add-Content -Path '.\SYSDBA.sql' -Value "CREATE USER SYSDBA PASSWORD 'masterkey';`r`nCOMMIT;`r`nQUIT;"
38+
.\isql -user sysdba employee -input SYSDBA.sql
39+
# Start Firebird
40+
.\firebird.exe -a
41+
Pop-Location
42+
}
43+
'MySQL' {
44+
Start-Service 'MySQL57'
45+
# Create nhibernate database (not handled by NHibernate.TestDatabaseSetup.dll)
46+
$env:MYSQL_PWD = 'Password12!'
47+
& 'C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql' -e 'CREATE DATABASE nhibernate;' --user=root
48+
}
49+
'Odbc' { Start-Service 'MSSQL$SQL2017' }
50+
'PostgreSQL' {
51+
# Enable prepared transactions
52+
Add-Content -Path 'C:\Program Files\PostgreSQL\10\data\postgresql.conf' -Value "`r`nmax_prepared_transactions = 100"
53+
Start-Service 'postgresql-x64-10'
54+
}
55+
'SqlServer2008' { Start-Service 'MSSQL$SQL2017' }
56+
'SqlServer2012' { Start-Service 'MSSQL$SQL2017' }
57+
}
58+
test_script:
59+
- cmd: powershell -noprofile -command "& ./build.ps1 -TaskList Set-Configuration,Test -properties @{\"Database\" = \"%DB%\";\"ConnectionString\"=\"%CONNECTION_STRING%\"}"
60+
deploy: off
61+
on_finish:
62+
- ps: |-
63+
$wc = New-Object 'System.Net.WebClient'
64+
Get-Item '*-TestResult.xml' | ForEach-Object {
65+
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", $_)
66+
}

build.ps1

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
param (
2+
$TaskList = 'Default',
3+
[hashtable]$Properties = @{}
4+
)
5+
6+
Install-Module psake -Force -Scope CurrentUser
7+
Import-Module psake
8+
Invoke-psake -buildFile .\psake.ps1 -nologo -taskList $TaskList -properties $Properties
9+
exit ( [int] ( -not $psake.build_success ) )

psake.ps1

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
properties {
2+
$Database = "SqlServer2012";
3+
$ConnectionString = $null;
4+
}
5+
6+
Task Default -depends Build, Test
7+
8+
Task Set-Configuration {
9+
$configDir = (Join-Path '.' 'current-test-configuration')
10+
#Configuration matrix
11+
$allSettings = @{
12+
'Firebird' = @{
13+
'connection.connection_string' = 'DataSource=localhost;Database=nhibernate;User ID=SYSDBA;Password=masterkey;MaxPoolSize=200;';
14+
'connection.driver_class' = 'NHibernate.Driver.FirebirdClientDriver';
15+
'dialect' = 'NHibernate.Dialect.FirebirdDialect'
16+
};
17+
'MySQL' = @{
18+
'connection.connection_string' = 'Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;';
19+
'connection.driver_class' = 'NHibernate.Driver.MySqlDataDriver';
20+
'dialect' = 'NHibernate.Dialect.MySQL5Dialect'
21+
};
22+
'Odbc' = @{
23+
# The OdbcDriver inherits SupportsMultipleOpenReaders=true from DriverBase, which requires Mars_Connection=yes for SQL Server.
24+
'connection.connection_string' = 'Server=(local)\SQL2017;Uid=sa;Pwd=Password12!;Database=nhibernateOdbc;Driver={SQL Server Native Client 11.0};Mars_Connection=yes;';
25+
'connection.driver_class' = 'NHibernate.Driver.OdbcDriver';
26+
'odbc.explicit_datetime_scale' = '3';
27+
<# We need to use a dialect that avoids mapping DbType.Time to TIME on MSSQL. On modern SQL Server
28+
this becomes TIME(7). Later, such values cannot be read back over ODBC. The
29+
error we get is "System.ArgumentException : Unknown SQL type - SS_TIME_EX.". I don't know for certain
30+
why this occurs, but MS docs do say that for a client "compiled using a version of SQL Server Native
31+
Client prior to SQL Server 2008", TIME(7) cannot be converted back to the client. Assuming that .Net's
32+
OdbcDriver would be considered a "client compiled with a previous version", it would make sense. Anyway,
33+
using the MsSql2005Dialect avoids these test failures. #>
34+
'dialect' = 'NHibernate.Dialect.MsSql2005Dialect'
35+
};
36+
'PostgreSQL' = @{
37+
'connection.connection_string' = 'Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true';
38+
'connection.driver_class' = 'NHibernate.Driver.NpgsqlDriver';
39+
'dialect' = 'NHibernate.Dialect.PostgreSQL83Dialect'
40+
};
41+
'SQLite' = @{
42+
<#
43+
DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
44+
which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
45+
See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
46+
and https://github.com/nhibernate/nhibernate-core/issues/1362 #>
47+
# Please note the connection string is formated for putting the db file in $configDir.
48+
'connection.connection_string' = "Data Source=$configDir/NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;";
49+
'connection.driver_class' = 'NHibernate.Driver.SQLite20Driver';
50+
'dialect' = 'NHibernate.Dialect.SQLiteDialect'
51+
};
52+
'SqlServerCe' = @{
53+
# Please note the connection string is formated for putting the db file in $configDir.
54+
'connection.connection_string' = "Data Source=$configDir/NHibernate.sdf;";
55+
'connection.driver_class' = 'NHibernate.Driver.SqlServerCeDriver';
56+
'command_timeout' = '0';
57+
'dialect' = 'NHibernate.Dialect.MsSqlCe40Dialect'
58+
};
59+
'SqlServer2008' = @{
60+
'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'
61+
};
62+
'SqlServer2012' = @{
63+
'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;';
64+
'dialect' = 'NHibernate.Dialect.MsSql2012Dialect'
65+
}
66+
}
67+
#Settings for current build
68+
$settings = $allSettings[$Database]
69+
70+
if (!$settings) {
71+
Write-Warning "Unable to find $Database settings"
72+
exit 1
73+
}
74+
if (-not [String]::IsNullOrWhitespace($ConnectionString)) {
75+
$settings['connection.connection_string'] = $ConnectionString
76+
}
77+
#Create settings file
78+
$configFile = (Join-Path $configDir 'hibernate.cfg.xml')
79+
New-Item $configDir -Type Directory
80+
Copy-Item "$([IO.Path]::Combine('.', 'build-common', 'teamcity-hibernate.cfg.xml'))" $configFile
81+
#Patch settings file
82+
$config = [Xml] (Get-Content $configFile)
83+
$allProps = $config.'hibernate-configuration'.'session-factory'.property
84+
foreach($key in $settings.keys)
85+
{
86+
$value = $settings[$key]
87+
$property = $allProps | Where-Object { $_.name -eq $key }
88+
if (!$property) {
89+
Write-Warning "Unable to find $key property"
90+
exit 1
91+
}
92+
$property.InnerText = $value
93+
}
94+
$config.Save($configFile)
95+
}
96+
97+
Task Build {
98+
Exec {
99+
dotnet `
100+
build ./src/NHibernate.sln `
101+
-f netcoreapp2.0 `
102+
-c Release
103+
}
104+
}
105+
106+
Task Test -depends Build {
107+
@(
108+
'NHibernate.TestDatabaseSetup',
109+
'NHibernate.Test',
110+
'NHibernate.Test.VisualBasic'
111+
) | ForEach-Object {
112+
$assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "netcoreapp2.0", "$_.dll")
113+
Exec {
114+
dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml"
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)