fix(release): decide channels from every page and never fail after publishing
The release step decided :latest and the releases repository's content after the Gitea release was already public, and could then fail or decide wrongly (owner review 2, phase 1 review): - Re-publishing v0.1.0-rc.1 or rc.2 builds Chronos.Tools from the tag, which has no release-channels: the step failed after publishing and the image job never ran. Any failure to decide (a tag older than the command, an unreadable page, a body that is not a list) now warns and moves no channel, so the version's image is still pushed. - Only the first page (50, newest first) of releases was read, and pre-releases now share it with stable ones: 50 pre-releases after a stable release hid it and moved :latest to a pre-release. The workflow reads every page up to the first empty one (at most 100) and release-channels takes one --releases file per page (Args.GetAll). - The Version step accepted tags release-channels refuses (v01.2.0), which then failed only after publishing. It now uses release-channels' SemVer 2.0 pattern without +BUILD, and a test keeps the two in step. BRIEF §19.3, DECISIONS, CHANGELOG and README step 5 say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a34b33d50b
commit
b2aeb2f587
8 files changed
+129
-40
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.RegularExpressions;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Tools.Commands;
|
||||
|
||||
@@ -75,6 +76,18 @@ public sealed class ReleaseChannelsCommandTests(TestContext context)
|
||||
Assert.Equal(Neither, Decide("v2.0.0", """[{"name":"no tag"},{"tag_name":42},{"tag_name":"v3.0.0"},7,null]"""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EveryPageOfTheListCounts()
|
||||
{
|
||||
// Gitea lists 50 releases a page, newest first: 50 pre-releases after v1.0.0 push it to the second page.
|
||||
var first = Releases([.. Enumerable.Range(1, 50).Reverse().Select(n => $"v1.1.0-rc.{n}")]);
|
||||
var second = Releases("v1.0.0", "v0.9.0");
|
||||
Assert.Equal(ImageOnly, Decide("v1.1.0-rc.51", first), "the first page alone shows no stable release");
|
||||
Assert.Equal(Neither, Decide("v1.1.0-rc.51", first, second));
|
||||
Assert.Equal(Neither, Decide("v0.9.0", first, second));
|
||||
Assert.Equal(Both, Decide("v1.1.0", first, second, "[]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheTagCountsAsPublishedWhenTheListIsEmpty()
|
||||
{
|
||||
@@ -128,12 +141,39 @@ public sealed class ReleaseChannelsCommandTests(TestContext context)
|
||||
await Assert.ThrowsAsync<ToolException>(() => command.RunAsync(["--tag", "v1.0.0-rc.01", "--releases", file]));
|
||||
await Assert.ThrowsAsync<ToolException>(() => command.RunAsync(["--releases", file]));
|
||||
await Assert.ThrowsAsync<ToolException>(() => command.RunAsync(["--tag", "v1.0.0", "--releases", file + ".missing"]));
|
||||
// A sign-in page or an API error instead of the list.
|
||||
// Every page is read: a missing one is refused, not skipped.
|
||||
Assert.Equal(0, await command.RunAsync(["--tag", "v1.0.0", "--releases", file, "--releases", file]));
|
||||
await Assert.ThrowsAsync<ToolException>(() => command.RunAsync(["--tag", "v1.0.0", "--releases", file, "--releases", file + ".missing"]));
|
||||
// A sign-in page or an API error instead of the list, on any page.
|
||||
Assert.Throws<ToolException>(() => Decide("v1.0.0", "<html>Sign in</html>"));
|
||||
Assert.Throws<ToolException>(() => Decide("v1.0.0", """{"message":"not found"}"""));
|
||||
Assert.Throws<ToolException>(() => Decide("v1.0.0", "[]", """{"message":"not found"}"""));
|
||||
}
|
||||
|
||||
private static ReleaseChannels Decide(string tag, string releases) => ReleaseChannelsCommand.Decide(tag, releases);
|
||||
[Test]
|
||||
public void TheReleaseWorkflowRefusesTheTagsReleaseChannelsRefuses()
|
||||
{
|
||||
// release.yml checks the tag before building, so a tag release-channels would refuse never gets published.
|
||||
var lines = File.ReadAllLines(Path.Combine(Args.RepoRoot(), ".gitea", "workflows", "release.yml"))
|
||||
.Select(l => l.Trim()).Where(l => l.StartsWith("semver='", StringComparison.Ordinal) && l.EndsWith('\'')).ToList();
|
||||
Assert.Count(1, lines);
|
||||
var check = new Regex(lines[0]["semver='".Length..^1], RegexOptions.CultureInvariant);
|
||||
|
||||
string[] tags =
|
||||
[
|
||||
"v0.1.0", "v1.2.3", "v10.20.30", "v0.1.0-rc.1", "v1.0.0-alpha.beta", "v1.0.0-0", "v1.0.0-x-y.7z.92", "v1.0.0-rc.1+sha.5",
|
||||
"v1.0.0+build", "1.0.0", "V1.0.0", "v1.0", "v1.0.0.0", "v01.2.0", "v1.02.0", "v1.2.03", "v1.0.0-", "v1.0.0-rc.",
|
||||
"v1.0.0-rc..1", "v1.0.0-rc.01", "v1.0.0-rc_1", "latest",
|
||||
];
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
// Build metadata is refused by the workflow as well: an image tag cannot hold a "+".
|
||||
var expected = TagVersion.Parse(tag) is not null && !tag.Contains('+', StringComparison.Ordinal);
|
||||
Assert.Equal(expected, check.IsMatch(tag), tag);
|
||||
}
|
||||
}
|
||||
|
||||
private static ReleaseChannels Decide(string tag, params string[] releases) => ReleaseChannelsCommand.Decide(tag, releases);
|
||||
|
||||
private static string Releases(params string[] tags) => new JsonArray([.. tags.Select(t => Release(t))]).ToJsonString();
|
||||
|
||||
|
||||
Reference in new issue
Block a user