Skip to content

Regenerate ci github workflows from Nuke build #1048

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

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Build;
[DotNetVerbosityMapping]
[MSBuildVerbosityMapping]
[NuGetVerbosityMapping]
[LocalBuildConventions]
public sealed partial class Solution : NukeBuild,
ICanRestoreWithDotNetCore,
ICanBuildWithDotNetCore,
Expand All @@ -28,6 +29,7 @@ public sealed partial class Solution : NukeBuild,
IGenerateCodeCoverageReport,
IGenerateCodeCoverageSummary,
IGenerateCodeCoverageBadges,
IGenerateDocFx,
IHaveConfiguration<Configuration>
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions .build/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Build;
[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
{
public static Configuration Debug => new() { Value = nameof(Debug) };
public static Configuration Release => new() { Value = nameof(Release) };
public static Configuration Debug = new() { Value = nameof(Debug) };
public static Configuration Release = new() { Value = nameof(Release) };

public static implicit operator string(Configuration configuration) => configuration.Value;
}
116 changes: 13 additions & 103 deletions .build/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@ internal class LocalConstants
[PrintCIEnvironment]
[UploadLogs]
[TitleEvents]
[ContinuousIntegrationConventions]
public partial class Solution
{
public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(
RocketSurgeonGitHubActionsConfiguration configuration
)
{
foreach (var item in configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsVcsTrigger>())
{
item.IncludePaths = LocalConstants.PathsIgnore;
}
configuration.IncludeRepositoryConfigurationFiles();

configuration.Jobs.RemoveAt(1);
( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = new List<GitHubActionsStep>
{
new RunStep("N/A")
Expand All @@ -97,104 +94,17 @@ 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 7.0 SDK")
{
DotNetVersion = "7.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()"
}
);

buildJob.Steps.Add(
new UploadArtifactStep("Publish Docs")
{
Name = "docs",
Path = "artifacts/docs/",
If = "always()"
}
);
configuration
.ExcludeRepositoryConfigurationFiles()
.AddNugetPublish()
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase))
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
.UseDotNetSdks("3.1", "7.0")
.AddNuGetCache()
.PublishLogs<Solution>()
.PublishArtifacts<Solution>()
.FailFast = false;

return configuration;
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ on:
- '.github/renovate.json'

jobs:
Build:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,20 @@ on:
- '.github/renovate.json'

jobs:
Build:
build:
env:
NUGET_PACKAGES: '${{ github.workspace }}/.nuget/packages'
strategy:
fail-fast: false
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]
os: [macos-latest, windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
clean: 'false'
fetch-depth: '0'
- name: Fetch all history for all tags and branches
run: |
git fetch --prune
- name: NuGet Cache
uses: actions/cache@v3
with:
Expand All @@ -105,18 +102,29 @@ jobs:
run: |
dotnet tool restore
- name: 🎁 Restore
id: restore
run: |
dotnet nuke Restore --skip
- name: ⚙ Build
id: build
run: |
dotnet nuke Build --skip
- name: 🚦 Test
id: test
run: |
dotnet nuke Test TriggerCodeCoverageReports GenerateCodeCoverageReportCobertura GenerateCodeCoverageBadges GenerateCodeCoverageSummary GenerateCodeCoverageReport --skip
- name: 📦 Pack
id: pack
run: |
dotnet nuke Pack --skip
- name: 🏺 Publish coverage data
if: always()
uses: actions/upload-artifact@v3
with:
name: 'coverage'
path: 'coverage/'
- name: 🐿 Publish Coverage
if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || ((github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.user.login != 'renovate[bot]' && github.event.pull_request.user.login != 'dependabot[bot]')
uses: codecov/[email protected]
with:
name: 'actions-${{ matrix.os }}'
Expand All @@ -126,12 +134,6 @@ jobs:
with:
name: 'logs'
path: 'artifacts/logs/'
- name: 🏺 Publish coverage data
if: always()
uses: actions/upload-artifact@v3
with:
name: 'coverage'
path: 'coverage/'
- name: 🏺 Publish test data
if: always()
uses: actions/upload-artifact@v3
Expand All @@ -144,16 +146,15 @@ jobs:
with:
name: 'nuget'
path: 'artifacts/nuget/'
- name: 🏺 Publish Docs
if: always()
- name: 🏺 Publish Documentation
uses: actions/upload-artifact@v3
with:
name: 'docs'
path: 'artifacts/docs/'
Publish:
needs:
- Build
uses: RocketSurgeonsGuild/actions/.github/workflows/[email protected]
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
uses: RocketSurgeonsGuild/actions/.github/workflows/[email protected]
6 changes: 6 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"type": "string",
"description": "Root directory during build execution"
},
"Serve": {
"type": "boolean",
"description": "serve the docs"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
Expand All @@ -84,6 +88,7 @@
"BuildVersion",
"Clean",
"CoreBuild",
"CoreDocs",
"CorePack",
"CoreRestore",
"CoreTest",
Expand Down Expand Up @@ -120,6 +125,7 @@
"BuildVersion",
"Clean",
"CoreBuild",
"CoreDocs",
"CorePack",
"CoreRestore",
"CoreTest",
Expand Down