Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .fallout/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"RunTargetInDockerImageTest",
"Test",
"UpdateContributors",
"UpdateStargazers"
"UpdateStargazers",
"VerifyGeneratedTools"
]
},
"Verbosity": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ jobs:
global-json-file: global.json
- name: 'Restore: dotnet tools'
run: dotnet tool restore
- name: 'Run: Test, Pack'
run: dotnet fallout Test Pack
- name: 'Run: VerifyGeneratedTools, Test, Pack'
run: dotnet fallout VerifyGeneratedTools Test Pack
2 changes: 1 addition & 1 deletion build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// branch — all are long-lived and protected; all require the ubuntu-latest check.
OnPullRequestBranches = new[] { ExperimentalBranch, MainBranch, ReleaseBranchPattern, SupportBranchPattern },
OnPullRequestExcludePaths = new[] { "docs/**", ".assets/**", "**/*.md" },
InvokedTargets = new[] { nameof(ITest.Test), nameof(IPack.Pack) },
InvokedTargets = new[] { nameof(VerifyGeneratedTools), nameof(ITest.Test), nameof(IPack.Pack) },
PublishArtifacts = false)]
partial class Build
{
Expand Down
27 changes: 22 additions & 5 deletions build/Build.CodeGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,29 @@ partial class Build
});

Target GenerateTools => _ => _
.Executes(() => GenerateAllTools());

// CI gate: `GenerateTools` only runs when a contributor remembers to invoke it, so a .json
// spec edited without regenerating its .Generated.cs could merge silently and ship stale
// wrapper code. Regenerating from a known-clean checkout and asserting the working copy is
// still clean afterward catches that drift before merge.
Target VerifyGeneratedTools => _ => _
.Requires(() => GitHasCleanWorkingCopy())
.Executes(() =>
{
SpecificationsDirectory.GlobFiles("*/*.json").ForEach(x =>
GenerateCode(
x,
namespaceProvider: x => $"Fallout.Common.Tools.{x.Name}",
sourceFileProvider: x => GitRepository.SetBranch(MainBranch).GetGitHubBrowseUrl(x.SpecificationFile)));
GenerateAllTools();

Assert.True(
GitHasCleanWorkingCopy(),
"Generated tool wrappers are out of sync with their .json specs. Run './build.ps1 GenerateTools' locally and commit the result.");
});

void GenerateAllTools()
{
SpecificationsDirectory.GlobFiles("*/*.json").ForEach(x =>
GenerateCode(
x,
namespaceProvider: x => $"Fallout.Common.Tools.{x.Name}",
sourceFileProvider: x => GitRepository.SetBranch(MainBranch).GetGitHubBrowseUrl(x.SpecificationFile)));
}
}
Loading