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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Build and test on every push to main, a release branch or net11, and every PR into any of them.
# Build and test on every push to main, a release branch or net11, and on every pull request.
# Two lines are supported from 11.0.0 on (CONTRIBUTING.md#branches-and-releases), and each branch
# that ships one needs the same checks as main's:
#
# - main is the next release. Until the v10.0.0 tag that is 10.0.0; after it, the 11 line.
# - release/9.x holds 9.x patches until the v10.0.0 tag, then takes no changes.
# - net11 holds the .NET 11 retarget and ships 11.0.0-preview.N until the v10.0.0 tag, merging
# main forward after every 10.0.0 fix. At the tag it becomes main.
# - release/10.x is cut from the v10.0.0 tag and holds the LTS line: 10.x minors (additions until
# v11.0.0, fixes only after it) and patches, cherry-picked from main.
# - release/10.x is cut from the v10.0.0 tag and holds the LTS line: 10.x minors (additions for
# six months after v11.0.0, fixes only after that) and patches, cherry-picked from main.
#
# Pull requests run whatever their base, so a stacked PR (one opened against another open PR's
# branch) is built and tested while it is stacked (#146). Retargeting it to main fires `edited`,
# which is deliberately not a trigger: a body edit would start a run whose skipped jobs pass the
# required checks, and would cancel a real run in the same concurrency group. It isn't needed
# either, because main's protection requires these checks on an up-to-date branch, and a PR whose
# base was merged into main is behind main, so updating it pushes a commit and starts a run.
#
# The release workflow keeps a 10.x tag off GitHub's Latest once 11.0.0 exists, and publishes a
# preview tag as a prerelease (release.yml, "Create the release").
Expand Down Expand Up @@ -38,7 +45,6 @@ on:
push:
branches: [ "main", "release/**", "net11" ]
pull_request:
branches: [ "main", "release/**", "net11" ]
workflow_dispatch:

permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,31 @@ private static IEnumerable<string> BuildOnlyReferencesOf(PackableProject project
.Select(reference => reference.Attribute("Include")?.Value)
.Where(id => !string.IsNullOrEmpty(id))!;

/// <summary>
/// A stacked PR targets another PR's branch, so a <c>branches</c> filter on the
/// <c>pull_request</c> trigger left it unbuilt until it was retargeted (#146). <c>edited</c>
/// stays out: a body edit would start a run whose skipped jobs pass the required checks.
/// </summary>
[TestMethod]
public void PullRequests_AreBuiltWhateverTheirBase()
{
var trigger = Regex.Match(
BuildWorkflowText(), @"^ pull_request:[^\n]*\n((?: [^\n]*\n)*)", RegexOptions.Multiline);

Assert.IsTrue(trigger.Success, "The .NET workflow has no pull_request trigger.");

var settings = trigger.Groups[1].Value;

Assert.IsFalse(
settings.Contains("branches", StringComparison.Ordinal),
"The .NET workflow's pull_request trigger filters on the base branch, so a stacked PR "
+ "(one opened against another PR's branch) is never built while it is stacked (#146).");
Assert.IsFalse(
settings.Contains("edited", StringComparison.Ordinal),
"The .NET workflow runs on `edited`. A body edit would start a run whose skipped jobs "
+ "pass the required checks and cancel a real run in the same concurrency group.");
}

private static string BuildWorkflowText() =>
File.ReadAllText(Path.Combine(RepoLayout.Root.FullName, ".github", "workflows", "dotnet.yml"));

Expand Down