From d87ff8accc350e381a41af018bd92fe315c6d14a Mon Sep 17 00:00:00 2001 From: virant Date: Sun, 15 Nov 2026 18:48:31 +0100 Subject: [PATCH] Resolve SDK requests through the release command entry point --- .github/sdk-release.json | 3 ++- .github/workflows/build.yml | 13 ++++++------- README.md | 3 +++ release.py | 12 +++++++++--- test_release.py | 17 +++++++++++++++++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/sdk-release.json b/.github/sdk-release.json index 46a681e..e2301ff 100644 --- a/.github/sdk-release.json +++ b/.github/sdk-release.json @@ -1,3 +1,4 @@ { - "engine_commit": "8fd3e8780c985721730855396de987e59e268fcf" + "engine_commit": "8fd3e8780c985721730855396de987e59e268fcf", + "attempt": 2 } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14e6586..014ef96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,14 +35,13 @@ jobs: env: REQUESTED_ENGINE_COMMIT: ${{ inputs.engine_commit }} REQUEST_EVENT: ${{ github.event_name }} - shell: python + shell: bash run: | - import os - from release import SDKRelease - override = os.environ['REQUESTED_ENGINE_COMMIT'] if os.environ['REQUEST_EVENT'] == 'workflow_dispatch' else None - commit = SDKRelease.requested_commit('.', override) - with open(os.environ['GITHUB_OUTPUT'], 'a') as output: - output.write('commit=' + commit + '\n') + if [ "$REQUEST_EVENT" = workflow_dispatch ]; then + python release.py resolve-request --commit "$REQUESTED_ENGINE_COMMIT" >> "$GITHUB_OUTPUT" + else + python release.py resolve-request >> "$GITHUB_OUTPUT" + fi build: needs: request strategy: diff --git a/README.md b/README.md index 1a8491a..ea95da6 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ for software that users execute. access. Merging it into `main` automatically starts all three native builds. This repository's initial request selects the already-tagged engine revision `8fd3e8780c985721730855396de987e59e268fcf`. + To retry an unpublished revision through a PR, increment the request's + optional positive integer `attempt` field (default: 1). Merging that request + starts a fresh run without moving the source tag. Manual **Build and publish binary SDKs** runs on `main` remain available for retries, using the same exact commit SHA. All three native-host SDK jobs must pass. The release contains three ZIP diff --git a/release.py b/release.py index 6ecb59f..78c3e2e 100644 --- a/release.py +++ b/release.py @@ -30,8 +30,11 @@ class SDKRelease: def requested_commit(cls, root, override=None): if override is None: request = json.loads((Path(root) / ".github/sdk-release.json").read_text()) - if not isinstance(request, dict) or set(request) != {"engine_commit"}: + if not isinstance(request, dict) or set(request) not in ({"engine_commit"}, {"engine_commit", "attempt"}): raise ValueError("Unexpected release request fields") + attempt = request.get("attempt", 1) + if type(attempt) is not int or not 1 <= attempt <= 100000: + raise ValueError("Release attempt must be a positive integer") override = request["engine_commit"] if not isinstance(override, str) or not re.fullmatch(r"[0-9a-f]{40}", override): raise ValueError("Release requests require a full engine commit") @@ -198,7 +201,7 @@ def stage(cls, source, destination, commit, targets): if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("command", choices=("check-repository", "stage")) + parser.add_argument("command", choices=("check-repository", "resolve-request", "stage")) parser.add_argument("--root", default=".") parser.add_argument("--input", type=Path) parser.add_argument("--output", type=Path) @@ -208,9 +211,12 @@ def stage(cls, source, destination, commit, targets): try: if args.command == "check-repository": SDKRelease.check_repository(args.root) + elif args.command == "resolve-request": + print("commit=" + SDKRelease.requested_commit(args.root, args.commit)) else: SDKRelease.stage(args.input, args.output, args.commit, (args.target,) if args.target else tuple(SDKRelease.TARGETS)) except Exception: print("PUBLICATION_POLICY_FAILED: output withheld; inspect privately.", file=sys.stderr) sys.exit(1) - print("PUBLICATION_POLICY_OK") + if args.command != "resolve-request": + print("PUBLICATION_POLICY_OK") diff --git a/test_release.py b/test_release.py index 3d32928..05fd336 100644 --- a/test_release.py +++ b/test_release.py @@ -5,6 +5,7 @@ from pathlib import Path import struct import subprocess +import sys import tempfile import unittest import zipfile @@ -107,6 +108,22 @@ def test_release_requests_and_manual_overrides_require_exact_commits(self): with self.subTest(override=value), self.assertRaises(ValueError): SDKRelease.requested_commit(self.root, value) + def test_release_request_cli_emits_only_github_job_output(self): + directory = self.root / '.github'; directory.mkdir() + request = directory / 'sdk-release.json' + request.write_text(json.dumps({'engine_commit': self.commit, 'attempt': 2})) + command = [sys.executable, str(Path(__file__).with_name('release.py').resolve()), 'resolve-request', '--root', str(self.root)] + result = subprocess.run(command, cwd=self.root, capture_output=True, text=True, check=True) + self.assertEqual(result.stdout, 'commit=' + self.commit + '\n') + result = subprocess.run(command + ['--commit', 'b' * 40], cwd=self.root, capture_output=True, text=True, check=True) + self.assertEqual(result.stdout, 'commit=' + 'b' * 40 + '\n') + for attempt in (0, -1, True, '2', 100001): + request.write_text(json.dumps({'engine_commit': self.commit, 'attempt': attempt})) + result = subprocess.run(command, cwd=self.root, capture_output=True, text=True) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(result.stdout, '') + self.assertNotIn('Traceback', result.stderr) + def test_repository_history_keeps_deleted_source_visible_to_the_audit(self): repo = self.root / 'repo'; repo.mkdir() subprocess.run(['git', 'init', '-q', str(repo)], check=True)