elsa-core/build/Build.CI.GitHubActions.cs
Sipke Schoorstra 8747151330
Add code coverage configuration and adjust test projects (#7049)
* Add code coverage configuration and adjust test projects

- Introduced `Include` and `Threshold` properties across test project files for improved code coverage tracking.
- Added `coverlet.collector` as a dependency for coverage data collection.
- Removed unused `global using` directives and redundant imports for cleaner test codebases.

* Update GitHub Actions workflows for pull request triggers

- Adjusted `pr.yml` to include `patch/*` and `develop/*` branches.
- Removed redundant pull request triggers in `packages.yml` for cleaner configuration.

* Expand pull request triggers in GitHub Actions

- Renamed `PR` workflow to `pr` for consistency.
- Included `patch/*` and `develop/*` branches in `pr.yml` and `Build.CI.GitHubActions.cs`.

* Remove pack target from pull request workflows

- Updated `pr.yml` to exclude the pack step.
- Adjusted `Build.CI.GitHubActions.cs` to reflect the removal of the pack target.

* Remove `Elsa.Workflows.Api` from integration test project references

- Updated `Elsa.Workflows.IntegrationTests.csproj` to exclude `Elsa.Workflows.Api` from the `Include` list and project references for cleanup and simplification.
2025-11-12 13:59:36 +01:00

70 lines
2 KiB
C#

using System.Collections.Generic;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.CI.GitHubActions.Configuration;
using Nuke.Common.Execution;
using Nuke.Common.Utilities;
using Nuke.Components;
[CustomGitHubActions(
"pr",
GitHubActionsImage.UbuntuLatest,
OnPullRequestBranches = ["main", "patch/*", "develop/*"],
OnPullRequestIncludePaths = ["**/*"],
PublishArtifacts = false,
InvokedTargets = [nameof(ICompile.Compile), nameof(ITest.Test)],
CacheKeyFiles = [],
ConcurrencyCancelInProgress = true
)
]
public partial class Build;
class CustomGitHubActionsAttribute : GitHubActionsAttribute
{
public CustomGitHubActionsAttribute(string name, GitHubActionsImage image, params GitHubActionsImage[] images) : base(name, image, images)
{
}
protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyCollection<ExecutableTarget> relevantTargets)
{
var job = base.GetJobs(image, relevantTargets);
var newSteps = new List<GitHubActionsStep>(job.Steps);
// only need to list the ones that are missing from default image
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(["9.x"]));
job.Steps = newSteps.ToArray();
return job;
}
}
class GitHubActionsSetupDotNetStep : GitHubActionsStep
{
public GitHubActionsSetupDotNetStep(string[] versions)
{
Versions = versions;
}
string[] Versions { get; }
public override void Write(CustomFileWriter writer)
{
writer.WriteLine("- uses: actions/setup-dotnet@v4");
using (writer.Indent())
{
writer.WriteLine("with:");
using (writer.Indent())
{
writer.WriteLine("dotnet-version: |");
using (writer.Indent())
{
foreach (var version in Versions)
{
writer.WriteLine(version);
}
}
}
}
}
}