Skip to content

Commit

Permalink
Fixed filter issues and added more filter tests. (#1170)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Oct 28, 2019
1 parent aeabc3b commit 6cf4e40
Show file tree
Hide file tree
Showing 36 changed files with 770 additions and 379 deletions.
308 changes: 15 additions & 293 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ Task("EnvironmentSetup")
{
if(string.IsNullOrEmpty(packageVersion))
{
packageVersion = EnvironmentVariable("CIRCLE_TAG")
?? EnvironmentVariable("APPVEYOR_REPO_TAG_NAME")
?? EnvironmentVariable("Version");
packageVersion = EnvironmentVariable("Version");
}
Environment.SetEnvironmentVariable("Version", packageVersion);

if(string.IsNullOrEmpty(sonarPrKey))
{
sonarPrKey = EnvironmentVariable("APPVEYOR_PULL_REQUEST_NUMBER");
sonarBranch = EnvironmentVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH");
sonarBranchBase = EnvironmentVariable("APPVEYOR_REPO_BRANCH");
sonarPrKey = EnvironmentVariable("PR_NUMBER");
sonarBranch = EnvironmentVariable("PR_SOURCE_BRANCH");
sonarBranchBase = EnvironmentVariable("PR_TARGET_BRANCH");
sonarBranchBase = "master";
System.Console.WriteLine("PrKey" + sonarPrKey);
}

if(string.IsNullOrEmpty(sonarLogin))
Expand All @@ -47,44 +46,9 @@ Task("EnvironmentSetup")
}
});

Task("Clean")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
DotNetCoreClean("./src/DataLoader");
DotNetCoreClean("./src/Core");
DotNetCoreClean("./src/Server");
});

Task("Restore")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
DotNetCoreRestore("./tools/Build.sln");
});

Task("RestoreCore")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
DotNetCoreRestore("./tools/Build.Core.sln");
});

Task("Build")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
};

DotNetCoreBuild("./tools/Build.sln", settings);
});

Task("BuildDebug")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var buildSettings = new DotNetCoreBuildSettings
{
Expand All @@ -94,57 +58,6 @@ Task("BuildDebug")
DotNetCoreBuild("./tools/Build.sln", buildSettings);
});

Task("BuildCore")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
};

DotNetCoreBuild("./tools/Build.Core.sln", settings);
});

Task("Publish")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
using(var process = StartAndReturnProcess("msbuild",
new ProcessSettings{ Arguments = "./tools/Build.sln /t:restore /p:configuration=" + configuration }))
{
process.WaitForExit();
}

using(var process = StartAndReturnProcess("msbuild",
new ProcessSettings{ Arguments = "./tools/Build.sln /t:build /p:configuration=" + configuration }))
{
process.WaitForExit();
}

using(var process = StartAndReturnProcess("msbuild",
new ProcessSettings{ Arguments = "./tools/Build.sln /t:pack /p:configuration=" + configuration + " /p:IncludeSource=true /p:IncludeSymbols=true" }))
{
process.WaitForExit();
}
});

Task("PublishTemplates")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings
{
Version = packageVersion,
OutputDirectory = "src/Templates"
};

ReplaceTextInFiles("src/Templates/StarWars/content/StarWars/StarWars.csproj", "10.0.1", packageVersion);
ReplaceTextInFiles("src/Templates/Server/content/HotChocolate.Server.Template.csproj", "10.0.1", packageVersion);
NuGetPack("src/Templates/StarWars/HotChocolate.Templates.StarWars.nuspec", nuGetPackSettings);
NuGetPack("src/Templates/Server/HotChocolate.Templates.Server.nuspec", nuGetPackSettings);
});

Task("Tests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
Expand All @@ -169,31 +82,18 @@ Task("Tests")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/full_{i++}\" --blame")
};

DotNetCoreBuild("./tools/Build.sln", buildSettings);
DotNetCoreBuild("./tools/Build.Core.sln", buildSettings);

foreach(var file in GetFiles("./src/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
if(!file.FullPath.Contains("Classic") && !file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("TemplatesCompile")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var buildSettings = new DotNetCoreBuildSettings
{
Configuration = "Debug"
};

DotNetCoreBuild("./src/Templates/Server/content", buildSettings);
DotNetCoreBuild("./src/Templates/StarWars/content", buildSettings);
});

Task("CoreTests")
Task("AllTests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
Expand All @@ -214,183 +114,14 @@ Task("CoreTests")
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/core_{i++}\" --blame")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/full_{i++}\" --blame")
};

DotNetCoreBuild("./tools/Build.Core.sln", buildSettings);

foreach(var file in GetFiles("./src/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("RedisTests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/core_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/**/*.Tests.csproj"))
{
if(file.FullPath.Contains("Redis"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("MongoTests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/core_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/**/*.Tests.csproj"))
{
if(file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("HC_DataLoader_Tests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/hc_dataloader_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/DataLoader/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});


Task("HC_Core_Tests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/hc_core_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/Core/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("HC_Server_Tests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/hc_server_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/Server/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
}
});

Task("HC_Stitching_Tests")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
int i = 0;
var testSettings = new DotNetCoreTestSettings
{
Configuration = "Debug",
ResultsDirectory = $"./{testOutputDir}",
Logger = "trx",
NoRestore = false,
NoBuild = false,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:Exclude=[xunit.*]*")
.Append("/p:CoverletOutputFormat=opencover")
.Append($"/p:CoverletOutput=\"../../{testOutputDir}/hc_stitching_{i++}\" --blame")
};

foreach(var file in GetFiles("./src/Stitching/**/*.Tests.csproj"))
{
if(!file.FullPath.Contains("Redis") && !file.FullPath.Contains("Mongo"))
if(!file.FullPath.Contains("Classic"))
{
DotNetCoreTest(file.FullPath, testSettings);
}
Expand All @@ -403,6 +134,7 @@ Task("SonarBegin")
{
SonarBegin(new SonarBeginSettings
{
UseCoreClr = true,
Url = "https://sonarcloud.io",
Login = sonarLogin,
Key = "HotChocolate",
Expand All @@ -420,7 +152,6 @@ Task("SonarBegin")
a = a.Append($"/d:sonar.pullrequest.base=\"{sonarBranchBase}\"");
a = a.Append($"/d:sonar.pullrequest.provider=\"github\"");
a = a.Append($"/d:sonar.pullrequest.github.repository=\"ChilliCream/hotchocolate\"");
// a = a.Append($"/d:sonar.pullrequest.github.endpoint=\"https://api.github.com/\"");
}
return a;
}
Expand All @@ -432,31 +163,22 @@ Task("SonarEnd")
{
SonarEnd(new SonarEndSettings
{
Login = sonarLogin,
UseCoreClr = true,
Login = sonarLogin
});
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Tests");
.IsDependentOn("Sonar");

Task("Sonar")
.IsDependentOn("SonarBegin")
.IsDependentOn("Tests")
.IsDependentOn("SonarEnd");

Task("SonarSlim")
.IsDependentOn("SonarBegin")
.IsDependentOn("BuildDebug")
.IsDependentOn("AllTests")
.IsDependentOn("SonarEnd");

Task("Release")
.IsDependentOn("Sonar")
.IsDependentOn("Publish")
.IsDependentOn("PublishTemplates");

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 6cf4e40

Please sign in to comment.