Skip to content

Commit 663588f

Browse files
authored
AppVeyor: Build tweaks & misc fixes (#1450)
Simplifying and improve build speed. - Decreases builds from 8-13 minutes down to ~2 minutes (while running more tests) - Moves to SQL Server 2019 on AppVeyor - Moves the 2 longest running tests with params to `[FactLongRunning]` - Bumps tests up to `netcoreapp3.1` - Also fixes .Contrib tests - Moves to `Build.csproj` - Simplifies `build.ps1` - Removed defunct `build.sh` - Nukes `IsAppveyor` (moves to environmental variable overloads) - Builds now work in Linux/macOS
1 parent 5c87dc9 commit 663588f

23 files changed

+104
-147
lines changed

Build.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project Sdk="Microsoft.Build.Traversal/2.0.24">
2+
<ItemGroup>
3+
<ProjectReference Include="*\*.csproj" />
4+
</ItemGroup>
5+
</Project>

Dapper.ProviderTools/BulkCopy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using Dapper.ProviderTools.Internal;
10-
#nullable enable
10+
1111
namespace Dapper.ProviderTools
1212
{
1313
/// <summary>

Dapper.ProviderTools/Dapper.ProviderTools.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
99
<SignAssembly>true</SignAssembly>
1010
<Nullable>enable</Nullable>
11-
<LangVersion>8.0</LangVersion>
1211
</PropertyGroup>
1312
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
1413
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

Dapper.ProviderTools/DbConnectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Data.Common;
44
using System.Linq.Expressions;
55
using System.Reflection;
6-
#nullable enable
6+
77
namespace Dapper.ProviderTools
88
{
99
/// <summary>

Dapper.ProviderTools/DbExceptionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Data.Common;
44
using System.Linq.Expressions;
55
using System.Reflection;
6-
#nullable enable
6+
77
namespace Dapper.ProviderTools
88
{
99
/// <summary>

Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<AssemblyName>Dapper.Tests.Contrib</AssemblyName>
44
<Description>Dapper Contrib Test Suite</Description>
55
<GenerateDocumentationFile>false</GenerateDocumentationFile>
6-
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>
6+
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
77
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
88
</PropertyGroup>
99
<ItemGroup>
10-
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" />
10+
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs" Link="Helpers\XunitSkippable.cs" />
1111
<None Remove="Test.DB.sdf" />
1212
</ItemGroup>
1313
<ItemGroup>
@@ -25,5 +25,4 @@
2525
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
2626
<Reference Include="Microsoft.CSharp" />
2727
</ItemGroup>
28-
<!-- note: define SQLCE if SQL CE is available -->
2928
</Project>
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using Xunit.Sdk;
3+
4+
namespace Dapper.Tests
5+
{
6+
/// <summary>
7+
/// <para>Override for <see cref="Xunit.FactAttribute"/> that truncates our DisplayName down.</para>
8+
/// <para>
9+
/// Attribute that is applied to a method to indicate that it is a fact that should
10+
/// be run by the test runner. It can also be extended to support a customized definition
11+
/// of a test method.
12+
/// </para>
13+
/// </summary>
14+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
15+
[XunitTestCaseDiscoverer("Dapper.Tests.FactDiscoverer", "Dapper.Tests.Contrib")]
16+
public class FactAttribute : Xunit.FactAttribute
17+
{
18+
}
19+
20+
/// <summary>
21+
/// <para>Override for <see cref="Xunit.TheoryAttribute"/> that truncates our DisplayName down.</para>
22+
/// <para>
23+
/// Marks a test method as being a data theory. Data theories are tests which are
24+
/// fed various bits of data from a data source, mapping to parameters on the test
25+
/// method. If the data source contains multiple rows, then the test method is executed
26+
/// multiple times (once with each data row). Data is provided by attributes which
27+
/// derive from Xunit.Sdk.DataAttribute (notably, Xunit.InlineDataAttribute and Xunit.MemberDataAttribute).
28+
/// </para>
29+
/// </summary>
30+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
31+
[XunitTestCaseDiscoverer("Dapper.Tests.TheoryDiscoverer", "Dapper.Tests.Contrib")]
32+
public class TheoryAttribute : Xunit.TheoryAttribute { }
33+
34+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
35+
public sealed class FactLongRunningAttribute : FactAttribute
36+
{
37+
public FactLongRunningAttribute()
38+
{
39+
#if !LONG_RUNNING
40+
Skip = "Long running";
41+
#endif
42+
}
43+
44+
public string Url { get; private set; }
45+
}
46+
}

Dapper.Tests.Contrib/TestSuite.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Data;
44
using System.Linq;
5-
using System.Transactions;
65
using Dapper.Contrib.Extensions;
76
using Xunit;
87

@@ -104,10 +103,11 @@ public class GenericType<T>
104103

105104
public abstract partial class TestSuite
106105
{
107-
protected static readonly bool IsAppVeyor = Environment.GetEnvironmentVariable("Appveyor")?.ToUpperInvariant() == "TRUE";
108-
109106
public abstract IDbConnection GetConnection();
110107

108+
protected static string GetConnectionString(string name, string defaultConnectionString) =>
109+
Environment.GetEnvironmentVariable(name) ?? defaultConnectionString;
110+
111111
private IDbConnection GetOpenConnection()
112112
{
113113
var connection = GetConnection();

Dapper.Tests.Contrib/TestSuites.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ public class SqlServerTestSuite : TestSuite
2323
{
2424
private const string DbName = "tempdb";
2525
public static string ConnectionString =>
26-
IsAppVeyor
27-
? @"Server=(local)\SQL2016;Database=tempdb;User ID=sa;Password=Password12!"
28-
: $"Data Source=.;Initial Catalog={DbName};Integrated Security=True";
26+
GetConnectionString("SqlServerConnectionString", $"Data Source=.;Initial Catalog={DbName};Integrated Security=True");
27+
2928
public override IDbConnection GetConnection() => new SqlConnection(ConnectionString);
3029

3130
static SqlServerTestSuite()
@@ -62,9 +61,7 @@ static SqlServerTestSuite()
6261
public class MySqlServerTestSuite : TestSuite
6362
{
6463
public static string ConnectionString { get; } =
65-
IsAppVeyor
66-
? "Server=localhost;Database=test;Uid=root;Pwd=Password12!;UseAffectedRows=false;"
67-
: "Server=localhost;Database=tests;Uid=test;Pwd=pass;UseAffectedRows=false;";
64+
GetConnectionString("MySqlConnectionString", "Server=localhost;Database=tests;Uid=test;Pwd=pass;UseAffectedRows=false;");
6865

6966
public override IDbConnection GetConnection()
7067
{

Dapper.Tests.Performance/Dapper.Tests.Performance.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<Description>Dapper Core Performance Suite</Description>
66
<OutputType>Exe</OutputType>
77
<GenerateDocumentationFile>false</GenerateDocumentationFile>
8-
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
8+
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
9+
<IsPackable>false</IsPackable>
910
</PropertyGroup>
1011
<ItemGroup>
1112
<ProjectReference Include="..\Dapper\Dapper.csproj" />

Dapper.Tests/Dapper.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyName>Dapper.Tests</AssemblyName>
44
<Description>Dapper Core Test Suite</Description>
55
<GenerateDocumentationFile>false</GenerateDocumentationFile>
6-
<TargetFrameworks>netcoreapp2.1;net462;net472</TargetFrameworks>
6+
<TargetFrameworks>netcoreapp3.1;net462;net472</TargetFrameworks>
77
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
88
<DefineConstants>$(DefineConstants);MSSQLCLIENT</DefineConstants>
99
</PropertyGroup>
@@ -13,10 +13,10 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" />
1716
<ProjectReference Include="..\Dapper\Dapper.csproj" />
1817
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
1918
<ProjectReference Include="..\Dapper.ProviderTools\Dapper.ProviderTools.csproj" />
19+
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" />
2020
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.0.0" />
2121
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.1" />
2222
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />

Dapper.Tests/ParameterTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1442,10 +1442,10 @@ public void Issue601_InternationalParameterNamesWork()
14421442
Assert.Equal(42, result);
14431443
}
14441444

1445-
[Fact]
1445+
[FactLongRunning]
14461446
public void TestListExpansionPadding_Enabled() => TestListExpansionPadding(true);
14471447

1448-
[Fact]
1448+
[FactLongRunning]
14491449
public void TestListExpansionPadding_Disabled() => TestListExpansionPadding(false);
14501450

14511451
private void TestListExpansionPadding(bool enabled)

Dapper.Tests/Providers/MySQLTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ namespace Dapper.Tests
1010
public sealed class MySqlProvider : DatabaseProvider
1111
{
1212
public override DbProviderFactory Factory => MySql.Data.MySqlClient.MySqlClientFactory.Instance;
13-
public override string GetConnectionString() => IsAppVeyor
14-
? "Server=localhost;Database=test;Uid=root;Pwd=Password12!;"
15-
: "Server=localhost;Database=tests;Uid=test;Pwd=pass;";
13+
public override string GetConnectionString() =>
14+
GetConnectionString("MySqlConnectionString", "Server=localhost;Database=tests;Uid=test;Pwd=pass;");
1615

1716
public DbConnection GetMySqlConnection(bool open = true,
1817
bool convertZeroDatetime = false, bool allowZeroDatetime = false)

Dapper.Tests/Providers/OLDEBTests.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ public class OLEDBProvider : DatabaseProvider
1111
{
1212
public override DbProviderFactory Factory => OleDbFactory.Instance;
1313
public override string GetConnectionString() =>
14-
IsAppVeyor
15-
? @"Provider=SQLOLEDB;Data Source=(local)\SQL2016;Initial Catalog=tempdb;User Id=sa;Password=Password12!"
16-
: "Provider=SQLOLEDB;Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI";
14+
GetConnectionString("OLEDBConnectionString", "Provider=SQLOLEDB;Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI");
1715
}
1816

1917
public class OLDEBTests : TestBase<OLEDBProvider>

Dapper.Tests/Providers/PostgresqlTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ namespace Dapper.Tests
99
public class PostgresProvider : DatabaseProvider
1010
{
1111
public override DbProviderFactory Factory => Npgsql.NpgsqlFactory.Instance;
12-
public override string GetConnectionString() => IsAppVeyor
13-
? "Server=localhost;Port=5432;User Id=postgres;Password=Password12!;Database=test"
14-
: "Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest"; // ;Encoding = UNICODE
12+
public override string GetConnectionString() =>
13+
GetConnectionString("PostgesConnectionString", "Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest");
1514
}
1615
public class PostgresqlTests : TestBase<PostgresProvider>
1716
{

Dapper.Tests/TestBase.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ public abstract class DatabaseProvider
1515
{
1616
public abstract DbProviderFactory Factory { get; }
1717

18-
public static bool IsAppVeyor { get; } = Environment.GetEnvironmentVariable("Appveyor")?.ToUpperInvariant() == "TRUE";
1918
public virtual void Dispose() { }
2019
public abstract string GetConnectionString();
2120

21+
protected string GetConnectionString(string name, string defaultConnectionString) =>
22+
Environment.GetEnvironmentVariable(name) ?? defaultConnectionString;
23+
2224
public DbConnection GetOpenConnection()
2325
{
2426
var conn = Factory.CreateConnection();
@@ -47,10 +49,8 @@ public DbParameter CreateRawParameter(string name, object value)
4749

4850
public abstract class SqlServerDatabaseProvider : DatabaseProvider
4951
{
50-
public override string GetConnectionString() =>
51-
IsAppVeyor
52-
? @"Server=(local)\SQL2016;Database=tempdb;User ID=sa;Password=Password12!"
53-
: "Data Source=.;Initial Catalog=tempdb;Integrated Security=True";
52+
public override string GetConnectionString() =>
53+
GetConnectionString("SqlServerConnectionString", "Data Source=.;Initial Catalog=tempdb;Integrated Security=True");
5454

5555
public DbConnection GetOpenConnection(bool mars)
5656
{

Directory.Build.props

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<IncludeSymbols>false</IncludeSymbols>
2121

2222
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23+
24+
<LangVersion>8.0</LangVersion>
2325
</PropertyGroup>
2426

2527
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
@@ -32,7 +34,8 @@
3234
</ItemGroup>
3335

3436
<ItemGroup>
35-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
37+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
3638
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
39+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
3740
</ItemGroup>
3841
</Project>

Readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ Performance
114114

115115
A key feature of Dapper is performance. The following metrics show how long it takes to execute a `SELECT` statement against a DB (in various config, each labeled) and map the data returned to objects.
116116

117-
The benchmarks can be found in [Dapper.Tests.Performance](https://github.com/StackExchange/Dapper/tree/master/Dapper.Tests.Performance) (contributions welcome!) and can be run once compiled via:
118-
```
119-
Dapper.Tests.Performance.exe -f * --join
117+
The benchmarks can be found in [Dapper.Tests.Performance](https://github.com/StackExchange/Dapper/tree/master/Dapper.Tests.Performance) (contributions welcome!) and can be run via:
118+
```bash
119+
dotnet run -p .\Dapper.Tests.Performance\ -c Release -f netcoreapp3.1 -- -f * --join
120120
```
121121
Output from the latest run is:
122122
``` ini

appveyor.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
image: Visual Studio 2017
1+
image: Visual Studio 2019
22

33
skip_branch_with_pr: true
44
skip_tags: true
55
skip_commits:
66
files:
77
- '**/*.md'
88

9-
install:
10-
- choco install dotnetcore-sdk --version 3.0.100
11-
129
environment:
1310
Appveyor: true
1411
# Postgres
@@ -24,14 +21,20 @@ environment:
2421
MYSQL_ENV_MYSQL_USER: root
2522
MYSQL_ENV_MYSQL_PASSWORD: Password12!
2623
MYSQL_ENV_MYSQL_DATABASE: test
24+
# Connection strings for tests:
25+
MySqlConnectionString: Server=localhost;Database=test;Uid=root;Pwd=Password12!
26+
OLEDBConnectionString: Provider=SQLOLEDB;Data Source=(local)\SQL2019;Initial Catalog=tempdb;User Id=sa;Password=Password12!
27+
PostgesConnectionString: Server=localhost;Port=5432;User Id=postgres;Password=Password12!;Database=test
28+
SqlServerConnectionString: Server=(local)\SQL2019;Database=tempdb;User ID=sa;Password=Password12!
29+
2730
services:
28-
- mssql2016
2931
- mysql
3032
- postgresql
3133

3234
init:
3335
- git config --global core.autocrlf input
3436
- SET PATH=%POSTGRES_PATH%\bin;%MYSQL_PATH%\bin;%PATH%
37+
- net start MSSQL$SQL2019
3538

3639
nuget:
3740
disable_publish_on_pr: true

0 commit comments

Comments
 (0)