From 46c1720b4620eea3f5fe5e9d5607c01abbec75b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gro=C3=9F?= Date: Sun, 18 Oct 2026 19:26:01 +0200 Subject: [PATCH] ci: build every pull request, so a stacked PR is tested while stacked The .NET workflow's pull_request trigger filtered on main, release/** and net11, so a PR opened against another PR's branch got no run until it was retargeted and updated. The filter goes; push keeps its own. `edited` is deliberately not added for the retarget: a body edit would start a run whose skipped jobs pass the required checks and cancel a real run in the same concurrency group. main's protection requires the checks on an up-to-date branch, so a retargeted PR is updated, and that push starts a run. A convention test holds both halves. Also brings the header comment in line with the 10.x additions window (#180). Closes #146 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dotnet.yml | 14 ++++++++--- .../ReleaseWiringConventionTests.cs | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ce6c1606..d6a10faa 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,4 +1,4 @@ -# 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: # @@ -6,8 +6,15 @@ # - 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"). @@ -38,7 +45,6 @@ on: push: branches: [ "main", "release/**", "net11" ] pull_request: - branches: [ "main", "release/**", "net11" ] workflow_dispatch: permissions: diff --git a/test/CodoMetis.ValueRanges.Conventions.Tests/ReleaseWiringConventionTests.cs b/test/CodoMetis.ValueRanges.Conventions.Tests/ReleaseWiringConventionTests.cs index afe31b49..e6b15ba7 100644 --- a/test/CodoMetis.ValueRanges.Conventions.Tests/ReleaseWiringConventionTests.cs +++ b/test/CodoMetis.ValueRanges.Conventions.Tests/ReleaseWiringConventionTests.cs @@ -194,6 +194,31 @@ private static IEnumerable BuildOnlyReferencesOf(PackableProject project .Select(reference => reference.Attribute("Include")?.Value) .Where(id => !string.IsNullOrEmpty(id))!; + /// + /// A stacked PR targets another PR's branch, so a branches filter on the + /// pull_request trigger left it unbuilt until it was retargeted (#146). edited + /// stays out: a body edit would start a run whose skipped jobs pass the required checks. + /// + [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"));