Skip to content

Commit d0dfdd6

Browse files
Updated nuke build to use new extension methods
1 parent faa77e7 commit d0dfdd6

File tree

1 file changed

+16
-128
lines changed

1 file changed

+16
-128
lines changed

.build/Build.CI.cs

Lines changed: 16 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,6 @@
66

77
#pragma warning disable CA1050
88

9-
internal class LocalConstants
10-
{
11-
public static string[] PathsIgnore =
12-
{
13-
".codecov.yml",
14-
".editorconfig",
15-
".gitattributes",
16-
".gitignore",
17-
".gitmodules",
18-
".lintstagedrc.js",
19-
".prettierignore",
20-
".prettierrc",
21-
"LICENSE",
22-
"nukeeper.settings.json",
23-
"omnisharp.json",
24-
"package-lock.json",
25-
"package.json",
26-
"Readme.md",
27-
".github/dependabot.yml",
28-
".github/labels.yml",
29-
".github/release.yml",
30-
".github/renovate.json",
31-
};
32-
}
33-
349
[GitHubActionsSteps(
3510
"ci-ignore",
3611
GitHubActionsImage.WindowsLatest,
@@ -70,18 +45,11 @@ internal class LocalConstants
7045
[PrintCIEnvironment]
7146
[UploadLogs]
7247
[TitleEvents]
48+
[ContinuousIntegrationConventions]
7349
public partial class Solution
7450
{
75-
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(
76-
RocketSurgeonGitHubActionsConfiguration configuration
77-
)
51+
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
7852
{
79-
foreach (var item in configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsVcsTrigger>())
80-
{
81-
item.IncludePaths = LocalConstants.PathsIgnore;
82-
}
83-
84-
configuration.Jobs.RemoveAt(1);
8553
( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = new List<GitHubActionsStep>
8654
{
8755
new RunStep("N/A")
@@ -90,103 +58,23 @@ RocketSurgeonGitHubActionsConfiguration configuration
9058
}
9159
};
9260

93-
return configuration;
61+
return configuration.IncludeRepositoryConfigurationFiles();
9462
}
9563

96-
public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(
97-
RocketSurgeonGitHubActionsConfiguration configuration
98-
)
64+
public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
9965
{
100-
foreach (var item in configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsVcsTrigger>())
101-
{
102-
item.ExcludePaths = LocalConstants.PathsIgnore;
103-
}
104-
105-
var buildJob = configuration.Jobs.OfType<RocketSurgeonsGithubActionsJob>().First(z => z.Name == "Build");
106-
buildJob.FailFast = false;
107-
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single();
108-
// For fetch all
109-
checkoutStep.FetchDepth = 0;
110-
buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages";
111-
buildJob.Steps.InsertRange(
112-
buildJob.Steps.IndexOf(checkoutStep) + 1,
113-
new BaseGitHubActionsStep[]
114-
{
115-
new RunStep("Fetch all history for all tags and branches")
116-
{
117-
Run = "git fetch --prune"
118-
},
119-
new UsingStep("NuGet Cache")
120-
{
121-
Uses = "actions/cache@v2",
122-
With =
123-
{
124-
["path"] = "${{ github.workspace }}/.nuget/packages",
125-
// keep in mind using central package versioning here
126-
["key"] =
127-
"${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
128-
["restore-keys"] = @"|
129-
${{ runner.os }}-nuget-"
130-
}
131-
},
132-
new SetupDotNetStep("Use .NET Core 3.1 SDK")
133-
{
134-
DotNetVersion = "3.1.x"
135-
},
136-
new SetupDotNetStep("Use .NET Core 6.0 SDK")
137-
{
138-
DotNetVersion = "6.0.x"
139-
},
140-
}
141-
);
142-
143-
buildJob.Steps.Add(
144-
new UsingStep("Publish Coverage")
145-
{
146-
Uses = "codecov/codecov-action@v1",
147-
With = new Dictionary<string, string>
148-
{
149-
["name"] = "actions-${{ matrix.os }}",
150-
}
151-
}
152-
);
153-
154-
buildJob.Steps.Add(
155-
new UploadArtifactStep("Publish logs")
156-
{
157-
Name = "logs",
158-
Path = "artifacts/logs/",
159-
If = "always()"
160-
}
161-
);
162-
163-
buildJob.Steps.Add(
164-
new UploadArtifactStep("Publish coverage data")
165-
{
166-
Name = "coverage",
167-
Path = "coverage/",
168-
If = "always()"
169-
}
170-
);
171-
172-
buildJob.Steps.Add(
173-
new UploadArtifactStep("Publish test data")
174-
{
175-
Name = "test data",
176-
Path = "artifacts/test/",
177-
If = "always()"
178-
}
179-
);
180-
181-
buildJob.Steps.Add(
182-
new UploadArtifactStep("Publish NuGet Packages")
183-
{
184-
Name = "nuget",
185-
Path = "artifacts/nuget/",
186-
If = "always()"
187-
}
188-
);
66+
configuration
67+
.ExcludeRepositoryConfigurationFiles()
68+
.AddNugetPublish()
69+
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
70+
.First(z => z.Name == "Build")
71+
.UseDotNetSdks("3.1", "6.0")
72+
.AddNuGetCache()
73+
// .ConfigureForGitVersion()
74+
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
75+
.PublishLogs<Solution>()
76+
.FailFast = false;
18977

19078
return configuration;
19179
}
192-
}
80+
}

0 commit comments

Comments
 (0)