From 4b1d829b305dca2f0b6f07d7bd66806fea786f9d Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Sat, 21 Nov 2026 11:52:02 +0800 Subject: [PATCH 1/3] Schedule Saturday stable minors alongside daily patch previews Use a stable-to-stable comparison for weekly notes and the latest publication for race checks. Agent-assisted-by: Codex (implementation and release documentation) Signed-off-by: Zeng Chuang --- .github/workflows/release.yml | 32 +++++++++++++------ docs/release-notes/v0.3.0.md | 30 ++++++++++++++++++ docs/releases.md | 54 ++++++++++++++++----------------- tests/test_release.py | 44 ++++++++++++++++++++++++++- tests/test_release_publisher.py | 34 ++++++++++++++++----- tools/check_release.py | 47 ++++++++++++++++++++++------ 6 files changed, 188 insertions(+), 53 deletions(-) create mode 100644 docs/release-notes/v0.3.0.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 451f73eb4..d1b54fbb9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,14 @@ on: schedule: # 02:00 Asia/Shanghai every day. GitHub schedules can be delayed. - cron: "0 18 * * *" + # 10:00 Asia/Shanghai every Saturday. + - cron: "0 2 * * 6" workflow_dispatch: inputs: + weekly: + description: Plan the weekly stable minor release (default is a patch preview) + default: false + type: boolean release_v020: description: One-off formal v0.2.0 release (daily preview policy is unchanged) default: false @@ -37,6 +43,8 @@ jobs: prerelease: ${{ steps.plan.outputs.prerelease }} commit: ${{ steps.plan.outputs.commit }} previous_tag: ${{ steps.plan.outputs.previous_tag }} + notes_start_tag: ${{ steps.plan.outputs.notes_start_tag }} + reviewed_notes: ${{ steps.plan.outputs.reviewed_notes }} steps: - uses: actions/checkout@v4 with: @@ -46,18 +54,20 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" - - name: Plan only when the source tree changed since the last published release + - name: Plan the release for the triggering channel id: plan env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} RELEASE_V020: ${{ github.event_name == 'workflow_dispatch' && inputs.release_v020 }} + WEEKLY: ${{ github.event.schedule == '0 2 * * 6' || (github.event_name == 'workflow_dispatch' && inputs.weekly) }} shell: bash run: | gh api --paginate --slurp "repos/$GH_REPO/releases?per_page=100" > "$RUNNER_TEMP/releases.json" options=() if [[ "$RELEASE_V020" == true ]]; then options+=(--release-v020); fi + if [[ "$WEEKLY" == true ]]; then options+=(--weekly); fi python tools/check_release.py plan --default-branch "$DEFAULT_BRANCH" \ --releases "$RUNNER_TEMP/releases.json" "${options[@]}" >> "$GITHUB_OUTPUT" @@ -161,12 +171,13 @@ jobs: GH_REPO: ${{ github.repository }} RELEASE_TAG: ${{ needs.plan.outputs.tag }} RELEASE_COMMIT: ${{ needs.plan.outputs.commit }} - PREVIOUS_TAG: ${{ needs.plan.outputs.previous_tag }} + PREVIOUS_TAG: ${{ needs.plan.outputs.notes_start_tag }} + REVIEWED_NOTES: ${{ needs.plan.outputs.reviewed_notes }} shell: bash run: | - if [[ "$RELEASE_TAG" == v0.2.0 ]]; then + if [[ "$REVIEWED_NOTES" == true ]]; then mkdir -p "$RUNNER_TEMP/release-notes" - cp docs/release-notes/v0.2.0.md "$RUNNER_TEMP/release-notes/ai-notes.md" + cp "docs/release-notes/$RELEASE_TAG.md" "$RUNNER_TEMP/release-notes/ai-notes.md" else python tools/generate_release_notes.py --tag "$RELEASE_TAG" \ --commit "$RELEASE_COMMIT" --previous-tag "$PREVIOUS_TAG" \ @@ -205,6 +216,8 @@ jobs: RELEASE_TAG: ${{ needs.plan.outputs.tag }} RELEASE_COMMIT: ${{ needs.plan.outputs.commit }} PREVIOUS_TAG: ${{ needs.plan.outputs.previous_tag }} + NOTES_START_TAG: ${{ needs.plan.outputs.notes_start_tag }} + REVIEWED_NOTES: ${{ needs.plan.outputs.reviewed_notes }} PRERELEASE: ${{ needs.plan.outputs.prerelease }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} steps: @@ -216,6 +229,8 @@ jobs: [[ "$RELEASE_TAG" =~ $version_tag ]] [[ "$RELEASE_COMMIT" =~ ^[0-9a-f]{40}$ ]] [[ -z "$PREVIOUS_TAG" || "$PREVIOUS_TAG" =~ $version_tag ]] + [[ -z "$NOTES_START_TAG" || "$NOTES_START_TAG" =~ $version_tag ]] + [[ "$REVIEWED_NOTES" == true || "$REVIEWED_NOTES" == false ]] [[ "$PRERELEASE" == true || "$PRERELEASE" == false ]] - uses: actions/download-artifact@v4 with: @@ -252,7 +267,7 @@ jobs: env: AI_NOTES_DOWNLOADED: ${{ steps.download_notes.outcome }} run: | - if [[ "$RELEASE_TAG" == v0.2.0 ]]; then + if [[ "$REVIEWED_NOTES" == true ]]; then [[ "${AI_NOTES_DOWNLOADED:-}" == success && -f notes/ai-notes.md && ! -L notes/ai-notes.md ]] [[ "$(wc -c < notes/ai-notes.md)" -gt 0 && "$(wc -c < notes/ai-notes.md)" -le 20000 ]] fi @@ -264,8 +279,8 @@ jobs: printf '\nThese notes describe software changes. Release builds and scaffold checks do not establish campaign PASS, model quality or service performance. Any such claim requires its acceptance issue and complete frozen evidence.\n' if [[ "${AI_NOTES_DOWNLOADED:-}" == success && -f notes/ai-notes.md && ! -L notes/ai-notes.md ]] && [[ "$(wc -c < notes/ai-notes.md)" -gt 0 && "$(wc -c < notes/ai-notes.md)" -le 20000 ]]; then - if [[ "$RELEASE_TAG" == v0.2.0 ]]; then - printf '\n## Reviewed v0.2.0 highlights\n\n' + if [[ "$REVIEWED_NOTES" == true ]]; then + printf '\n## Reviewed %s highlights\n\n' "$RELEASE_TAG" else printf '\n## AI-generated summary\n\n' fi @@ -274,8 +289,7 @@ jobs: fi } > "$notes_file" options=() - if [[ "$RELEASE_TAG" == v0.2.0 ]]; then PREVIOUS_TAG=v0.1.1; fi - if [[ -n "$PREVIOUS_TAG" ]]; then options+=(--notes-start-tag "$PREVIOUS_TAG"); fi + if [[ -n "$NOTES_START_TAG" ]]; then options+=(--notes-start-tag "$NOTES_START_TAG"); fi gh release create "$RELEASE_TAG" dist/*.whl dist/*.tar.gz dist/*.zip dist/SHA256SUMS \ --verify-tag --draft --title "InferRSI $RELEASE_TAG" \ --generate-notes --notes-file "$notes_file" "${options[@]}" diff --git a/docs/release-notes/v0.3.0.md b/docs/release-notes/v0.3.0.md new file mode 100644 index 000000000..d7928dabc --- /dev/null +++ b/docs/release-notes/v0.3.0.md @@ -0,0 +1,30 @@ +# InferRSI v0.3.0 + +InferRSI v0.3.0 ties optimization decisions to measured bottlenecks. Teams can now run the same task with the knowledge library enabled and disabled, then compare the candidates that two independent agent sessions produce within the same budget. These highlights cover changes since v0.2.0. + +## Optimization and evaluation + +- **Diagnose the bottleneck before searching.** New managed optimization runs record a baseline profile or measurements from the same workload and environment before the agent searches for knowledge or evaluates a candidate. Each round links back to its diagnosis. Project campaigns can also start one service per candidate and use it for performance, quality and optional profiling checks. The selected candidate gets an independent final evaluation. [Diagnosis](https://github.com/InferMatrixLab/InferRSI/pull/519) · [Service reuse](https://github.com/InferMatrixLab/InferRSI/pull/480) · [Optional profiling](https://github.com/InferMatrixLab/InferRSI/pull/521) +- **Measure what the knowledge library contributes.** `inferrsi benchmarks compare` runs independent optimization sessions with managed knowledge on and off under the same task, evaluation rules and round budget. It defaults to Qwen-Image 2.1 denoising and MoE forward on Ascend. The report pairs final speedup with elapsed optimization time and flags missing or invalid pairs as insufficient evidence. [Comparison guide](https://github.com/InferMatrixLab/InferRSI/blob/6ed42af83a69f13fe88aaf0426ab8ef4f8ac7654/docs/benchmark-comparison.md) + +## Knowledge and results + +- **Start from the engineering task.** Seven entry points cover model bring-up, performance, debugging, accuracy, version alignment, derived engines and independent engines. Search spans skills, cases and engineering findings. With CANNBot enabled, the dashboard shows its search and read records alongside local retrieval and identifies the sources the agent explicitly cited in each round. [Task routes](https://github.com/InferMatrixLab/InferRSI/pull/516) · [CANNBot tracing](https://github.com/InferMatrixLab/InferRSI/pull/523) +- **Review and share a run.** The dashboard connects performance trends to individual rounds, candidate choices and execution results. `inferrsi export` writes a Markdown report, offline HTML, a machine-readable result and an artifact index from the same snapshot. Keep the original campaign directory for the code and evidence referenced by the export. [Round view](https://github.com/InferMatrixLab/InferRSI/pull/495) · [Result export](https://github.com/InferMatrixLab/InferRSI/pull/485) +- **Revisit earlier experiments.** Versioned archives preserve the original trial records for H3 Ref2VA, Qwen3.8 and MiniCPM Seed-TTS. The repository keeps compact evidence bundles with checksums, so reviewers can inspect individual trials and their original verdicts. [H3 and Qwen3.8 archives](https://github.com/InferMatrixLab/InferRSI/pull/472) · [MiniCPM Seed-TTS archive](https://github.com/InferMatrixLab/InferRSI/pull/435) + +## Upgrading from v0.2.x + +The `inferrsi` command and `python -m inferrsi` remain the CLI entry points. Apps now brings together the CLI, integrations and reports. Harness runs experiments, Benchmark owns tasks and evaluation rules, and Knowledge supplies skills and findings. Python integrations that import the retired `inferrsi.infra` or `inferrsi.model` packages need to update those imports. [CLI migration](https://github.com/InferMatrixLab/InferRSI/pull/461) · [Full module migration details](https://github.com/InferMatrixLab/InferRSI/blob/6ed42af83a69f13fe88aaf0426ab8ef4f8ac7654/CHANGELOG.md) + +| Previous import | v0.3.0 import | +| --- | --- | +| `inferrsi.cli` | `inferrsi.apps.cli` | +| `inferrsi.infra.artifacts` | `inferrsi.apps.artifacts` | +| `inferrsi.infra.http` | `inferrsi.harness.serving.http` | +| `inferrsi.model.protocols.metrics` | `inferrsi.benchmark.metrics` | +| `inferrsi.model.validators` | `inferrsi.benchmark.validators` | + +**Keep the original runtime for in-flight sessions.** A frozen plan records the runtime that created it. Use that environment for `status` and `recover`. Start a fresh session to run under v0.3.0. [Session recovery guide](https://github.com/InferMatrixLab/InferRSI/blob/6ed42af83a69f13fe88aaf0426ab8ef4f8ac7654/docs/optimization-workflow-unification.md#release-boundary-recovery) + +[Full comparison from v0.2.0 to v0.3.0](https://github.com/InferMatrixLab/InferRSI/compare/v0.2.0...v0.3.0) diff --git a/docs/releases.md b/docs/releases.md index 138137ef8..0d6d6ecaf 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -1,22 +1,23 @@ -# Automatic daily releases - -The [release bot](../.github/workflows/release.yml) runs every day at **02:00 -Asia/Shanghai** (18:00 UTC). GitHub schedules can be delayed. If the default -branch's source tree is unchanged from the highest successfully published numeric -version, it skips the release. Empty commits do not cause a release. - -When changed, the bot chooses a version, builds and checks the packages, creates -the tag and publishes the GitHub Release as `github-actions[bot]`. There is no -manual version bump, tag push or draft publication step. The first release uses -`tool.inferrsi.release.initial_version` in `pyproject.toml` (initially `0.1.0`); -subsequent releases allocate the next unused numeric patch version. Major/minor -releases need a separately reviewed change to that initial-version floor. - -The existing **Developer Preview** classification is preserved: -`tool.inferrsi.release.prerelease = true` marks automatic releases as GitHub -prereleases and does not mark them Latest. Changing to a stable channel is a -separately reviewed configuration decision. Published previews count as -successful releases for no-change detection; private drafts do not. +# Daily previews and weekly stable releases + +The [release bot](../.github/workflows/release.yml) runs on the default branch. +Both schedules use Asia/Shanghai time. GitHub may delay a scheduled run. + +| Schedule | Version | Changes since | GitHub designation | +| --- | --- | --- | --- | +| Every day at 02:00 (18:00 UTC the previous day) | Next patch, e.g. v0.3.1 | Latest published numeric release | Pre-release | +| Saturday at 10:00 (02:00 UTC Saturday) | Next minor, e.g. v0.3.0, then v0.4.0 | Latest published numeric stable release | Latest | + +Saturday runs both channels. Each skips an unchanged source tree against its own +baseline. A preview can therefore become stable on the same commit. A published +stable release also satisfies the current Saturday-to-Friday window on retries. +Drafts and reserved tags consume version numbers. Evidence archive tags are +outside the numeric sequence. Both channels build and validate packages before +publication. A stable release uses reviewed highlights from +`docs/release-notes/.md` when present. Otherwise the notes job generates a +summary from the channel baseline. GitHub's generated changelog covers that +same range. The publisher checks for races against the latest publication +across both channels. ## Authority boundary @@ -81,7 +82,7 @@ configuration does not silently change their access or existing branch rules. All source-tree changes, including documentation, are eligible. The [notes configuration](../.github/release.yml) groups existing `enhancement`, `bug` and `documentation` labels and includes other merged PRs. Notes use the -previous published tag rather than incomplete reserved tags. A release describes +channel's previous published tag. A release describes software changes; CPU/package checks do not establish campaign `PASS`, model quality or service performance. Such claims retain the acceptance and evidence requirements in [contributing](contributing.md#evidence-and-claims). @@ -173,7 +174,9 @@ guard. Under **Actions → Release bot → Run workflow**, select the default branch and leave **dry_run** checked. It plans and builds the next release without creating -a remote tag or Release; unchanged trees skip here too. With `DS_API_KEY` +a remote tag or Release. Select **weekly** to exercise the stable path. Both +channels apply their normal skip rules. +With `DS_API_KEY` configured, a changed-source dry run also makes the AI request and uploads the summary artifact for inspection, consuming API usage. Clearing **dry_run** runs the same automatic publication immediately. It takes no version/tag input. @@ -226,7 +229,7 @@ and [publication CLI](https://cli.github.com/manual/gh_release_edit), plus the Remote scheduled execution, repository policy and actual publication remain unverified until observed in an actual release run. -## One-off formal v0.2.0 +## Historical one-off formal v0.2.0 The existing workflow accepts `release_v020=true` only through manual dispatch. It plans exactly v0.2.0 with `prerelease=false`, rejects any already reserved @@ -242,8 +245,5 @@ check still uses the actual latest release, not that historical notes baseline. This one-off notes path does not call the model API. Wheel, sdist, Codex ZIP, WorkSwarm ZIP and SHA256SUMS remain bound to the planned source commit. -Scheduled dispatch and ordinary manual runs keep the existing pyproject defaults. -After v0.2.0 is published, the unchanged semantic patch planner naturally selects -v0.2.1 as a preview when source changes; this does not retain the v0.1.x numbering -line or turn future releases stable. A failed reserved v0.2.0 is not overwritten -or silently replaced: investigate and obtain a new release decision. +The daily patch planner continued with v0.2.1 after this promotion. +The recurring Saturday channel now handles subsequent minor releases. diff --git a/tests/test_release.py b/tests/test_release.py index d71b01afb..182e41983 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -2,6 +2,7 @@ import shlex import subprocess import tarfile +from datetime import datetime, timezone from pathlib import Path import pytest @@ -81,7 +82,7 @@ def test_bootstrap_without_existing_tags(release_repo): assert plan == {"release": "true", "tag": "v0.1.0", "version": "0.1.0", "prerelease": "true", "commit": release_repo("rev-parse", "HEAD"), - "previous_tag": ""} + "previous_tag": "", "notes_start_tag": ""} @pytest.mark.parametrize("empty_commit", [False, True]) @@ -211,3 +212,44 @@ def test_one_off_can_promote_unchanged_preview_tree(release_repo): def test_one_off_requires_notes_baseline(release_repo): with pytest.raises(subprocess.CalledProcessError): plan_release("main", [], "0.1.0", release_v020=True) + + +def test_saturday_promotes_daily_preview_and_next_day_continues(release_repo): + git = release_repo + git("tag", "v0.2.0") + change_source(git) + git("tag", "v0.2.6") + releases = [ + dict(published("v0.2.0"), published_at="2026-11-13T02:00:00Z"), + published("v0.2.6", prerelease=True), + published("evidence-v1"), + ] + saturday = datetime(2026, 11, 21, 2, tzinfo=timezone.utc) + assert plan_release("main", releases, "0.1.0") == {"release": "false"} + weekly = plan_release("main", releases, "0.1.0", weekly=True, now=saturday) + assert (weekly["tag"], weekly["prerelease"]) == ("v0.3.0", "false") + assert (weekly["previous_tag"], weekly["notes_start_tag"]) == ("v0.2.6", "v0.2.0") + git("tag", "v0.3.0") + releases.append(dict(published("v0.3.0"), published_at="2026-11-21T02:25:00Z")) + next_saturday = datetime(2026, 11, 28, 2, tzinfo=timezone.utc) + assert plan_release("main", releases, "0.1.0", weekly=True, now=next_saturday) == { + "release": "false"} + Path("next").write_text("new source") + git("add", "next") + git("commit", "-m", "further change") + git("update-ref", "refs/remotes/origin/main", "HEAD") + assert plan_release("main", releases, "0.1.0", weekly=True, now=saturday) == { + "release": "false"} + daily = plan_release("main", releases, "0.1.0") + assert (daily["tag"], daily["prerelease"], daily["notes_start_tag"]) == ( + "v0.3.1", "true", "v0.3.0") + assert plan_release("main", releases, "0.1.0", weekly=True, now=next_saturday)["tag"] == ( + "v0.4.0") + + +def test_first_stable_respects_reservations_and_ignores_drafts_as_baselines(release_repo): + release_repo("tag", "v0.2.6") + releases = [published("v0.2.6", prerelease=True), published("v0.3.0", draft=True)] + plan = plan_release("main", releases, "0.1.0", weekly=True) + assert (plan["tag"], plan["previous_tag"], plan["notes_start_tag"]) == ( + "v0.4.0", "v0.2.6", "") diff --git a/tests/test_release_publisher.py b/tests/test_release_publisher.py index 5fd6ba0d4..b3c2c7af9 100644 --- a/tests/test_release_publisher.py +++ b/tests/test_release_publisher.py @@ -138,10 +138,12 @@ def publisher(tmp_path, request): mock_bin.mkdir() gh = mock_bin / "gh" mock = MOCK_GH.replace("1.2.3", release_tag[1:]).replace("v1.2.2", previous_tag) - if release_tag == "v0.2.0": - mock = mock.replace("## AI-generated summary", "## Reviewed v0.2.0 highlights") + reviewed = release_tag in {"v0.2.0", "v0.3.0"} + notes_start = {"v0.2.0": "v0.1.1", "v0.3.0": "v0.2.0"}.get(release_tag, previous_tag) + if reviewed: + mock = mock.replace("## AI-generated summary", f"## Reviewed {release_tag} highlights") mock = mock.replace('record("create_release")', - 'assert args[args.index("--notes-start-tag") + 1] == "v0.1.1"\n' + f'assert args[args.index("--notes-start-tag") + 1] == "{notes_start}"\n' ' record("create_release")') gh.write_text(mock, encoding="utf-8", newline="\n") gh.chmod(0o755) @@ -182,6 +184,7 @@ def run(state=None, **inputs): RUNNER_TEMP=str(tmp_path), GH_TOKEN="fake-no-access", GH_REPO="example/release", DEFAULT_BRANCH="main", RELEASE_TAG=release_tag, RELEASE_COMMIT=COMMIT, PREVIOUS_TAG=previous_tag, + NOTES_START_TAG=notes_start, REVIEWED_NOTES=str(reviewed).lower(), PRERELEASE="true") env.update(inputs) env["AI_NOTES_DOWNLOADED"] = ( @@ -265,9 +268,9 @@ def test_incomplete_or_retargeted_release_cannot_be_published(publisher, state): ] -@pytest.mark.parametrize("publisher", ["v0.2.0"], indirect=True) -def test_one_off_publishes_reviewed_notes_with_historical_baseline(publisher, tmp_path): - result, mutations = publisher({"ai_summary": "Reviewed highlights since v0.1.1"}, +@pytest.mark.parametrize("publisher", ["v0.2.0", "v0.3.0"], indirect=True) +def test_stable_publishes_reviewed_notes_with_stable_baseline(publisher, tmp_path): + result, mutations = publisher({"ai_summary": "Reviewed highlights"}, PRERELEASE="false") assert result.returncode == 0, result.stderr assert mutations[-1] == {"operation": "publish_release"} @@ -277,7 +280,7 @@ def test_one_off_publishes_reviewed_notes_with_historical_baseline(publisher, tm assert "--prerelease=false" in edits[-1] and "--latest" in edits[-1] -@pytest.mark.parametrize("publisher", ["v0.2.0"], indirect=True) +@pytest.mark.parametrize("publisher", ["v0.2.0", "v0.3.0"], indirect=True) @pytest.mark.parametrize("state", [None, {"ai_summary": "x", "failed_notes_download": True}, {"ai_summary": "x" * 20001}]) def test_one_off_missing_reviewed_notes_blocks_before_tag(publisher, state): @@ -294,3 +297,20 @@ def test_one_off_dispatch_is_opt_in_and_schedule_cannot_select_it(): assert "github.event_name == 'workflow_dispatch' && inputs.release_v020" in ( step["env"]["RELEASE_V020"]) assert '"${options[@]}"' in step["run"] + + +def test_weekly_and_daily_channels_use_the_same_serialized_publisher(): + config = workflow() + triggers = config.get("on", config.get(True)) + assert triggers["schedule"] == [{"cron": "0 18 * * *"}, {"cron": "0 2 * * 6"}] + assert triggers["workflow_dispatch"]["inputs"]["weekly"]["default"] is False + job = config["jobs"]["plan"] + step = next(step for step in job["steps"] if step.get("id") == "plan") + assert "github.event.schedule == '0 2 * * 6'" in step["env"]["WEEKLY"] + assert 'if [[ "$WEEKLY" == true ]]; then options+=(--weekly); fi' in step["run"] + assert config["concurrency"] == {"group": "release-bot", "cancel-in-progress": False} + notes = next(s for s in config["jobs"]["notes"]["steps"] if s.get("id") == "notes") + assert notes["env"]["PREVIOUS_TAG"] == "${{ needs.plan.outputs.notes_start_tag }}" + publisher = config["jobs"]["publish"]["env"] + assert publisher["PREVIOUS_TAG"] == "${{ needs.plan.outputs.previous_tag }}" + assert publisher["NOTES_START_TAG"] == notes["env"]["PREVIOUS_TAG"] diff --git a/tools/check_release.py b/tools/check_release.py index f976f938a..536e4698a 100644 --- a/tools/check_release.py +++ b/tools/check_release.py @@ -1,4 +1,4 @@ -"""Plan daily versioned releases and validate their packages without publishing.""" +"""Plan daily previews and weekly stable releases and validate their packages.""" import argparse import ast @@ -13,6 +13,7 @@ import tarfile import tempfile import zipfile +from datetime import datetime, timedelta, timezone from pathlib import Path, PurePosixPath @@ -32,9 +33,12 @@ def git(*args: str) -> str: def plan_release(default_branch: str, releases: list[dict], initial_version: str, - prerelease: bool = True, *, release_v020: bool = False) -> dict: + prerelease: bool = True, *, release_v020: bool = False, + weekly: bool = False, now: datetime | None = None) -> dict: if type(prerelease) is not bool: raise ValueError("Release prerelease setting must be a boolean") + if release_v020 and weekly: + raise ValueError("Choose a single release channel") initial = version_tuple(f"v{initial_version}") source = git("rev-parse", "--verify", f"refs/remotes/origin/{default_branch}^{{commit}}") stable = {} @@ -44,6 +48,11 @@ def plan_release(default_branch: str, releases: list[dict], initial_version: str except ValueError: continue published = [] + published_stable = [] + if weekly: + shanghai = timezone(timedelta(hours=8)) + today = (now or datetime.now(shanghai)).astimezone(shanghai).date() + saturday = today - timedelta(days=(today.weekday() - 5) % 7) reserved = [] for release in releases: tag = release["tag_name"] @@ -54,6 +63,12 @@ def plan_release(default_branch: str, releases: list[dict], initial_version: str reserved.append(value) if release["draft"] is False: published.append((value, tag)) + if release["prerelease"] is False: + published_stable.append((value, tag)) + if weekly: + stamp = datetime.fromisoformat(release["published_at"].replace("Z", "+00:00")) + if stamp.astimezone(shanghai).date() >= saturday: + return {"release": "false"} if release_v020: baseline = git("rev-parse", "--verify", "refs/tags/v0.1.1^{commit}") subprocess.run(["git", "merge-base", "--is-ancestor", baseline, source], @@ -63,26 +78,33 @@ def plan_release(default_branch: str, releases: list[dict], initial_version: str raise ValueError("One-off v0.2.0 requires an unused target newer than " "every reserved version") previous_tag = max(published)[1] if published else "" - if previous_tag: - previous = git("rev-parse", "--verify", f"refs/tags/{previous_tag}^{{commit}}") + notes_start_tag = previous_tag + if weekly: + notes_start_tag = max(published_stable)[1] if published_stable else "" + elif release_v020: + notes_start_tag = "v0.1.1" + for tag in dict.fromkeys(filter(None, (previous_tag, notes_start_tag))): + previous = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}") subprocess.run(["git", "merge-base", "--is-ancestor", previous, source], check=True, capture_output=True) - if (not release_v020 and + if (tag == notes_start_tag and not release_v020 and git("rev-parse", f"{previous}^{{tree}}") == git("rev-parse", f"{source}^{{tree}}")): return {"release": "false"} used = [*stable.values(), *reserved] if used: major, minor, patch = max(used) - version = max(initial, (major, minor, patch + 1)) + next_version = (major, minor + 1, 0) if weekly else (major, minor, patch + 1) + version = max(initial, next_version) else: version = initial if release_v020: version = (0, 2, 0) + if release_v020 or weekly: prerelease = False return {"release": "true", "tag": "v" + ".".join(map(str, version)), "version": ".".join(map(str, version)), "prerelease": str(prerelease).lower(), - "commit": source, "previous_tag": previous_tag} + "commit": source, "previous_tag": previous_tag, "notes_start_tag": notes_start_tag} def check_versions(tag: str, distribution: str, runtime: str) -> None: @@ -255,7 +277,9 @@ def main() -> None: plan = commands.add_parser("plan") plan.add_argument("--default-branch", required=True) plan.add_argument("--releases", type=Path, required=True) - plan.add_argument("--release-v020", action="store_true") + channels = plan.add_mutually_exclusive_group() + channels.add_argument("--release-v020", action="store_true") + channels.add_argument("--weekly", action="store_true") installed = commands.add_parser("installed") installed.add_argument("--tag", required=True) sdist = commands.add_parser("sdist") @@ -276,7 +300,12 @@ def main() -> None: settings = config["tool"]["inferrsi"]["release"] result = plan_release(args.default_branch, releases, settings["initial_version"], settings["prerelease"], - release_v020=args.release_v020) + release_v020=args.release_v020, weekly=args.weekly) + if result["release"] == "true": + path = f"docs/release-notes/{result['tag']}.md" + curated = result["prerelease"] == "false" and bool( + git("ls-tree", "--name-only", result["commit"], "--", path)) + result["reviewed_notes"] = str(curated or args.release_v020).lower() for key, value in result.items(): print(f"{key}={value}") elif args.command == "sdist": From 050b9fc06aad7c9181e556e79f065526512173d1 Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Sat, 21 Nov 2026 12:21:19 +0800 Subject: [PATCH 2/3] Move weekly stable releases to Sunday at 08:00 Shanghai time Start the weekly deduplication window on Sunday and cover both sides of the local week boundary. Agent-assisted-by: Codex (implementation and tests) Signed-off-by: Zeng Chuang --- .github/workflows/release.yml | 6 +++--- docs/releases.md | 8 ++++---- tests/test_release.py | 22 +++++++++++++--------- tests/test_release_publisher.py | 4 ++-- tools/check_release.py | 4 ++-- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1b54fbb9..67c09767b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,8 @@ on: schedule: # 02:00 Asia/Shanghai every day. GitHub schedules can be delayed. - cron: "0 18 * * *" - # 10:00 Asia/Shanghai every Saturday. - - cron: "0 2 * * 6" + # 08:00 Asia/Shanghai every Sunday (00:00 UTC). + - cron: "0 0 * * 0" workflow_dispatch: inputs: weekly: @@ -61,7 +61,7 @@ jobs: GH_REPO: ${{ github.repository }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} RELEASE_V020: ${{ github.event_name == 'workflow_dispatch' && inputs.release_v020 }} - WEEKLY: ${{ github.event.schedule == '0 2 * * 6' || (github.event_name == 'workflow_dispatch' && inputs.weekly) }} + WEEKLY: ${{ github.event.schedule == '0 0 * * 0' || (github.event_name == 'workflow_dispatch' && inputs.weekly) }} shell: bash run: | gh api --paginate --slurp "repos/$GH_REPO/releases?per_page=100" > "$RUNNER_TEMP/releases.json" diff --git a/docs/releases.md b/docs/releases.md index 0d6d6ecaf..30016b6d3 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -6,11 +6,11 @@ Both schedules use Asia/Shanghai time. GitHub may delay a scheduled run. | Schedule | Version | Changes since | GitHub designation | | --- | --- | --- | --- | | Every day at 02:00 (18:00 UTC the previous day) | Next patch, e.g. v0.3.1 | Latest published numeric release | Pre-release | -| Saturday at 10:00 (02:00 UTC Saturday) | Next minor, e.g. v0.3.0, then v0.4.0 | Latest published numeric stable release | Latest | +| Sunday at 08:00 (00:00 UTC Sunday) | Next minor, e.g. v0.3.0, then v0.4.0 | Latest published numeric stable release | Latest | -Saturday runs both channels. Each skips an unchanged source tree against its own +Sunday runs both channels. Each skips an unchanged source tree against its own baseline. A preview can therefore become stable on the same commit. A published -stable release also satisfies the current Saturday-to-Friday window on retries. +stable release also satisfies the current Sunday-to-Saturday window on retries. Drafts and reserved tags consume version numbers. Evidence archive tags are outside the numeric sequence. Both channels build and validate packages before publication. A stable release uses reviewed highlights from @@ -246,4 +246,4 @@ This one-off notes path does not call the model API. Wheel, sdist, Codex ZIP, WorkSwarm ZIP and SHA256SUMS remain bound to the planned source commit. The daily patch planner continued with v0.2.1 after this promotion. -The recurring Saturday channel now handles subsequent minor releases. +The recurring Sunday channel now handles subsequent minor releases. diff --git a/tests/test_release.py b/tests/test_release.py index 182e41983..a9a252550 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -214,36 +214,40 @@ def test_one_off_requires_notes_baseline(release_repo): plan_release("main", [], "0.1.0", release_v020=True) -def test_saturday_promotes_daily_preview_and_next_day_continues(release_repo): +def test_sunday_promotes_daily_preview_and_next_day_continues(release_repo): git = release_repo git("tag", "v0.2.0") change_source(git) git("tag", "v0.2.6") releases = [ - dict(published("v0.2.0"), published_at="2026-11-13T02:00:00Z"), + dict(published("v0.2.0"), published_at="2026-11-21T15:59:00Z"), published("v0.2.6", prerelease=True), published("evidence-v1"), ] - saturday = datetime(2026, 11, 21, 2, tzinfo=timezone.utc) + sunday = datetime(2026, 11, 22, 0, tzinfo=timezone.utc) assert plan_release("main", releases, "0.1.0") == {"release": "false"} - weekly = plan_release("main", releases, "0.1.0", weekly=True, now=saturday) + weekly = plan_release("main", releases, "0.1.0", weekly=True, now=sunday) assert (weekly["tag"], weekly["prerelease"]) == ("v0.3.0", "false") assert (weekly["previous_tag"], weekly["notes_start_tag"]) == ("v0.2.6", "v0.2.0") git("tag", "v0.3.0") - releases.append(dict(published("v0.3.0"), published_at="2026-11-21T02:25:00Z")) - next_saturday = datetime(2026, 11, 28, 2, tzinfo=timezone.utc) - assert plan_release("main", releases, "0.1.0", weekly=True, now=next_saturday) == { + releases.append(dict(published("v0.3.0"), published_at="2026-11-22T00:25:00Z")) + next_sunday = datetime(2026, 11, 29, 0, tzinfo=timezone.utc) + assert plan_release("main", releases, "0.1.0", weekly=True, now=next_sunday) == { "release": "false"} Path("next").write_text("new source") git("add", "next") git("commit", "-m", "further change") git("update-ref", "refs/remotes/origin/main", "HEAD") - assert plan_release("main", releases, "0.1.0", weekly=True, now=saturday) == { + assert plan_release("main", releases, "0.1.0", weekly=True, now=sunday) == { + "release": "false"} + # Saturday 23:59 in Shanghai is still in the same release week. + end_of_week = datetime(2026, 11, 28, 15, 59, tzinfo=timezone.utc) + assert plan_release("main", releases, "0.1.0", weekly=True, now=end_of_week) == { "release": "false"} daily = plan_release("main", releases, "0.1.0") assert (daily["tag"], daily["prerelease"], daily["notes_start_tag"]) == ( "v0.3.1", "true", "v0.3.0") - assert plan_release("main", releases, "0.1.0", weekly=True, now=next_saturday)["tag"] == ( + assert plan_release("main", releases, "0.1.0", weekly=True, now=next_sunday)["tag"] == ( "v0.4.0") diff --git a/tests/test_release_publisher.py b/tests/test_release_publisher.py index b3c2c7af9..5fb167d1b 100644 --- a/tests/test_release_publisher.py +++ b/tests/test_release_publisher.py @@ -302,11 +302,11 @@ def test_one_off_dispatch_is_opt_in_and_schedule_cannot_select_it(): def test_weekly_and_daily_channels_use_the_same_serialized_publisher(): config = workflow() triggers = config.get("on", config.get(True)) - assert triggers["schedule"] == [{"cron": "0 18 * * *"}, {"cron": "0 2 * * 6"}] + assert triggers["schedule"] == [{"cron": "0 18 * * *"}, {"cron": "0 0 * * 0"}] assert triggers["workflow_dispatch"]["inputs"]["weekly"]["default"] is False job = config["jobs"]["plan"] step = next(step for step in job["steps"] if step.get("id") == "plan") - assert "github.event.schedule == '0 2 * * 6'" in step["env"]["WEEKLY"] + assert "github.event.schedule == '0 0 * * 0'" in step["env"]["WEEKLY"] assert 'if [[ "$WEEKLY" == true ]]; then options+=(--weekly); fi' in step["run"] assert config["concurrency"] == {"group": "release-bot", "cancel-in-progress": False} notes = next(s for s in config["jobs"]["notes"]["steps"] if s.get("id") == "notes") diff --git a/tools/check_release.py b/tools/check_release.py index 536e4698a..511c9ca57 100644 --- a/tools/check_release.py +++ b/tools/check_release.py @@ -52,7 +52,7 @@ def plan_release(default_branch: str, releases: list[dict], initial_version: str if weekly: shanghai = timezone(timedelta(hours=8)) today = (now or datetime.now(shanghai)).astimezone(shanghai).date() - saturday = today - timedelta(days=(today.weekday() - 5) % 7) + sunday = today - timedelta(days=today.isoweekday() % 7) reserved = [] for release in releases: tag = release["tag_name"] @@ -67,7 +67,7 @@ def plan_release(default_branch: str, releases: list[dict], initial_version: str published_stable.append((value, tag)) if weekly: stamp = datetime.fromisoformat(release["published_at"].replace("Z", "+00:00")) - if stamp.astimezone(shanghai).date() >= saturday: + if stamp.astimezone(shanghai).date() >= sunday: return {"release": "false"} if release_v020: baseline = git("rev-parse", "--verify", "refs/tags/v0.1.1^{commit}") From 880bc080c2d0322863e14ca7a8eb53e78efbe8ea Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Sat, 21 Nov 2026 18:23:00 +0800 Subject: [PATCH 3/3] Gate weekly publication on rehearsal and recheck the stable baseline Cover the Sunday preview before promotion, channel-specific publication races, and dry-run eligibility. Document the rollout and one-off recovery. Agent-assisted-by: Codex (implementation and review fixes) Signed-off-by: Zeng Chuang --- .github/workflows/release.yml | 29 +++++++++++++++-- docs/releases.md | 34 +++++++++++++------- tests/test_release.py | 9 ++++-- tests/test_release_publisher.py | 55 +++++++++++++++++++++++++++++++-- 4 files changed, 107 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67c09767b..a2f4db8b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,6 +45,7 @@ jobs: previous_tag: ${{ steps.plan.outputs.previous_tag }} notes_start_tag: ${{ steps.plan.outputs.notes_start_tag }} reviewed_notes: ${{ steps.plan.outputs.reviewed_notes }} + weekly: ${{ steps.plan.outputs.weekly }} steps: - uses: actions/checkout@v4 with: @@ -62,14 +63,25 @@ jobs: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} RELEASE_V020: ${{ github.event_name == 'workflow_dispatch' && inputs.release_v020 }} WEEKLY: ${{ github.event.schedule == '0 0 * * 0' || (github.event_name == 'workflow_dispatch' && inputs.weekly) }} + WEEKLY_ENABLED: ${{ vars.INFERRSI_WEEKLY_RELEASE_ENABLED }} + DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }} shell: bash run: | + echo "weekly=$WEEKLY" >> "$GITHUB_OUTPUT" + if [[ "$WEEKLY" == true && "$WEEKLY_ENABLED" != true && "$DRY_RUN" != true ]]; then + echo "::notice::Weekly publication is disabled pending the default-branch dry run." + echo "release=false" >> "$GITHUB_OUTPUT" + exit 0 + fi gh api --paginate --slurp "repos/$GH_REPO/releases?per_page=100" > "$RUNNER_TEMP/releases.json" options=() if [[ "$RELEASE_V020" == true ]]; then options+=(--release-v020); fi if [[ "$WEEKLY" == true ]]; then options+=(--weekly); fi python tools/check_release.py plan --default-branch "$DEFAULT_BRANCH" \ --releases "$RUNNER_TEMP/releases.json" "${options[@]}" >> "$GITHUB_OUTPUT" + if grep -Fxq 'release=false' "$GITHUB_OUTPUT"; then + echo "::notice::No release due for this channel." + fi build: needs: plan @@ -219,6 +231,7 @@ jobs: NOTES_START_TAG: ${{ needs.plan.outputs.notes_start_tag }} REVIEWED_NOTES: ${{ needs.plan.outputs.reviewed_notes }} PRERELEASE: ${{ needs.plan.outputs.prerelease }} + WEEKLY: ${{ needs.plan.outputs.weekly }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} steps: # The write job never checks out or executes repository/build code. @@ -232,6 +245,8 @@ jobs: [[ -z "$NOTES_START_TAG" || "$NOTES_START_TAG" =~ $version_tag ]] [[ "$REVIEWED_NOTES" == true || "$REVIEWED_NOTES" == false ]] [[ "$PRERELEASE" == true || "$PRERELEASE" == false ]] + [[ "$WEEKLY" == true || "$WEEKLY" == false ]] + [[ "$WEEKLY" == false || "$PRERELEASE" == false ]] - uses: actions/download-artifact@v4 with: name: release-distributions @@ -259,9 +274,17 @@ jobs: echo "::error::Release already exists; no tags or assets will be overwritten." exit 1 fi - published=$(jq -r '.[][] | select(.draft == false) | .tag_name | select(test("^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"))' <<< "$releases") - latest=$(printf '%s\n' "$published" | sort -V | tail -n 1) - [[ "$latest" == "$PREVIOUS_TAG" ]] + version_tag='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' + published=$(jq -r --arg pattern "$version_tag" '.[][] | select(.draft == false and (.tag_name | test($pattern))) | [.tag_name, .prerelease] | @tsv' <<< "$releases") + if [[ "$WEEKLY" == true ]]; then + latest_stable=$(awk '$2 == "false" {print $1}' <<< "$published" | sort -V | tail -n 1) + [[ "$latest_stable" == "$NOTES_START_TAG" ]] + newest=$( { cut -f1 <<< "$published"; echo "$RELEASE_TAG"; } | sort -V | tail -n 1) + [[ "$newest" == "$RELEASE_TAG" ]] + else + latest=$(cut -f1 <<< "$published" | sort -V | tail -n 1) + [[ "$latest" == "$PREVIOUS_TAG" ]] + fi - name: Create the remote tag, upload packages, then publish shell: bash env: diff --git a/docs/releases.md b/docs/releases.md index 30016b6d3..c16ee398e 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -8,7 +8,7 @@ Both schedules use Asia/Shanghai time. GitHub may delay a scheduled run. | Every day at 02:00 (18:00 UTC the previous day) | Next patch, e.g. v0.3.1 | Latest published numeric release | Pre-release | | Sunday at 08:00 (00:00 UTC Sunday) | Next minor, e.g. v0.3.0, then v0.4.0 | Latest published numeric stable release | Latest | -Sunday runs both channels. Each skips an unchanged source tree against its own +After weekly activation, Sunday runs both channels. Each skips an unchanged source tree against its own baseline. A preview can therefore become stable on the same commit. A published stable release also satisfies the current Sunday-to-Saturday window on retries. Drafts and reserved tags consume version numbers. Evidence archive tags are @@ -16,8 +16,11 @@ outside the numeric sequence. Both channels build and validate packages before publication. A stable release uses reviewed highlights from `docs/release-notes/.md` when present. Otherwise the notes job generates a summary from the channel baseline. GitHub's generated changelog covers that -same range. The publisher checks for races against the latest publication -across both channels. +same range. The daily publisher checks that the latest numeric release still +matches its plan. The weekly publisher checks that its stable baseline is +current and that its target is still the newest eligible version. An intervening +preview below that target can still precede the weekly release. A mid-week +hotfix reaches preview first and is eligible for stable on Sunday. ## Authority boundary @@ -173,17 +176,22 @@ repository and default branch; copies must deliberately update that repository guard. Under **Actions → Release bot → Run workflow**, select the default branch and -leave **dry_run** checked. It plans and builds the next release without creating -a remote tag or Release. Select **weekly** to exercise the stable path. Both -channels apply their normal skip rules. -With `DS_API_KEY` -configured, a changed-source dry run also makes the AI request and uploads the -summary artifact for inspection, consuming API usage. Clearing **dry_run** -runs the same automatic publication immediately. It takes no version/tag input. +leave **dry_run** checked. Select **weekly** to rehearse the stable path. +If a stable release already exists in the current Sunday-to-Saturday window, +the dry run reports a skip before building, even if new commits have landed. +When a build uses generated notes and `DS_API_KEY` is configured, the dry run +also requests a summary and uploads it for inspection. + +Before the first weekly publication, run the following command after the +workflow reaches the default branch. The release owner records the successful +build, notes and skipped publisher in [the activation issue](https://github.com/InferMatrixLab/InferRSI/issues/554), +then enables the Actions repository variable `INFERRSI_WEEKLY_RELEASE_ENABLED=true`. +While the variable is unset or false, both scheduled and manually requested +live weekly runs report a skip. Daily previews and manual dry runs remain available. ```bash gh workflow run release.yml --repo InferMatrixLab/InferRSI --ref \ - -F dry_run=true + -F weekly=true -F dry_run=true ``` Actions artifacts are retained for seven days. Package versions come from Git @@ -206,7 +214,7 @@ Runs are serialized across schedule and manual dispatch. A failed build creates no remote tag or Release. A later tag/upload/publication failure can leave an unused tag or private incomplete draft. The bot never moves tags, overwrites notes/assets or uses `--clobber`. On a later eligible run it allocates the next -unused patch version, so failures may leave gaps in version numbers. Failed +unused version for the selected channel, so failures may leave gaps in version numbers. Failed attempts do not advance the successful-release baseline or suppress retry of unreleased source. Old drafts remain for an authorized maintainer to inspect. @@ -246,4 +254,6 @@ This one-off notes path does not call the model API. Wheel, sdist, Codex ZIP, WorkSwarm ZIP and SHA256SUMS remain bound to the planned source commit. The daily patch planner continued with v0.2.1 after this promotion. +If a failed one-off attempt has reserved v0.2.0, the planner stops. Inspect the +reservation and obtain a new release decision from the maintainer before retrying. The recurring Sunday channel now handles subsequent minor releases. diff --git a/tests/test_release.py b/tests/test_release.py index a9a252550..712b0cf6e 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -218,17 +218,20 @@ def test_sunday_promotes_daily_preview_and_next_day_continues(release_repo): git = release_repo git("tag", "v0.2.0") change_source(git) - git("tag", "v0.2.6") releases = [ dict(published("v0.2.0"), published_at="2026-11-21T15:59:00Z"), - published("v0.2.6", prerelease=True), published("evidence-v1"), ] + # Sunday 02:00 publishes the patch before Sunday's 08:00 promotion. + preview = plan_release("main", releases, "0.1.0") + assert (preview["tag"], preview["prerelease"]) == ("v0.2.1", "true") + git("tag", preview["tag"]) + releases.append(published(preview["tag"], prerelease=True)) sunday = datetime(2026, 11, 22, 0, tzinfo=timezone.utc) assert plan_release("main", releases, "0.1.0") == {"release": "false"} weekly = plan_release("main", releases, "0.1.0", weekly=True, now=sunday) assert (weekly["tag"], weekly["prerelease"]) == ("v0.3.0", "false") - assert (weekly["previous_tag"], weekly["notes_start_tag"]) == ("v0.2.6", "v0.2.0") + assert (weekly["previous_tag"], weekly["notes_start_tag"]) == (preview["tag"], "v0.2.0") git("tag", "v0.3.0") releases.append(dict(published("v0.3.0"), published_at="2026-11-22T00:25:00Z")) next_sunday = datetime(2026, 11, 29, 0, tzinfo=timezone.utc) diff --git a/tests/test_release_publisher.py b/tests/test_release_publisher.py index 5fb167d1b..f50e353b3 100644 --- a/tests/test_release_publisher.py +++ b/tests/test_release_publisher.py @@ -44,6 +44,10 @@ def save(): "base_commit": {"sha": state.get("resolved", commit)}})) elif args == ["api", "--paginate", "--slurp", f"{repo}/releases?per_page=100"]: releases = [{"tag_name": "v1.2.2", "draft": False, "prerelease": True}] + if os.environ["WEEKLY"] == "true": + releases.append({"tag_name": os.environ["NOTES_START_TAG"], "draft": False, + "prerelease": False}) + releases.extend(state.get("new_releases", [])) if state.get("existing"): releases.append({"tag_name": tag, "draft": False, "prerelease": True}) print(json.dumps([releases])) @@ -127,7 +131,7 @@ def test_optional_notes_failure_cannot_skip_an_otherwise_valid_publication(): @pytest.fixture def publisher(tmp_path, request): release_tag = getattr(request, "param", "v1.2.3") - previous_tag = "v0.1.10" if release_tag == "v0.2.0" else "v1.2.2" + previous_tag = {"v0.2.0": "v0.1.10", "v0.3.0": "v0.2.7"}.get(release_tag, "v1.2.2") bash = shutil.which("bash") if os.name == "nt": candidate = Path(os.environ.get("ProgramFiles", "")) / "Git/bin/bash.exe" @@ -185,7 +189,7 @@ def run(state=None, **inputs): GH_TOKEN="fake-no-access", GH_REPO="example/release", DEFAULT_BRANCH="main", RELEASE_TAG=release_tag, RELEASE_COMMIT=COMMIT, PREVIOUS_TAG=previous_tag, NOTES_START_TAG=notes_start, REVIEWED_NOTES=str(reviewed).lower(), - PRERELEASE="true") + PRERELEASE="true", WEEKLY=str(release_tag == "v0.3.0").lower()) env.update(inputs) env["AI_NOTES_DOWNLOADED"] = ( "failure" if state and state.get("failed_notes_download") else @@ -314,3 +318,50 @@ def test_weekly_and_daily_channels_use_the_same_serialized_publisher(): publisher = config["jobs"]["publish"]["env"] assert publisher["PREVIOUS_TAG"] == "${{ needs.plan.outputs.previous_tag }}" assert publisher["NOTES_START_TAG"] == notes["env"]["PREVIOUS_TAG"] + assert publisher["WEEKLY"] == "${{ needs.plan.outputs.weekly }}" + assert step["env"]["WEEKLY_ENABLED"] == "${{ vars.INFERRSI_WEEKLY_RELEASE_ENABLED }}" + assert step["env"]["DRY_RUN"] == ( + "${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}") + + +@pytest.mark.parametrize("weekly,enabled,dry_run,skip", [ + ("true", "", "false", True), ("true", "false", "false", True), + ("true", "", "true", False), ("true", "true", "false", False), + ("false", "", "false", False), +]) +def test_weekly_rollout_gate(tmp_path, weekly, enabled, dry_run, skip): + step = next(s for s in workflow()["jobs"]["plan"]["steps"] if s.get("id") == "plan") + bash = shutil.which("bash") if os.name != "nt" else str( + Path(os.environ["ProgramFiles"]) / "Git/bin/bash.exe") + if not bash or not Path(bash).is_file(): + pytest.skip("Workflow plan runs in Bash") + # Stop at the first GitHub read to distinguish skipped runs from eligible plans. + result = subprocess.run([bash, "-ec", 'gh() { return 37; }\n' + step["run"]], + cwd=tmp_path, capture_output=True, text=True, + env=dict(os.environ, WEEKLY=weekly, WEEKLY_ENABLED=enabled, + DRY_RUN=dry_run, GITHUB_OUTPUT="outputs", RUNNER_TEMP=".", + GH_REPO="example/release")) + assert result.returncode == (0 if skip else 37), result.stderr + assert ("release=false" in (tmp_path / "outputs").read_text().splitlines()) == skip + assert ("::notice::" in result.stdout) == skip + + +@pytest.mark.parametrize("publisher", ["v0.3.0"], indirect=True) +@pytest.mark.parametrize("tag,preview,permitted", [ + ("v0.2.8", True, True), ("v0.2.8", False, False), ("v0.3.1", True, False), +]) +def test_weekly_publish_race_uses_stable_baseline_and_target(publisher, tag, preview, permitted): + release = {"tag_name": tag, "draft": False, "prerelease": preview} + result, mutations = publisher({"new_releases": [release], "ai_summary": "Highlights"}, + PRERELEASE="false") + assert (result.returncode == 0) == permitted, result.stderr + if permitted: + assert mutations[-1] == {"operation": "publish_release"} + else: + assert mutations == [] + + +def test_daily_publish_race_rejects_newer_preview(publisher): + release = {"tag_name": "v1.2.4", "draft": False, "prerelease": True} + result, mutations = publisher({"new_releases": [release]}) + assert result.returncode != 0 and mutations == []