diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml
index a8a0244..6eac7bd 100644
--- a/.github/workflows/continuous.yml
+++ b/.github/workflows/continuous.yml
@@ -23,7 +23,7 @@ jobs:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
@@ -33,10 +33,21 @@ jobs:
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- - name: 'Run: Compile, Pack'
- run: ./build.cmd Compile Pack
+ - name: 'Run: Compile, Test, Pack'
+ run: ./build.cmd Compile Test Pack
+ - name: 'Upload coverage to Codecov'
+ uses: codecov/codecov-action@v5
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ files: artifacts/coverage/*.xml
+ fail_ci_if_error: false
+ - name: 'Publish: coverage'
+ uses: actions/upload-artifact@v5
+ with:
+ name: coverage
+ path: artifacts/coverage
- name: 'Publish: packages'
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v5
with:
name: packages
path: artifacts/packages
diff --git a/build/Build.cs b/build/Build.cs
index 25590f9..67834ed 100644
--- a/build/Build.cs
+++ b/build/Build.cs
@@ -8,6 +8,7 @@
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
+using Nuke.Common.Tools.Coverlet;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Utilities.Collections;
@@ -22,7 +23,7 @@
FetchDepth = 0,
On = [GitHubActionsTrigger.Push],
PublishArtifacts = true,
- InvokedTargets = [nameof(Compile), nameof(Pack)])]
+ InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack)])]
[GitHubActions(
"release",
GitHubActionsImage.UbuntuLatest,
@@ -59,6 +60,7 @@ class Build : NukeBuild
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
AbsolutePath PackagesDirectory => ArtifactsDirectory / "packages";
+ AbsolutePath CoverageDirectory => ArtifactsDirectory / "coverage";
Target Clean => _ => _
.Before(Restore)
@@ -104,16 +106,22 @@ class Build : NukeBuild
Target Test => _ => _
.DependsOn(Compile)
+ .Produces(CoverageDirectory / "*.xml")
.Executes(() =>
{
var projects = Solution.GetAllProjects("*.Tests");
+ CoverageDirectory.CreateOrCleanDirectory();
+
foreach (var project in projects)
{
DotNetTest(_ => _
.SetProjectFile(project.Path)
.SetConfiguration(Configuration)
.EnableNoBuild()
+ .EnableCollectCoverage()
+ .SetCoverletOutputFormat(CoverletOutputFormat.cobertura)
+ .SetCoverletOutput(CoverageDirectory / $"{project.Name}.xml")
);
}
});
diff --git a/src/Scarlet.System.Text.Json.DateTimeConverter.Tests/Scarlet.System.Text.Json.DateTimeConverter.Tests.csproj b/src/Scarlet.System.Text.Json.DateTimeConverter.Tests/Scarlet.System.Text.Json.DateTimeConverter.Tests.csproj
index 6a60c6a..6fd67cd 100644
--- a/src/Scarlet.System.Text.Json.DateTimeConverter.Tests/Scarlet.System.Text.Json.DateTimeConverter.Tests.csproj
+++ b/src/Scarlet.System.Text.Json.DateTimeConverter.Tests/Scarlet.System.Text.Json.DateTimeConverter.Tests.csproj
@@ -14,6 +14,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+