Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(release): validate version commits before protected main pushes
rubenluetke10-beep76a8020caf23
diff --git a/.github/workflows/release-cut.yml b/.github/workflows/release-cut.ymlindex 53145589c4..e7ad4cf911 100644--- a/.github/workflows/release-cut.yml+++ b/.github/workflows/release-cut.yml@@ -7,7 +7,7 @@# 2. bumps pyproject.toml + jarvis/__init__.py and writes the CHANGELOG# section (scripts/ci/cut_release.py: [Unreleased] notes, or the# Conventional Commits since the last tag),-# 3. commits "chore(release): publish vX.Y.Z" to main, dispatches CI for it,+# 3. checks the version commit on a candidate branch, then fast-forwards main,# 4. pushes the annotated tag and dispatches the three publishing workflows# on it (PyPI, desktop installers, signed installer). Each of them starts# with release-gate.yml, which waits for CI on the release commit.@@ -48,7 +48,7 @@ jobs:name: cut releaseif: github.ref == 'refs/heads/main'runs-on: ubuntu-latest- timeout-minutes: 30+ timeout-minutes: 180outputs:version: ${{ steps.bump.outputs.version }}env:@@ -76,7 +76,7 @@ jobs:new="$(python scripts/ci/cut_release.py "${arg[@]}" --notes-out "$RUNNER_TEMP/notes.md" | tail -1)"echo "version=$new" >> "$GITHUB_OUTPUT"git diff --stat- - name: Commit, dispatch CI, tag+ - name: Check the version commit before landing and taggingenv:V: ${{ steps.bump.outputs.version }}run: |@@ -84,8 +84,27 @@ jobs:git config user.email "41898282+github-actions[bot]@users.noreply.github.com"git add pyproject.toml jarvis/__init__.py uv.lock CHANGELOG.mdgit commit -m "chore(release): publish v$V"+ sha="$(git rev-parse HEAD)"+ candidate="release-cut/v${V}-${GITHUB_RUN_ID}"+ git push origin "HEAD:refs/heads/$candidate"+ gh workflow run ci.yml --ref "$candidate" -f full=true -f include_macos=false+ # GITHUB_TOKEN pushes do not trigger CI, and protected main requires+ # checks BEFORE the push. Dispatch on this immutable candidate first.+ ci_run=""+ for attempt in {1..60}; do+ ci_run="$(gh run list --workflow ci.yml --branch "$candidate" --commit "$sha" \+ --event workflow_dispatch --json databaseId --jq '.[0].databaseId // empty')"+ [ -n "$ci_run" ] && break+ sleep 5+ done+ [ -n "$ci_run" ] || { echo "::error::Candidate CI did not start."; exit 1; }+ gh run watch "$ci_run" --exit-status --interval 30+ state="$(gh api "repos/$GITHUB_REPOSITORY/commits/$sha/check-runs?check_name=CI%20gate" \+ --jq '(.check_runs | max_by(.id)) | if .status == "completed" then .conclusion else (.status // "missing") end')"+ [ "$state" = "success" ] || { echo "::error::Candidate CI gate is $state."; exit 1; }+ # A concurrent main update rejects this ordinary fast-forward push.+ # No tag or publishing workflow is created when landing fails.git push origin HEAD:main- gh workflow run ci.yml --ref main -f full=true -f include_macos=falsegit tag -a "v$V" -m "v$V"git push origin "v$V"- name: Dispatch the publishing workflows on the tagdiff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.mdindex 61d4de0b0d..f05c49d69f 100644--- a/docs/ci-pipeline.md+++ b/docs/ci-pipeline.md@@ -107,10 +107,13 @@ dirty worktree and never stashes or force-pushes.A release happens **only** when the maintainer asks for one.* **`release-cut.yml`** (manual): refuses unless main is green, bumps- `pyproject.toml` + `jarvis/__init__.py`, moves the `[Unreleased]` notes (or+ `pyproject.toml`, `jarvis/__init__.py` and `uv.lock`, moves the `[Unreleased]` notes (orthe Conventional Commits since the last tag) into a dated CHANGELOG section- (`scripts/ci/cut_release.py`), commits, dispatches CI, tags, and dispatches- the three publishing workflows on the tag.+ (`scripts/ci/cut_release.py`), and commits on a unique candidate branch.+ It dispatches full CI for that exact commit, waits for success, then+ fast-forwards protected main, tags, and dispatches the three publishing+ workflows on the tag. A failed check or concurrent main update prevents+ tagging and publication; no branch-protection bypass is needed.* **`release-gate.yml`** is the first job of `release.yml` (PyPI),`desktop-installers.yml` and `sign-installer.yml`. It admits a tag onlywhen tag, versions and CHANGELOG agree, the commit is on main, anddiff --git a/tests/unit/ci/test_release_cut_workflow.py b/tests/unit/ci/test_release_cut_workflow.pynew file mode 100644index 0000000000..61de3b5f8e--- /dev/null+++ b/tests/unit/ci/test_release_cut_workflow.py@@ -0,0 +1,110 @@+"""Exercise the release shell against fake Git/GitHub commands, without publishing."""++from __future__ import annotations++import os+import shutil+import subprocess+from pathlib import Path++import pytest+import yaml++from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS+++ "watch_exit,gate_state,land_exit,success",+ [+ (0, "success", 0, True),+ (1, "failure", 0, False),+ (0, "in_progress", 0, False),+ (0, "success", 1, False),+ ],+)+def test_only_a_green_candidate_can_land_and_publish(+ tmp_path: Path,+ watch_exit: int,+ gate_state: str,+ land_exit: int,+ success: bool,+) -> None:+ bash = shutil.which("bash")+ if os.name == "nt":+ # System32/bash.exe enters WSL, which does not preserve this test's+ # Windows environment or paths. Use the runner's Git Bash instead.+ git = shutil.which("git")+ roots = (Path(git).parent, Path(git).parent.parent / "bin") if git else ()+ bash = next(+ (str(root / "bash.exe") for root in roots if (root / "bash.exe").is_file()), None+ )+ if bash is None:+ pytest.skip("the workflow shell requires Bash")+ root = Path(__file__).resolve().parents[3]+ workflow = yaml.safe_load((root / ".github/workflows/release-cut.yml").read_text("utf-8"))+ step = next(+ step+ for step in workflow["jobs"]["cut"]["steps"]+ if step.get("name") == "Check the version commit before landing and tagging"+ )+ trace = tmp_path / "commands.txt"+ # Functions shadow commands only inside this disposable shell. No real+ # repository, credentials, GitHub API, or release is touched by this test.+ fakes = r"""+git() {+ printf 'git %s\n' "$*" >> "$TRACE_FILE"+ if [ "$1" = rev-parse ]; then printf '%040d\n' 1; fi+ if [ "$1 $2 $3" = 'push origin HEAD:main' ]; then return "$LAND_EXIT"; fi+ return 0+}+gh() {+ printf 'gh %s\n' "$*" >> "$TRACE_FILE"+ case "$1 $2" in+ 'workflow run') return 0 ;;+ 'run list') printf '123\n' ;;+ 'run watch') return "$WATCH_EXIT" ;;+ api\ *) printf '%s\n' "$GATE_STATE" ;;+ *) return 2 ;;+ esac+}+"""+ script = tmp_path / "release-test.sh"+ script.write_text(fakes + step["run"], encoding="utf-8", newline="\n")+ result = subprocess.run(+ [bash, "--noprofile", "--norc", "-e", "-o", "pipefail", script.name],+ cwd=tmp_path,+ env={+ **os.environ,+ "V": "1.2.3",+ "GITHUB_RUN_ID": "77",+ "GITHUB_REPOSITORY": "example/project",+ "TRACE_FILE": trace.name,+ "PATH": "",+ "BASH_ENV": "/dev/null",+ "WATCH_EXIT": str(watch_exit),+ "GATE_STATE": gate_state,+ "LAND_EXIT": str(land_exit),+ },+ capture_output=True,+ text=True,+ encoding="utf-8",+ timeout=15,+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+ assert trace.exists(), result.stdout + result.stderr+ commands = trace.read_text("utf-8").splitlines()+ assert (result.returncode == 0) is success, result.stdout + result.stderr+ candidate = "git push origin HEAD:refs/heads/release-cut/v1.2.3-77"+ watch = "gh run watch 123 --exit-status --interval 30"+ assert commands.index(candidate) < commands.index(watch)+ if watch_exit or gate_state != "success":+ assert "git push origin HEAD:main" not in commands+ if success:+ assert commands.index(watch) < commands.index("git push origin HEAD:main")+ assert commands.index("git push origin HEAD:main") < commands.index(+ "git tag -a v1.2.3 -m v1.2.3"+ )+ assert commands[-1] == "git push origin v1.2.3"+ else:+ assert not any(command.startswith("git tag ") for command in commands)+ assert "git push origin v1.2.3" not in commands