Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Build/Nuke/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.AppVeyor;
using Nuke.Common.CI.AzurePipelines;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
Expand All @@ -13,7 +12,6 @@
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.Xunit;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand Down Expand Up @@ -61,6 +59,7 @@ partial class Build : Nuke.Common.NukeBuild
[GitVersion] readonly GitVersion GitVersion;

[CI] readonly AzurePipelines AzurePipelines;

[Parameter("GitHub Token")] readonly string GitHubToken;

AbsolutePath SourceDirectory => RootDirectory / "src";
Expand Down Expand Up @@ -124,21 +123,31 @@ from platform in project.GetPlatforms()
}
}

[Partition(4)] readonly Partition TestPartition;

Target Test => _ => _
.DependsOn(Compile)
.Produces(TestResultDirectory / "*.trx")
.Partition(() => TestPartition)
.Executes(() => ExecutesTest(false));

void ExecutesTest(bool excludeNetFramework)
{
Logger.Info(excludeNetFramework ? "Exclude net framework" : "Include net framework");

var testConfigurations =
var groupTestConfigurations =
(from project in TestProjects
from framework in project.GetTargetFrameworks(excludeNetFramework)
from platform in project.GetPlatformsForTests()
select (project, framework, platform))
.Filter(IsLocalBuild);
.Filter(IsLocalBuild, AzurePipelines)
.Group()
.ToList();

var testConfigurations =
TestPartition
.GetCurrent(groupTestConfigurations)
.SelectMany(x=>x);

DotNetTest(_ =>
{
Expand Down
24 changes: 22 additions & 2 deletions Build/Nuke/ProjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Nuke.Common.CI.AzurePipelines;
using Nuke.Common.ProjectModel;

public static class ProjectExtensions
Expand Down Expand Up @@ -37,13 +38,19 @@ public static IReadOnlyCollection<string> GetPlatformsForTests(this Project proj
return platforms.Where(x=> x != "x86").ToList();
}

public static IEnumerable<(Project project, string framework, string platform)> Filter(this IEnumerable<(Project project, string framework, string platform)> list, bool isLocal)
public static IEnumerable<(Project project, string framework, string platform)> Filter(
this IEnumerable<(Project project, string framework, string platform)> list, bool isLocal,
AzurePipelines azurePipelines)
{
if (isLocal)
return list;
//exclude netcore 2.1 and 2.2 in x86 because is not well handle by azure pipelines and github actions on windows
return list.Where(x =>
{
// exclude netcore 2.2 for azure pipelines
if (azurePipelines != null && x.framework.Contains("2.2"))
return false;

//exclude netcore 2.1 and 2.2 in x86 because is not well handle by azure pipelines and github actions on windows
if (x.platform != "x86")
return true;
if (x.framework == null)
Expand All @@ -56,4 +63,17 @@ public static IReadOnlyCollection<string> GetPlatformsForTests(this Project proj
});
}


public static IEnumerable<IEnumerable<(Project project, string framework, string platform)>> Group(
this IEnumerable<(Project project, string framework, string platform)> list)
{
var toList = list.ToList();
foreach (var element in toList.Where(x=> x.project.Name.Contains("StructLinq.Tests")))
{
yield return new[] {element};
}

yield return toList.Where(x => !x.project.Name.Contains("StructLinq.Tests"));
}

}
6 changes: 4 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ stages:
inputs:
script: './build.cmd Restore Compile --skip'
- job: Test
displayName: '🚦 Test'
displayName: '🚦 Test 🧩'
dependsOn: [ Compile ]
strategy:
parallel: 4
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Test --skip'
script: './build.cmd Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: test-results
Expand Down