Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Add coverage target
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Oct 22, 2019
1 parent 147f922 commit ea5c1b8
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
with:
name: output
path: output
- uses: actions/upload-artifact@v1
with:
name: coverage-report.zip
path: output/coverage-report.zip
ubuntu-16_04:
name: ubuntu-16_04
runs-on: ubuntu-16.04
Expand All @@ -33,6 +37,10 @@ jobs:
with:
name: output
path: output
- uses: actions/upload-artifact@v1
with:
name: coverage-report.zip
path: output/coverage-report.zip
ubuntu-18_04:
name: ubuntu-18_04
runs-on: ubuntu-18.04
Expand All @@ -48,6 +56,10 @@ jobs:
with:
name: output
path: output
- uses: actions/upload-artifact@v1
with:
name: coverage-report.zip
path: output/coverage-report.zip
windows-2016:
name: windows-2016
runs-on: windows-2016
Expand All @@ -63,6 +75,10 @@ jobs:
with:
name: output
path: output
- uses: actions/upload-artifact@v1
with:
name: coverage-report.zip
path: output/coverage-report.zip
windows-2019:
name: windows-2019
runs-on: windows-2019
Expand All @@ -78,3 +94,7 @@ jobs:
with:
name: output
path: output
- uses: actions/upload-artifact@v1
with:
name: coverage-report.zip
path: output/coverage-report.zip
48 changes: 47 additions & 1 deletion .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ project {
buildType(Test_P1T2)
buildType(Test_P2T2)
buildType(Test)
buildType(Coverage)
buildType(Publish)
buildType(Announce)

buildTypesOrder = arrayListOf(Compile, Pack, Test_P1T2, Test_P2T2, Test, Publish, Announce)
buildTypesOrder = arrayListOf(Compile, Pack, Test_P1T2, Test_P2T2, Test, Coverage, Publish, Announce)

params {
select (
Expand Down Expand Up @@ -124,6 +125,10 @@ object Test_P1T2 : BuildType({
root(VcsRoot)
cleanCheckout = true
}
artifactRules = """
output/*.trx
output/*.xml
""".trimIndent()
steps {
powerShell {
scriptMode = file { path = "build.ps1" }
Expand All @@ -144,6 +149,10 @@ object Test_P2T2 : BuildType({
root(VcsRoot)
cleanCheckout = true
}
artifactRules = """
output/*.trx
output/*.xml
""".trimIndent()
steps {
powerShell {
scriptMode = file { path = "build.ps1" }
Expand All @@ -165,6 +174,10 @@ object Test : BuildType({
root(VcsRoot)
showDependenciesChanges = true
}
artifactRules = """
output/*.trx
output/*.xml
""".trimIndent()
triggers {
vcs {
branchFilter = ""
Expand Down Expand Up @@ -194,6 +207,39 @@ object Test : BuildType({
}
}
})
object Coverage : BuildType({
name = "📊 Coverage"
vcs {
root(VcsRoot)
}
artifactRules = """
output/coverage-report.zip
""".trimIndent()
steps {
powerShell {
scriptMode = file { path = "build.ps1" }
param("jetbrains_powershell_scriptArguments", "Coverage --skip")
noProfile = true
}
}
triggers {
finishBuildTrigger {
buildType = "Test"
}
}
dependencies {
snapshot(Test) {
onDependencyFailure = FailureAction.FAIL_TO_START
onDependencyCancel = FailureAction.CANCEL
}
artifacts(Test) {
artifactRules = """
output/*.trx
output/*.xml
""".trimIndent()
}
}
})
object Publish : BuildType({
name = "🚚 Publish"
vcs {
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ build_script:
- ps: .\build.ps1 Test Pack

artifacts:
- path: output/*.trx
- path: output/*.xml
- path: output/coverage-report.zip
- path: output/*.nupkg
12 changes: 12 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ stages:
inputs:
filePath: 'build.ps1'
arguments: 'Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: output
pathtoPublish: 'output'
- job: Pack
displayName: '📦 Pack'
dependsOn: [ Compile ]
Expand Down Expand Up @@ -59,6 +63,10 @@ stages:
inputs:
filePath: 'build.ps1'
arguments: 'Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: output
pathtoPublish: 'output'
- job: Pack
displayName: '📦 Pack'
dependsOn: [ Compile ]
Expand Down Expand Up @@ -95,6 +103,10 @@ stages:
inputs:
filePath: 'build.ps1'
arguments: 'Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: output
pathtoPublish: 'output'
- job: Pack
displayName: '📦 Pack'
dependsOn: [ Compile ]
Expand Down
1 change: 1 addition & 0 deletions build/Build.AzurePipelinesAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected override AzurePipelinesJob GetJob(ExecutableTarget executableTarget, L
{ nameof(Compile), "⚙️" },
{ nameof(Test), "🚦" },
{ nameof(Pack), "📦" },
{ nameof(Coverage), "📊" },
{ nameof(Publish), "🚚" },
{ nameof(Announce), "🗣" }
};
Expand Down
1 change: 1 addition & 0 deletions build/Build.TeamCityAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected override IEnumerable<TeamCityBuildType> GetBuildTypes(
{ nameof(Compile), "⚙️" },
{ nameof(Test), "🚦" },
{ nameof(Pack), "📦" },
{ nameof(Coverage), "📊" },
{ nameof(Publish), "🚚" },
{ nameof(Announce), "🗣" }
};
Expand Down
48 changes: 42 additions & 6 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Nuke.Common;
Expand All @@ -14,23 +15,27 @@
using Nuke.Common.CI.TeamCity;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotCover;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.InspectCode;
using Nuke.Common.Tools.ReportGenerator;
using Nuke.Common.Tools.Slack;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.ChangeLog.ChangelogTasks;
using static Nuke.Common.ControlFlow;
using static Nuke.Common.Gitter.GitterTasks;
using static Nuke.Common.IO.CompressionTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.Git.GitTasks;
using static Nuke.Common.Tools.InspectCode.InspectCodeTasks;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
using static Nuke.Common.Tools.Slack.SlackTasks;

// ReSharper disable HeapView.DelegateAllocation
Expand Down Expand Up @@ -69,7 +74,7 @@
AzurePipelinesImage.MacOsLatest,
InvokedTargets = new[] { nameof(Test), nameof(Pack) },
NonEntryTargets = new[] { nameof(Restore) },
ExcludedTargets = new[] { nameof(Clean) })]
ExcludedTargets = new[] { nameof(Clean), nameof(Coverage) })]
partial class Build : NukeBuild
{
/// Support plugins are available for:
Expand Down Expand Up @@ -176,19 +181,50 @@ from framework in project.GetTargetFrameworks()

Target Test => _ => _
.DependsOn(Compile)
.Produces(OutputDirectory / "*.trx")
.Produces(OutputDirectory / "*.xml")
.Partition(() => TestPartition)
.Executes(() =>
{
DotNetTest(s => s
.SetConfiguration(Configuration)
.SetNoBuild(TeamCity.Instance == null)
.SetNoBuild(ExecutingTargets.Contains(Compile))
.ResetVerbosity()
.When(TeamCity.Instance != null, cs => cs
.SetProperty("CollectCoverage", propertyValue: true)
.SetProperty("CoverletOutputFormat", "teamcity"))
.SetLogger("trx")
.SetResultsDirectory(OutputDirectory)
.SetProperty("CollectCoverage", propertyValue: true)
.SetProperty("CoverletOutputFormat", "teamcity%2ccobertura")
.SetProperty("UseSourceLink", propertyValue: true)
.SetProperty("ExcludeByFile", "*.Generated.cs")
.CombineWith(
TestPartition.GetCurrent(Solution.GetProjects("*.Tests")), (cs, v) => cs
.SetProjectFile(v)));
.SetProjectFile(v)
.SetProperty("CoverletOutput", OutputDirectory / $"{v.Name}.xml")));

AzurePipelines.Instance?.PublishAzureDevOpsTestResults(
OutputDirectory.GlobFiles("*.trx").Select(x => new FileInfo(x)),
"Test Results");
});

string CoverageReportDirectory => OutputDirectory / "coverage-report";
string CoverageReportArchive => OutputDirectory / "coverage-report.zip";

Target Coverage => _ => _
.DependsOn(Test)
.TriggeredBy(Test)
.Consumes(Test)
.Produces(CoverageReportArchive)
.Executes(() =>
{
ReportGenerator(s => s
.SetReports(OutputDirectory / "*.xml")
.SetReportTypes(ReportTypes.HtmlInline)
.SetTargetDirectory(CoverageReportDirectory));

CompressZip(
directory: CoverageReportDirectory,
archiveFile: CoverageReportArchive,
fileMode: FileMode.Create);
});

Target Analysis => _ => _
Expand Down
2 changes: 2 additions & 0 deletions shell-completion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Skip:
- Changelog
- Clean
- Compile
- Coverage
- Generate
- Hotfix
- Install
Expand All @@ -43,6 +44,7 @@ Target:
- Changelog
- Clean
- Compile
- Coverage
- Generate
- Hotfix
- Install
Expand Down

0 comments on commit ea5c1b8

Please sign in to comment.