Skip to content

Commit

Permalink
AppVeyor: Build tweaks & misc fixes (#1450)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickCraver committed May 2, 2020
1 parent 5c87dc9 commit 663588f
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 147 deletions.
5 changes: 5 additions & 0 deletions Build.csproj
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.Build.Traversal/2.0.24">
<ItemGroup>
<ProjectReference Include="*\*.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Dapper.ProviderTools/BulkCopy.cs
Expand Up @@ -7,7 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Dapper.ProviderTools.Internal;
#nullable enable

namespace Dapper.ProviderTools
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion Dapper.ProviderTools/Dapper.ProviderTools.csproj
Expand Up @@ -8,7 +8,6 @@
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion Dapper.ProviderTools/DbConnectionExtensions.cs
Expand Up @@ -3,7 +3,7 @@
using System.Data.Common;
using System.Linq.Expressions;
using System.Reflection;
#nullable enable

namespace Dapper.ProviderTools
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Dapper.ProviderTools/DbExceptionExtensions.cs
Expand Up @@ -3,7 +3,7 @@
using System.Data.Common;
using System.Linq.Expressions;
using System.Reflection;
#nullable enable

namespace Dapper.ProviderTools
{
/// <summary>
Expand Down
5 changes: 2 additions & 3 deletions Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj
Expand Up @@ -3,11 +3,11 @@
<AssemblyName>Dapper.Tests.Contrib</AssemblyName>
<Description>Dapper Contrib Test Suite</Description>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" />
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs" Link="Helpers\XunitSkippable.cs" />
<None Remove="Test.DB.sdf" />
</ItemGroup>
<ItemGroup>
Expand All @@ -25,5 +25,4 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<!-- note: define SQLCE if SQL CE is available -->
</Project>
46 changes: 46 additions & 0 deletions Dapper.Tests.Contrib/Helpers/Attributes.cs
@@ -0,0 +1,46 @@
using System;
using Xunit.Sdk;

namespace Dapper.Tests
{
/// <summary>
/// <para>Override for <see cref="Xunit.FactAttribute"/> that truncates our DisplayName down.</para>
/// <para>
/// Attribute that is applied to a method to indicate that it is a fact that should
/// be run by the test runner. It can also be extended to support a customized definition
/// of a test method.
/// </para>
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("Dapper.Tests.FactDiscoverer", "Dapper.Tests.Contrib")]
public class FactAttribute : Xunit.FactAttribute
{
}

/// <summary>
/// <para>Override for <see cref="Xunit.TheoryAttribute"/> that truncates our DisplayName down.</para>
/// <para>
/// Marks a test method as being a data theory. Data theories are tests which are
/// fed various bits of data from a data source, mapping to parameters on the test
/// method. If the data source contains multiple rows, then the test method is executed
/// multiple times (once with each data row). Data is provided by attributes which
/// derive from Xunit.Sdk.DataAttribute (notably, Xunit.InlineDataAttribute and Xunit.MemberDataAttribute).
/// </para>
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("Dapper.Tests.TheoryDiscoverer", "Dapper.Tests.Contrib")]
public class TheoryAttribute : Xunit.TheoryAttribute { }

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class FactLongRunningAttribute : FactAttribute
{
public FactLongRunningAttribute()
{
#if !LONG_RUNNING
Skip = "Long running";
#endif
}

public string Url { get; private set; }
}
}
6 changes: 3 additions & 3 deletions Dapper.Tests.Contrib/TestSuite.cs
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Transactions;
using Dapper.Contrib.Extensions;
using Xunit;

Expand Down Expand Up @@ -104,10 +103,11 @@ public class GenericType<T>

public abstract partial class TestSuite
{
protected static readonly bool IsAppVeyor = Environment.GetEnvironmentVariable("Appveyor")?.ToUpperInvariant() == "TRUE";

public abstract IDbConnection GetConnection();

protected static string GetConnectionString(string name, string defaultConnectionString) =>
Environment.GetEnvironmentVariable(name) ?? defaultConnectionString;

private IDbConnection GetOpenConnection()
{
var connection = GetConnection();
Expand Down
9 changes: 3 additions & 6 deletions Dapper.Tests.Contrib/TestSuites.cs
Expand Up @@ -23,9 +23,8 @@ public class SqlServerTestSuite : TestSuite
{
private const string DbName = "tempdb";
public static string ConnectionString =>
IsAppVeyor
? @"Server=(local)\SQL2016;Database=tempdb;User ID=sa;Password=Password12!"
: $"Data Source=.;Initial Catalog={DbName};Integrated Security=True";
GetConnectionString("SqlServerConnectionString", $"Data Source=.;Initial Catalog={DbName};Integrated Security=True");

public override IDbConnection GetConnection() => new SqlConnection(ConnectionString);

static SqlServerTestSuite()
Expand Down Expand Up @@ -62,9 +61,7 @@ static SqlServerTestSuite()
public class MySqlServerTestSuite : TestSuite
{
public static string ConnectionString { get; } =
IsAppVeyor
? "Server=localhost;Database=test;Uid=root;Pwd=Password12!;UseAffectedRows=false;"
: "Server=localhost;Database=tests;Uid=test;Pwd=pass;UseAffectedRows=false;";
GetConnectionString("MySqlConnectionString", "Server=localhost;Database=tests;Uid=test;Pwd=pass;UseAffectedRows=false;");

public override IDbConnection GetConnection()
{
Expand Down
3 changes: 2 additions & 1 deletion Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
Expand Up @@ -5,7 +5,8 @@
<Description>Dapper Core Performance Suite</Description>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions Dapper.Tests/Dapper.Tests.csproj
Expand Up @@ -3,7 +3,7 @@
<AssemblyName>Dapper.Tests</AssemblyName>
<Description>Dapper Core Test Suite</Description>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>netcoreapp2.1;net462;net472</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net462;net472</TargetFrameworks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DefineConstants>$(DefineConstants);MSSQLCLIENT</DefineConstants>
</PropertyGroup>
Expand All @@ -13,10 +13,10 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" />
<ProjectReference Include="..\Dapper\Dapper.csproj" />
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
<ProjectReference Include="..\Dapper.ProviderTools\Dapper.ProviderTools.csproj" />
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
Expand Down
4 changes: 2 additions & 2 deletions Dapper.Tests/ParameterTests.cs
Expand Up @@ -1442,10 +1442,10 @@ public void Issue601_InternationalParameterNamesWork()
Assert.Equal(42, result);
}

[Fact]
[FactLongRunning]
public void TestListExpansionPadding_Enabled() => TestListExpansionPadding(true);

[Fact]
[FactLongRunning]
public void TestListExpansionPadding_Disabled() => TestListExpansionPadding(false);

private void TestListExpansionPadding(bool enabled)
Expand Down
5 changes: 2 additions & 3 deletions Dapper.Tests/Providers/MySQLTests.cs
Expand Up @@ -10,9 +10,8 @@ namespace Dapper.Tests
public sealed class MySqlProvider : DatabaseProvider
{
public override DbProviderFactory Factory => MySql.Data.MySqlClient.MySqlClientFactory.Instance;
public override string GetConnectionString() => IsAppVeyor
? "Server=localhost;Database=test;Uid=root;Pwd=Password12!;"
: "Server=localhost;Database=tests;Uid=test;Pwd=pass;";
public override string GetConnectionString() =>
GetConnectionString("MySqlConnectionString", "Server=localhost;Database=tests;Uid=test;Pwd=pass;");

public DbConnection GetMySqlConnection(bool open = true,
bool convertZeroDatetime = false, bool allowZeroDatetime = false)
Expand Down
4 changes: 1 addition & 3 deletions Dapper.Tests/Providers/OLDEBTests.cs
Expand Up @@ -11,9 +11,7 @@ public class OLEDBProvider : DatabaseProvider
{
public override DbProviderFactory Factory => OleDbFactory.Instance;
public override string GetConnectionString() =>
IsAppVeyor
? @"Provider=SQLOLEDB;Data Source=(local)\SQL2016;Initial Catalog=tempdb;User Id=sa;Password=Password12!"
: "Provider=SQLOLEDB;Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI";
GetConnectionString("OLEDBConnectionString", "Provider=SQLOLEDB;Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI");
}

public class OLDEBTests : TestBase<OLEDBProvider>
Expand Down
5 changes: 2 additions & 3 deletions Dapper.Tests/Providers/PostgresqlTests.cs
Expand Up @@ -9,9 +9,8 @@ namespace Dapper.Tests
public class PostgresProvider : DatabaseProvider
{
public override DbProviderFactory Factory => Npgsql.NpgsqlFactory.Instance;
public override string GetConnectionString() => IsAppVeyor
? "Server=localhost;Port=5432;User Id=postgres;Password=Password12!;Database=test"
: "Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest"; // ;Encoding = UNICODE
public override string GetConnectionString() =>
GetConnectionString("PostgesConnectionString", "Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest");
}
public class PostgresqlTests : TestBase<PostgresProvider>
{
Expand Down
10 changes: 5 additions & 5 deletions Dapper.Tests/TestBase.cs
Expand Up @@ -15,10 +15,12 @@ public abstract class DatabaseProvider
{
public abstract DbProviderFactory Factory { get; }

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

protected string GetConnectionString(string name, string defaultConnectionString) =>
Environment.GetEnvironmentVariable(name) ?? defaultConnectionString;

public DbConnection GetOpenConnection()
{
var conn = Factory.CreateConnection();
Expand Down Expand Up @@ -47,10 +49,8 @@ public DbParameter CreateRawParameter(string name, object value)

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

public DbConnection GetOpenConnection(bool mars)
{
Expand Down
5 changes: 4 additions & 1 deletion Directory.Build.props
Expand Up @@ -20,6 +20,8 @@
<IncludeSymbols>false</IncludeSymbols>

<PublishRepositoryUrl>true</PublishRepositoryUrl>

<LangVersion>8.0</LangVersion>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Readme.md
Expand Up @@ -114,9 +114,9 @@ Performance

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.

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:
```
Dapper.Tests.Performance.exe -f * --join
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:
```bash
dotnet run -p .\Dapper.Tests.Performance\ -c Release -f netcoreapp3.1 -- -f * --join
```
Output from the latest run is:
``` ini
Expand Down
13 changes: 8 additions & 5 deletions appveyor.yml
@@ -1,14 +1,11 @@
image: Visual Studio 2017
image: Visual Studio 2019

skip_branch_with_pr: true
skip_tags: true
skip_commits:
files:
- '**/*.md'

install:
- choco install dotnetcore-sdk --version 3.0.100

environment:
Appveyor: true
# Postgres
Expand All @@ -24,14 +21,20 @@ environment:
MYSQL_ENV_MYSQL_USER: root
MYSQL_ENV_MYSQL_PASSWORD: Password12!
MYSQL_ENV_MYSQL_DATABASE: test
# Connection strings for tests:
MySqlConnectionString: Server=localhost;Database=test;Uid=root;Pwd=Password12!
OLEDBConnectionString: Provider=SQLOLEDB;Data Source=(local)\SQL2019;Initial Catalog=tempdb;User Id=sa;Password=Password12!
PostgesConnectionString: Server=localhost;Port=5432;User Id=postgres;Password=Password12!;Database=test
SqlServerConnectionString: Server=(local)\SQL2019;Database=tempdb;User ID=sa;Password=Password12!

services:
- mssql2016
- mysql
- postgresql

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

nuget:
disable_publish_on_pr: true
Expand Down

0 comments on commit 663588f

Please sign in to comment.