Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 40 additions & 7 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,25 @@
CheckoutRef = "${{ github.head_ref }}",
// PRs targeting develop, main, or any release/* / support/* branch — all
// long-lived and protected; all require the ubuntu-latest check.
OnPullRequestBranches = new[] { DevelopBranch, MainBranch, ReleaseBranchPattern, SupportBranchPattern },
OnPullRequestExcludePaths = new[] { "docs/**", ".assets/**", "**/*.md" },
InvokedTargets = new[] { nameof(VerifyGeneratedTools), nameof(ITest.Test), nameof(IPack.Pack) },
OnPullRequestBranches = new[]
{
DevelopBranch,
MainBranch,
ReleaseBranchPattern,
SupportBranchPattern
},
OnPullRequestExcludePaths = new[]
{
"docs/**",
".assets/**",
"**/*.md"
},
InvokedTargets = new[]
{
nameof(VerifyGeneratedTools),
nameof(ITest.Test),
nameof(IPack.Pack)
},
PublishArtifacts = false)]
[GitHubActions(
"build-cross-platform",
Expand All @@ -53,13 +69,30 @@
FetchDepth = 0,
ConcurrencyGroup = "${{ github.workflow }}-${{ github.ref }}",
ConcurrencyCancelInProgress = true,
OnPushTags = new[] { "v*" },
OnPushTags = new[]
{
"v*"
},
// main is the production trunk now (ADR-0009). A PR into it is always a
// release/vX.Y GA merge or a hotfix, so it belongs on this release-intent gate,
// alongside release/* and support/*.
OnPullRequestBranches = new[] { MainBranch, ReleaseBranchPattern, SupportBranchPattern },
OnPullRequestExcludePaths = new[] { "docs/**", ".assets/**", "**/*.md" },
InvokedTargets = new[] { nameof(ITest.Test), nameof(IPack.Pack) },
OnPullRequestBranches = new[]
{
MainBranch,
ReleaseBranchPattern,
SupportBranchPattern
},
OnPullRequestExcludePaths = new[]
{
"docs/**",
".assets/**",
"**/*.md"
},
InvokedTargets = new[]
{
nameof(ITest.Test),
nameof(IPack.Pack)
},
PublishArtifacts = false)]
partial class Build
{
Expand Down
7 changes: 4 additions & 3 deletions build/Build.CodeGeneration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Fallout.Common;
using Fallout.Common;
using Fallout.Common.IO;
using Fallout.Common.Utilities.Collections;
using static Fallout.CodeGeneration.CodeGenerator;
Expand All @@ -9,6 +8,7 @@
partial class Build
{
AbsolutePath SpecificationsDirectory => RootDirectory / "src" / "Fallout.Common" / "Tools";

AbsolutePath ReferencesDirectory => RootDirectory / "docs" / "cli-tools";

// Hardcoded rather than derived from the locally-resolved git remote (e.g. via
Expand All @@ -32,7 +32,8 @@ partial class Build
GenerateCode(
x,
namespaceProvider: x => $"Fallout.Common.Tools.{x.Name}",
sourceFileProvider: x => $"https://github.com/{CanonicalRepositoryIdentifier}/blob/{DevelopBranch}/{RootDirectory.GetUnixRelativePathTo(x.SpecificationFile)}"));
sourceFileProvider: x =>
$"https://github.com/{CanonicalRepositoryIdentifier}/blob/{DevelopBranch}/{RootDirectory.GetUnixRelativePathTo(x.SpecificationFile)}"));
});

// CI gate: `GenerateTools` only runs when a contributor remembers to invoke it, so a .json
Expand Down
14 changes: 12 additions & 2 deletions build/Build.Contributors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,39 @@
partial class Build
{
AbsolutePath ContributorsFile => RootDirectory / "CONTRIBUTORS.md";

AbsolutePath ContributorsCacheFile => TemporaryDirectory / "contributors.dat";

Target UpdateContributors => _ => _
.Executes(() =>
{
var previousContributors = ContributorsCacheFile.Existing()?.ReadAllLines() ?? new string[0];

var repositoryDirectories = new[] { RootDirectory / ".git" }
var repositoryDirectories = new[]
{
RootDirectory / ".git"
}
.Concat(ExternalRepositoriesDirectory.GlobDirectories("*/.git"));

var contributors = repositoryDirectories
.SelectMany(x => Git(@"log --pretty=""%an|%ae%n%cn|%ce""", workingDirectory: x, logOutput: false))
.Select(x => x.Text)
.Distinct().ToList()
.Select(x => x.Split('|'))
.ForEachLazy(x => Assert.Count(x, length: 2))
.Select(x => new { Name = x[0], Email = x[1] }).ToList();
.Select(x => new
{
Name = x[0],
Email = x[1]
}).ToList();

var newContributors = contributors.Where(x => !previousContributors.Contains(x.Email));

foreach (var newContributor in newContributors)
{
var content = (ContributorsFile.Existing()?.ReadAllLines() ?? new string[0])
.Concat($"- {newContributor.Name}").OrderBy(x => x);

ContributorsFile.WriteAllLines(content, Encoding.Default);
Git($"add {ContributorsFile}");

Expand Down
11 changes: 7 additions & 4 deletions build/Build.GlobalSolution.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Fallout.Common;
using Fallout.Common.Git;
using Fallout.Common.IO;
using Fallout.Solutions;
using Fallout.Common.Tools.GitHub;
using Fallout.Common.Utilities;
using Fallout.Solutions;
using Fallout.Utilities.Text.Yaml;
using static Fallout.Common.ControlFlow;
using static Fallout.Common.Tools.Git.GitTasks;

partial class Build
{
[Parameter] readonly bool UseHttps;
[Parameter]
readonly bool UseHttps;

AbsolutePath GlobalSolution => RootDirectory / "fallout-global.sln";

AbsolutePath ExternalRepositoriesDirectory => RootDirectory / "external";

AbsolutePath ExternalRepositoriesFile => ExternalRepositoriesDirectory / "repositories.yml";

IEnumerable<Fallout.Solutions.Solution> ExternalSolutions
Expand All @@ -38,7 +39,9 @@ IEnumerable<GitRepository> ExternalRepositories
var origin = UseHttps ? repository.HttpsUrl : repository.SshUrl;

if (!Directory.Exists(repositoryDirectory))
{
Git($"clone {origin} {repositoryDirectory} --progress");
}
else
{
SuppressErrors(() => Git($"remote add origin {origin}", repositoryDirectory));
Expand Down
29 changes: 15 additions & 14 deletions build/Build.Licenses.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Fallout.Common;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Fallout.Common;
using Fallout.Common.IO;
using Fallout.Components;
using Serilog;
Expand All @@ -13,18 +13,18 @@ partial class Build

IEnumerable<(string Project, string Url)> Licenses
=> new[]
{
("Glob", "https://raw.githubusercontent.com/kthompson/glob/develop/LICENSE"),
("ICSharpCode.SharpZipLib", "https://raw.githubusercontent.com/icsharpcode/SharpZipLib/master/LICENSE.txt"),
("Microsoft.Build", "https://raw.githubusercontent.com/dotnet/msbuild/main/LICENSE"),
("Microsoft.CodeAnalysis", "https://raw.githubusercontent.com/dotnet/roslyn/main/License.txt"),
("Newtonsoft.Json", "https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/LICENSE.md"),
("NuGet", "https://raw.githubusercontent.com/NuGet/NuGet.Client/dev/LICENSE.txt"),
("Octokit", "https://raw.githubusercontent.com/octokit/octokit.net/main/LICENSE.txt"),
("Serilog", "https://raw.githubusercontent.com/serilog/serilog/dev/LICENSE"),
("Spectre.Console", "https://raw.githubusercontent.com/spectreconsole/spectre.console/main/LICENSE.md"),
("YamlDotNet", "https://raw.githubusercontent.com/aaubry/YamlDotNet/master/LICENSE.txt")
};
{
("Glob", "https://raw.githubusercontent.com/kthompson/glob/develop/LICENSE"),
("ICSharpCode.SharpZipLib", "https://raw.githubusercontent.com/icsharpcode/SharpZipLib/master/LICENSE.txt"),
("Microsoft.Build", "https://raw.githubusercontent.com/dotnet/msbuild/main/LICENSE"),
("Microsoft.CodeAnalysis", "https://raw.githubusercontent.com/dotnet/roslyn/main/License.txt"),
("Newtonsoft.Json", "https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/LICENSE.md"),
("NuGet", "https://raw.githubusercontent.com/NuGet/NuGet.Client/dev/LICENSE.txt"),
("Octokit", "https://raw.githubusercontent.com/octokit/octokit.net/main/LICENSE.txt"),
("Serilog", "https://raw.githubusercontent.com/serilog/serilog/dev/LICENSE"),
("Spectre.Console", "https://raw.githubusercontent.com/spectreconsole/spectre.console/main/LICENSE.md"),
("YamlDotNet", "https://raw.githubusercontent.com/aaubry/YamlDotNet/master/LICENSE.txt")
};

Target DownloadLicenses => _ => _
.After<ICompile>()
Expand All @@ -38,6 +38,7 @@ partial class Build
await HttpDownloadFileAsync(x.Url, LicensesDirectory / $"{x.Project}.txt");
Log.Information("Downloaded license for {Project}", x.Project);
});

Task.WaitAll(downloadTasks.ToArray());
});
}
12 changes: 11 additions & 1 deletion build/Build.PublicApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,24 @@ partial class Build
bool DefaultFilter(MemberInfo member)
{
if (member is PropertyInfo)
{
return false;
}

if (member is Type && !member.IsPublic())
{
return false;
}

if (!(member.IsPublic() || member.IsFamily() && !member.DeclaringType.NotNull().IsSealed))
if (!(member.IsPublic() || (member.IsFamily() && !member.DeclaringType.NotNull().IsSealed)))
{
return false;
}

if (member is FieldInfo { IsSpecialName: true })
{
return false;
}

return true;
}
Expand All @@ -78,7 +86,9 @@ bool DefaultFilter(MemberInfo member)
.ThenBy(x => x.Name);

foreach (var member in members)
{
builder.AppendLine($"- {member.GetDisplayText()}");
}

builder.AppendLine();
}
Expand Down
30 changes: 21 additions & 9 deletions build/Build.Stargazers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,36 @@ partial class Build
var stargazerUsers = await GitHubTasks.GitHubClient.Activity.Starring.GetAllStargazers(
GitRepository.GetGitHubOwner(),
GitRepository.GetGitHubName());

var stargazerEntries = stargazerUsers.Select(async x =>
{
var user = await GitHubTasks.GitHubClient.User.Get(x.Login);
return new[]
{
user.Login.DoubleQuote(),
user.Name.DoubleQuote(),
user.Company.DoubleQuote(),
user.Location.DoubleQuote(),
user.Email.DoubleQuote(),
user.Blog.DoubleQuote()
};
{
user.Login.DoubleQuote(),
user.Name.DoubleQuote(),
user.Company.DoubleQuote(),
user.Location.DoubleQuote(),
user.Email.DoubleQuote(),
user.Blog.DoubleQuote()
};
}).ToList();

await Task.WhenAll(stargazerEntries);

StargazersFile.WriteAllLines(
new[] { new[] { "Login", "Name", "Company", "Location", "Email", "Blog" } }
new[]
{
new[]
{
"Login",
"Name",
"Company",
"Location",
"Email",
"Blog"
}
}
.Concat(stargazerEntries.Select(x => x.Result).OrderBy(x => x.First()))
.Select(x => x.JoinComma()));
});
Expand Down
4 changes: 1 addition & 3 deletions build/Build.Terminal.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using Fallout.Common;
using Fallout.Common;
using Fallout.Common.Execution;

[DisableDefaultOutput<Terminal>(
Expand Down
Loading
Loading