Skip to content

Commit

Permalink
ci: fix step order
Browse files Browse the repository at this point in the history
  • Loading branch information
ArwynFr committed Aug 13, 2024
1 parent c76a8f3 commit c62c96c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
6 changes: 2 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@
"type": "string",
"enum": [
"Clean",
"Lint",
"Pack",
"Publish",
"Release",
"Restore",
"Sonarqube",
"SonarScannerBegin",
"Tags",
"Test"
]
Expand All @@ -99,12 +98,11 @@
"type": "string",
"enum": [
"Clean",
"Lint",
"Pack",
"Publish",
"Release",
"Restore",
"Sonarqube",
"SonarScannerBegin",
"Tags",
"Test"
]
Expand Down
77 changes: 37 additions & 40 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,50 @@ class Build : NukeBuild
AbsolutePath NugetGlob => RootDirectory / Constants.Nuget.PackageGlob;
bool IsPreRelease => !string.IsNullOrEmpty(OctoVersionInfo.PreReleaseTag);

Target Clean => _ => _
.Before(Restore, Test)
.Executes(() =>
{
DotNetTasks.DotNetClean();
TestResultsDirectory.DeleteDirectory();
NugetGlob.GlobFiles().DeleteFiles();
DotSonar.DeleteDirectory();
});

Target Restore => _ => _
.Unlisted()
.Executes(() => DotNetTasks.DotNetToolRestore());

Target Test => _ => _
Target Lint => _ => _
.DependsOn(Restore)
.Unlisted()
.Executes(() =>
{
DotNetTasks.DotNet("format --verify-no-changes");
DotNetTasks.DotNet("tool run roslynator analyze");
DotNetTasks.DotNet("tool run dotnet-outdated --fail-on-updates");
DotNetTasks.DotNetTest(_ => _
.SetProjectFile(TestProject.Path)
.EnableCollectCoverage()
.SetDataCollector(Constants.XUnit.CoverletCollectorName)
.SetResultsDirectory(TestResultsDirectory)
.AddRunSetting(Constants.XUnit.FormatSetting, Constants.XUnit.OpenCoverFormat)
.AddRunSetting(Constants.XUnit.IncludeSetting, TestIncludes));
});

Target Test => _ => _
.DependsOn(Lint)
.Executes(() => DotNetTasks.DotNetTest(_ => _
.SetProjectFile(TestProject.Path)
.EnableCollectCoverage()
.SetDataCollector(Constants.XUnit.CoverletCollectorName)
.SetResultsDirectory(TestResultsDirectory)
.AddRunSetting(Constants.XUnit.FormatSetting, Constants.XUnit.OpenCoverFormat)
.AddRunSetting(Constants.XUnit.IncludeSetting, TestIncludes)));

Target SonarScannerBegin => _ => _
.Unlisted()
.Before(Test)
Target Sonarqube => _ => _
.Requires(() => SonarToken)
.Executes(() => SonarScannerTasks.SonarScannerBegin(_ => _
.SetOrganization(SonarOrganization)
.SetProjectKey(SonarKey)
.SetOpenCoverPaths(TestResultsGlob)
.SetToken(SonarToken)
.SetQualityGateWait(true)));

Target Sonarqube => _ => _
.DependsOn(SonarScannerBegin, Test)
.SetQualityGateWait(true)))
.Inherit(Test)
.Executes(() => SonarScannerTasks.SonarScannerEnd(_ => _.SetToken(SonarToken)));

Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
DotNetTasks.DotNetClean();
TestResultsDirectory.DeleteDirectory();
NugetGlob.GlobFiles().DeleteFiles();
DotSonar.DeleteDirectory();
});

Target Pack => _ => _
.Executes(() => DotNetTasks.DotNetPack(_ => _
.SetProject(Solution.ArwynFr_IntegrationTesting)
Expand All @@ -88,21 +86,20 @@ class Build : NukeBuild

Target Publish => _ => _
.DependsOn(Pack, Sonarqube)
.Requires(() => NugetApikey)
.Executes(() => DotNetTasks.DotNetNuGetPush(_ => _
.SetSource(Constants.Nuget.DefaultNugetSource)
.SetApiKey(NugetApikey)
.SetTargetPath(NugetGlob)));
.Requires(() => NugetApikey, () => GhToken)
.Executes(() =>
{
DotNetTasks.DotNetNuGetPush(_ => _
.SetSource(Constants.Nuget.DefaultNugetSource)
.SetApiKey(NugetApikey)
.SetTargetPath(NugetGlob));

Target Release => _ => _
.Unlisted()
.TriggeredBy(Publish)
.Requires(() => GhToken)
.Executes(() => Gh.Invoke(
arguments: $"release create {OctoVersionInfo.FullSemVer} --generate-notes",
environmentVariables: EnvironmentInfo.Variables
.ToDictionary(x => x.Key, x => x.Value)
.SetKeyValue("GH_TOKEN", GhToken).AsReadOnly()));
Gh.Invoke(
arguments: $"release create {OctoVersionInfo.FullSemVer} --generate-notes",
environmentVariables: EnvironmentInfo.Variables
.ToDictionary(x => x.Key, x => x.Value)
.SetKeyValue("GH_TOKEN", GhToken).AsReadOnly());
});

Target Tags => _ => _
.Unlisted()
Expand Down

0 comments on commit c62c96c

Please sign in to comment.