Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated nuke build to use new extension methods #535

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
144 changes: 16 additions & 128 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@

#pragma warning disable CA1050

internal class LocalConstants
{
public static string[] PathsIgnore =
{
".codecov.yml",
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".lintstagedrc.js",
".prettierignore",
".prettierrc",
"LICENSE",
"nukeeper.settings.json",
"omnisharp.json",
"package-lock.json",
"package.json",
"Readme.md",
".github/dependabot.yml",
".github/labels.yml",
".github/release.yml",
".github/renovate.json",
};
}

[GitHubActionsSteps(
"ci-ignore",
GitHubActionsImage.WindowsLatest,
Expand Down Expand Up @@ -70,18 +45,11 @@ internal class LocalConstants
[PrintCIEnvironment]
[UploadLogs]
[TitleEvents]
[ContinuousIntegrationConventions]
public partial class Solution
{
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(
RocketSurgeonGitHubActionsConfiguration configuration
)
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
foreach (var item in configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsVcsTrigger>())
{
item.IncludePaths = LocalConstants.PathsIgnore;
}

configuration.Jobs.RemoveAt(1);
( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = new List<GitHubActionsStep>
{
new RunStep("N/A")
Expand All @@ -90,103 +58,23 @@ RocketSurgeonGitHubActionsConfiguration configuration
}
};

return configuration;
return configuration.IncludeRepositoryConfigurationFiles();
}

public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(
RocketSurgeonGitHubActionsConfiguration configuration
)
public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
foreach (var item in configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsVcsTrigger>())
{
item.ExcludePaths = LocalConstants.PathsIgnore;
}

var buildJob = configuration.Jobs.OfType<RocketSurgeonsGithubActionsJob>().First(z => z.Name == "Build");
buildJob.FailFast = false;
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single();
// For fetch all
checkoutStep.FetchDepth = 0;
buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages";
buildJob.Steps.InsertRange(
buildJob.Steps.IndexOf(checkoutStep) + 1,
new BaseGitHubActionsStep[]
{
new RunStep("Fetch all history for all tags and branches")
{
Run = "git fetch --prune"
},
new UsingStep("NuGet Cache")
{
Uses = "actions/cache@v2",
With =
{
["path"] = "${{ github.workspace }}/.nuget/packages",
// keep in mind using central package versioning here
["key"] =
"${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
["restore-keys"] = @"|
${{ runner.os }}-nuget-"
}
},
new SetupDotNetStep("Use .NET Core 3.1 SDK")
{
DotNetVersion = "3.1.x"
},
new SetupDotNetStep("Use .NET Core 6.0 SDK")
{
DotNetVersion = "6.0.x"
},
}
);

buildJob.Steps.Add(
new UsingStep("Publish Coverage")
{
Uses = "codecov/codecov-action@v1",
With = new Dictionary<string, string>
{
["name"] = "actions-${{ matrix.os }}",
}
}
);

buildJob.Steps.Add(
new UploadArtifactStep("Publish logs")
{
Name = "logs",
Path = "artifacts/logs/",
If = "always()"
}
);

buildJob.Steps.Add(
new UploadArtifactStep("Publish coverage data")
{
Name = "coverage",
Path = "coverage/",
If = "always()"
}
);

buildJob.Steps.Add(
new UploadArtifactStep("Publish test data")
{
Name = "test data",
Path = "artifacts/test/",
If = "always()"
}
);

buildJob.Steps.Add(
new UploadArtifactStep("Publish NuGet Packages")
{
Name = "nuget",
Path = "artifacts/nuget/",
If = "always()"
}
);
configuration
.ExcludeRepositoryConfigurationFiles()
.AddNugetPublish()
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name == "Build")
.UseDotNetSdks("3.1", "6.0")
.AddNuGetCache()
// .ConfigureForGitVersion()
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
.PublishLogs<Solution>()
.FailFast = false;

return configuration;
}
}
}