Skip to content

Commit

Permalink
Add CI verification step
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Jan 7, 2022
1 parent 50838e3 commit c5fdb5d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.AspNet.Sqlite.Functi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.AspNet.InMemory.FunctionalTests", "test\EFCore.AspNet.InMemory.FunctionalTests\EFCore.AspNet.InMemory.FunctionalTests.csproj", "{F1B2E5A0-8C74-414A-B262-353FEE325E9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.Trimming.Test", "test\EFCore.Trimming.Test\EFCore.Trimming.Test.csproj", "{933C8662-817C-4F45-B98B-6557E28F7BB1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.Trimming.Tests", "test\EFCore.Trimming.Tests\EFCore.Trimming.Tests.csproj", "{933C8662-817C-4F45-B98B-6557E28F7BB1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup Condition="'$(IsUnitTestProject)' == ''">
<IsUnitTestProject Condition="$(MSBuildProjectName.EndsWith('.FunctionalTests'))">True</IsUnitTestProject>
<IsUnitTestProject Condition="$(MSBuildProjectName.EndsWith('.Specification.Tests'))">False</IsUnitTestProject>
<IsUnitTestProject Condition="$(MSBuildProjectName.EndsWith('.Trimming.Tests'))">False</IsUnitTestProject>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
Expand Down
6 changes: 6 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
variables:
- name: _BuildConfig
value: Release
- name: _BuildTargetFramework
value: net6.0
- name: _TeamName
value: AspNetCore
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
Expand Down Expand Up @@ -100,6 +102,10 @@ stages:
env:
Test__Cosmos__DefaultConnection: $(_CosmosConnectionUrl)
name: Build
- script: |
.dotnet\dotnet publish --configuration $(_BuildConfig) --runtime win-x64 --self-contained test\EFCore.Trimming.Tests
artifacts\bin\EFCore.Trimming.Tests\$(_BuildConfig)\$(_BuildTargetFramework)\win-x64\publish\EFCore.Trimming.Tests.exe
displayName: Test trimming
- task: PublishBuildArtifacts@1
displayName: Upload TestResults
condition: always()
Expand Down
5 changes: 5 additions & 0 deletions eng/helix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<XUnitProject Remove="$(SqlServerTests)"/>
</ItemGroup>

<!-- The trimming test project is a console program -->
<ItemGroup>
<XUnitProject Remove="$(RepoRoot)/test/EFCore.Trimming.Tests/*.csproj"/>
</ItemGroup>

<PropertyGroup>
<XUnitPublishTargetFramework>net6.0</XUnitPublishTargetFramework>
<XUnitRuntimeTargetFramework>netcoreapp2.0</XUnitRuntimeTargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using EFCore.Trimming.Tests;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.TestUtilities;

await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
Expand All @@ -12,12 +14,26 @@
// Execute any query to make sure the basic query pipeline works
_ = ctx.Blogs.Where(b => b.Name.StartsWith("foo")).ToList();

Console.WriteLine("Database query executed successfully.");

public class BlogContext : DbContext
{
private static readonly string ConnectionString;

public DbSet<Blog> Blogs { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer(TestEnvironment.DefaultConnection);
=> optionsBuilder.UseSqlServer(ConnectionString);

static BlogContext()
{
var builder = new SqlConnectionStringBuilder(TestEnvironment.DefaultConnection)
{
InitialCatalog = "TrimmingTests"
};

ConnectionString = builder.ToString();
}
}

public class Blog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;

namespace Microsoft.EntityFrameworkCore.TestUtilities;
namespace EFCore.Trimming.Tests;

public static class TestEnvironment
{
Expand Down

0 comments on commit c5fdb5d

Please sign in to comment.