Created
November 9, 2015 13:43
-
-
Save bjartwolf/daafed892f2ee78be070 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "tools/FAKE/tools/FakeLib.dll" | |
open Fake | |
open Fake.Testing | |
open Fake.MSTest | |
open Fake.DotCover | |
open Fake.TeamCityHelper | |
open Fake.ZipHelper | |
open Fake.MSBuildHelper | |
"../.nuget/packages.config" |> RestorePackage (fun p -> { p with OutputPath = "tools" | |
ToolPath = "../.nuget/NuGet.exe"} ) | |
// causes teamcity to hang | |
MSBuildDefaults <- { MSBuildDefaults with NodeReuse = false} | |
// Maybe the error was typo in import and in that case could go back to use | |
// standard runner with nuget | |
Unzip "tools\dotCoverConsoleRunner.2.5.574.60" "..\Tools\dotCoverConsoleRunner.2.5.574.60.zip" | |
// Directories | |
let buildDir = "./build/" | |
let testDir = "./test/" | |
let artifactsDir = "./artifacts/" | |
// Filesets | |
let references = !! "Nrk.Programspiller.Backend.WebAPI/*.csproj" | |
-- "**/*Tests.csproj" | |
let testReferences = !! "**/*Tests.fsproj" | |
++ "../SpecFlow/**Backend/*.csproj" | |
++ "**/*Tests.csproj" | |
Target "RestoreNugetPackages" (fun _ -> | |
!! "./../.nuget/packages.config" | |
++ "./**/packages.config" | |
++ "./../SpecFlow\Nrk.Programspiller.Specifications.Backend/packages.config" | |
++ "./../Common/**/packages.config" | |
++ "./../Worker/Nrk.Programspiller.UserData\Nrk.Programspiller.UserData.Worker/packages.config" | |
++ "./../Worker/Nrk.Programspiller.ElasticSearch/Nrk.Programspiller.ElasticSearch.Library/packages.config" | |
++ "./../Nrk.ProgramSpiller.Data/**/packages.config" | |
|> Seq.iter (RestorePackage (fun p -> {p with ToolPath = "../.nuget/NuGet.exe" | |
OutputPath = "./../packages"})) | |
) | |
Target "Clean" (fun _ -> | |
CleanDirs [buildDir; testDir] | |
) | |
Target "IntegrationTest" (fun _ -> | |
!! (testDir + "*Tests.dll") | |
-- (testDir + "*IntegrationTests.dll") | |
|> MSTest (fun p -> p)) | |
Target "Build" (fun _ -> | |
MSBuild buildDir "Build" [ "Configuration", "Debug" ] references | |
|> Log "AppBuild-Output: ") | |
Target "BuildTest" (fun _ -> | |
MSBuild testDir "Build" [ "Configuration", "Debug" ] testReferences | |
|> Log "TestBuild-Output: ") | |
let coverFilters = "+:Nrk.Programspiller.Backend*;-:*Tests*;-:*Specifications*;-:Nrk.Programspiller.Common*" | |
let attributesFilters = "-:Generated*-:System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" | |
// Teamcity imports these from what I guess must be parsing of the build log | |
let dotCoverXUnit f = f |> DotCoverXUnit2 (fun p -> { p with Output=artifactsDir @@ "XUnit2.dcvr" | |
ErrorLevel = ErrorLevel.DontFailBuild | |
AttributeFilters = attributesFilters | |
Filters = coverFilters }) | |
(fun xUnit2Options -> xUnit2Options ) | |
Target "CoverXUnit2" (fun _ -> | |
!! (testDir + "*Tests.dll") |> dotCoverXUnit) // -- (testDir + "*IntegrationTests.dll") | |
Target "CoverXUnit2Integration" (fun _ -> | |
!! (testDir + "*Tests.dll") |> dotCoverXUnit) | |
let dotCoverMSTest f = f |> DotCoverMSTest (fun p -> { p with Output=artifactsDir @@ "MSTest.dcvr" | |
ErrorLevel = ErrorLevel.DontFailBuild | |
AttributeFilters = attributesFilters | |
Filters = coverFilters} ) | |
(fun p -> { p with ResultsDir = artifactsDir | |
NoIsolation = false} ) | |
sendTeamCityMSTestImport @"Backend/artifacts/*.trx" | |
Target "CoverMSTest" (fun _ -> | |
!! (testDir + "*Tests.dll") | |
++ (testDir + "*Specifications.Backend.dll") | |
-- (testDir + "*IntegrationTests*.dll") |> dotCoverMSTest) | |
Target "CoverMSTestIntegration" (fun _ -> | |
!! (testDir + "*Tests.dll") | |
++ (testDir + "*Specifications.Backend.dll") |> dotCoverMSTest) | |
Target "DotCoverMerge" (fun _ -> | |
DotCoverMerge (fun p -> { p with | |
Source = [artifactsDir @@ "XUnit2.dcvr" | |
artifactsDir @@ "MSTest.dcvr"] | |
Output = artifactsDir @@ "MergedDotCoverSnapshot.dcvr" })) | |
Target "DotCoverReportTC" (fun _ -> | |
sendToTeamCity "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='%s']" "Backend/artifacts/MergedDotCoverSnapshot.dcvr") | |
Target "CreateDotCoverXmlReport" (fun _ -> | |
DotCoverReport (fun p -> { p with | |
Source = artifactsDir @@ "MergedDotCoverSnapshot.dcvr" | |
Output = artifactsDir @@ "dotCoverReport.xml" | |
ReportType = DotCoverReportType.NDependXml} ) false) | |
Target "Integration" (fun _ -> trace "blank target") | |
let isIntegrationBuild = (getBuildParam "target" = "Integration") | |
"Clean" | |
==> "RestoreNugetPackages" | |
==> "Build" | |
==> "BuildTest" | |
=?> ("CoverXUnit2Integration", isIntegrationBuild) | |
=?> ("CoverMSTestIntegration", isIntegrationBuild) | |
=?> ("CoverXUnit2",not isIntegrationBuild) | |
=?> ("CoverMSTest",not isIntegrationBuild) | |
==> "DotCoverMerge" | |
==> "CreateDotCoverXmlReport" | |
==> "DotCoverReportTC" | |
==> "Integration" | |
RunTargetOrDefault "DotCoverReportTC" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment