From 8672507fa444b0fa583a65801e8df77072bfd690 Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 19 Oct 2026 14:45:35 -0600 Subject: [PATCH] Preserve queued OS merge builds and guard reruns --- .gitea/workflows/main.yml | 2 ++ .gitea/workflows/next.yml | 4 --- .gitea/workflows/source-pr.yml | 2 ++ ci/test-version.py | 59 ++++++++++++++++++++++++++++++++++ ci/version.py | 7 ++++ 5 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 ci/test-version.py diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 4cb5b49..e049e47 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -38,6 +38,8 @@ jobs: run: python3 ci/test-conformance.py - name: Release publication checks run: python3 ci/test-release.py + - name: Release version checks + run: python3 ci/test-version.py - name: CI cleanup containment checks run: python3 ci/test-cleanup-generated.py - name: Quality diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index b9f7e80..1815d7a 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -4,10 +4,6 @@ on: push: branches: [next] -concurrency: - group: alkane-os-next - cancel-in-progress: false - jobs: build: runs-on: alkane-fast diff --git a/.gitea/workflows/source-pr.yml b/.gitea/workflows/source-pr.yml index 9ad6ffe..5701fea 100644 --- a/.gitea/workflows/source-pr.yml +++ b/.gitea/workflows/source-pr.yml @@ -22,6 +22,8 @@ jobs: run: rustup component add rustfmt - name: Check source formatting run: cargo fmt --check + - name: Check release numbering + run: python3 ci/test-version.py - name: Build source run: cargo build --release --offline --locked - name: Clean generated build diff --git a/ci/test-version.py b/ci/test-version.py new file mode 100644 index 0000000..3532380 --- /dev/null +++ b/ci/test-version.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Check candidate numbering and covered-commit reruns with real Git tags.""" + +from pathlib import Path +import subprocess +import tempfile + + +VERSION = Path(__file__).with_name("version.py") + + +def git(root: Path, *args: str) -> str: + result = subprocess.run( + ["git", *args], cwd=root, text=True, check=True, capture_output=True + ) + return result.stdout.strip() + + +def selected(root: Path, branch: str) -> dict[str, str]: + result = subprocess.run( + ["python3", str(VERSION), branch], cwd=root, + text=True, check=True, capture_output=True + ) + return dict(line.split("=", 1) for line in result.stdout.splitlines()) + + +def main() -> None: + with tempfile.TemporaryDirectory(prefix="alkane-os-version-") as path: + root = Path(path) + (root / "ci").mkdir() + (root / "ci/version-x.txt").write_text("0\n") + git(root, "init", "-q") + git(root, "config", "user.name", "Alkane CI") + git(root, "config", "user.email", "ci@example.invalid") + git(root, "add", ".") + git(root, "commit", "-qm", "First source") + first = git(root, "rev-parse", "HEAD") + assert selected(root, "next") == { + "release": "true", "tag": "v0.1.0-rc.1", "version": "0.1.0-rc.1" + } + git(root, "tag", "v0.1.0-rc.1") + assert selected(root, "next") == {"release": "false"} + + (root / "README.md").write_text("A later merge.\n") + git(root, "add", ".") + git(root, "commit", "-qm", "Later source") + assert selected(root, "next") == { + "release": "true", "tag": "v0.1.0-rc.2", "version": "0.1.0-rc.2" + } + git(root, "tag", "v0.1.0-rc.2") + assert selected(root, "next") == {"release": "false"} + git(root, "checkout", "-q", first) + assert selected(root, "next") == {"release": "false"} + print("PASS: exact and superseded candidate reruns do not publish") + + +if __name__ == "__main__": + main() diff --git a/ci/version.py b/ci/version.py index 4f66d5e..65703b1 100644 --- a/ci/version.py +++ b/ci/version.py @@ -27,6 +27,13 @@ def main(): parser.add_argument("branch", choices=("main", "next")) args = parser.parse_args() major = int(pathlib.Path("ci/version-x.txt").read_text().strip()) + # A rerun of a commit already covered by a published tag must not issue + # a newer candidate number for older source. + tagged_descendants = set(git("tag", "--contains", "HEAD", "-l", "v*").splitlines()) + known_tags = {tag for _, tag in versions("main") + versions("next")} + if tagged_descendants & known_tags: + print("release=false") + return finals = versions("main") previous = finals[-1] if finals else None if previous and previous[0][0] > major: -- 2.54.0