Skip to content

Commit d162f28

Browse files
committed
Add Travis-CI build
1 parent 51a4ba2 commit d162f28

File tree

3 files changed

+149
-0
lines changed

3 files changed

+149
-0
lines changed

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: csharp
2+
mono: none
3+
dotnet: 2.1.2
4+
sudo: required
5+
services:
6+
- mysql
7+
- postgresql
8+
- docker
9+
env:
10+
- DB=SqlServer2008 CONNECTION_STRING="Server=localhost;Database=nhibernate;User Id=sa;Password=P@ssw0rd;"
11+
- DB=MySQL CONNECTION_STRING="Server=127.0.0.1;Uid=root;Database=nhibernate;Old Guids=True;"
12+
- DB=PostgreSQL CONNECTION_STRING="Host=localhost;Port=5432;Username=postgres;Database=nhibernate;Enlist=true;"
13+
before_install:
14+
- curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
15+
- curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
16+
- sudo apt-get update -qq
17+
- sudo apt-get install -y powershell
18+
before_script:
19+
- sh -c "if [ '$DB' = 'PostgreSQL' ]; then psql -c 'CREATE DATABASE nhibernate;' -U postgres; fi"
20+
- sh -c "if [ '$DB' = 'MySQL' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS nhibernate;'; fi"
21+
- sh -c "if [ '$DB' = 'SqlServer2008' ]; then docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssw0rd' -e 'MSSQL_PID=Express' -p 1433:1433 -d --name sqlexpress microsoft/mssql-server-linux:latest; fi"
22+
script:
23+
- pwsh -noprofile -command "& ./build.ps1 -TaskList Set-Configuration,Test -properties @{\"Database\" = \"$DB\";\"ConnectionString\"=\"$CONNECTION_STRING\"}"

build.ps1

Lines changed: 9 additions & 0 deletions
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

Lines changed: 117 additions & 0 deletions
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 ($ConnectionString -ne $null) {
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
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)