GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into cf5a/pm-hosted-read-s… · developing-today/code@ca7e094
File treeExpand file treeCollapse file tree Open diff view settings infra/fleet-queue-backup/tests testdata/seeds/v1/2026/11
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/scripts/id-runtime-artifact.py +73-45Lines changed: 73 additions & 45 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | parse and validate everything before subprocesses or writes. Existing output | 7 | 7 | is never overwritten. Nix builds only on the producer, never on consumers. | 8 | 8 | """ | | 9 | + | 9 | 10 | import argparse | 10 | 11 | import gzip | 11 | 12 | import hashlib | | 20 | 21 |
| 21 | 22 |
| 22 | 23 | def capture(*command): | 23 | | - return subprocess.run(command, cwd=ROOT, check=True, text=True, | 24 | | - stdout=subprocess.PIPE).stdout.strip() | | 24 | + return subprocess.run( | | 25 | + command, cwd=ROOT, check=True, text=True, stdout=subprocess.PIPE | | 26 | + ).stdout.strip() | 25 | 27 |
| 26 | 28 |
| 27 | 29 | def main(): | 28 | 30 | parser = argparse.ArgumentParser(description=__doc__, allow_abbrev=False) | 29 | | - parser.add_argument('--output-dir', required=True, action='append') | 30 | | - parser.add_argument('--source-sha', required=True, action='append') | | 31 | + parser.add_argument("--output-dir", required=True, action="append") | | 32 | + parser.add_argument("--source-sha", required=True, action="append") | 31 | 33 | args = parser.parse_args() | 32 | 34 | if len(args.output_dir) != 1 or len(args.source_sha) != 1: | 33 | | - parser.error('each option must appear exactly once') | | 35 | + parser.error("each option must appear exactly once") | 34 | 36 | sha = args.source_sha[0] | 35 | | - if re.fullmatch(r'[0-9a-f]{40}', sha) is None: | 36 | | - parser.error('--source-sha must be a full lowercase 40-character commit SHA') | | 37 | + if re.fullmatch(r"[0-9a-f]{40}", sha) is None: | | 38 | + parser.error("--source-sha must be a full lowercase 40-character commit SHA") | 37 | 39 | if not args.output_dir[0]: | 38 | | - parser.error('--output-dir must not be empty') | | 40 | + parser.error("--output-dir must not be empty") | 39 | 41 | output = Path(args.output_dir[0]).absolute() | 40 | 42 | if output.exists(): | 41 | | - parser.error(f'--output-dir already exists: {output}') | 42 | | - if capture('git', 'rev-parse', 'HEAD') != sha: | 43 | | - raise RuntimeError('source SHA differs from the producer checkout') | 44 | | - store = capture('nix', 'build', '--no-link', '--print-out-paths', | 45 | | - str(ROOT / 'pkgs/id') + '#id-lib') | 46 | | - if '\n' in store or not Path(store).is_absolute(): | 47 | | - raise RuntimeError('expected exactly one absolute package output') | 48 | | - binary = str(Path(store) / 'bin/id') | 49 | | - for command in (('serve', '--help'), ('world', 'join', '--help')): | | 43 | + parser.error(f"--output-dir already exists: {output}") | | 44 | + if capture("git", "rev-parse", "HEAD") != sha: | | 45 | + raise RuntimeError("source SHA differs from the producer checkout") | | 46 | + store = capture( | | 47 | + "nix", | | 48 | + "build", | | 49 | + "--no-link", | | 50 | + "--print-out-paths", | | 51 | + str(ROOT / "pkgs/id") + "#id-lib", | | 52 | + ) | | 53 | + if "\n" in store or not Path(store).is_absolute(): | | 54 | + raise RuntimeError("expected exactly one absolute package output") | | 55 | + binary = str(Path(store) / "bin/id") | | 56 | + for command in (("serve", "--help"), ("world", "join", "--help")): | 50 | 57 | capture(binary, *command) | 51 | | - closure = capture('nix-store', '--query', '--requisites', store).splitlines() | | 58 | + closure = capture("nix-store", "--query", "--requisites", store).splitlines() | 52 | 59 | if store not in closure: | 53 | | - raise RuntimeError('runtime closure does not contain its package root') | | 60 | + raise RuntimeError("runtime closure does not contain its package root") | 54 | 61 | # Stage privately; failed export/probes never publish a partial artifact. | 55 | | - with tempfile.TemporaryDirectory(prefix='id-runtime-') as temporary: | | 62 | + with tempfile.TemporaryDirectory(prefix="id-runtime-") as temporary: | 56 | 63 | staged = Path(temporary) | 57 | | - raw = staged / 'runtime.closure' | 58 | | - with raw.open('wb') as stream: | 59 | | - subprocess.run(['nix-store', '--export', *closure], check=True, stdout=stream) | | 64 | + raw = staged / "runtime.closure" | | 65 | + with raw.open("wb") as stream: | | 66 | + subprocess.run( | | 67 | + ["nix-store", "--export", *closure], check=True, stdout=stream | | 68 | + ) | 60 | 69 | if raw.stat().st_size == 0: | 61 | | - raise RuntimeError('empty runtime closure export') | 62 | | - with raw.open('rb') as source, (staged / 'runtime.closure.gz').open('wb') as target: | 63 | | - with gzip.GzipFile(fileobj=target, mode='wb', mtime=0) as compressed: | | 70 | + raise RuntimeError("empty runtime closure export") | | 71 | + with ( | | 72 | + raw.open("rb") as source, | | 73 | + (staged / "runtime.closure.gz").open("wb") as target, | | 74 | + ): | | 75 | + with gzip.GzipFile(fileobj=target, mode="wb", mtime=0) as compressed: | 64 | 76 | shutil.copyfileobj(source, compressed) | 65 | 77 | raw.unlink() | 66 | | - (staged / 'manifest.json').write_text(json.dumps({ | 67 | | - 'source_sha': sha, 'store_path': store, 'package': 'id-lib', | 68 | | - 'system': 'x86_64-linux', 'closure_paths': closure, | 69 | | - }, indent=2) + '\n') | 70 | | - (staged / 'INSTALL.txt').write_text( | 71 | | - 'Requires x86_64 Linux with Nix; run from the downloaded artifact directory.\n' | 72 | | - 'No source checkout, compiler or profile changes are needed.\n\n' | 73 | | - 'sha256sum --check SHA256SUMS\n' | 74 | | - 'gzip -dc runtime.closure.gz | nix-store --import\n' | 75 | | - f'{binary} serve --help\n{binary} world join --help\n' | 76 | | - '\nUse this exact executable with the separately downloaded game wasm.\n' | | 78 | + (staged / "manifest.json").write_text( | | 79 | + json.dumps( | | 80 | + { | | 81 | + "source_sha": sha, | | 82 | + "store_path": store, | | 83 | + "package": "id-lib", | | 84 | + "system": "x86_64-linux", | | 85 | + "closure_paths": closure, | | 86 | + }, | | 87 | + indent=2, | | 88 | + ) | | 89 | + + "\n" | | 90 | + ) | | 91 | + (staged / "INSTALL.txt").write_text( | | 92 | + "Requires x86_64 Linux with Nix; run from the downloaded artifact directory.\n" | | 93 | + "No source checkout, compiler or profile changes are needed.\n\n" | | 94 | + "sha256sum --check SHA256SUMS\n" | | 95 | + "gzip -dc runtime.closure.gz | nix-store --import\n" | | 96 | + f"{binary} serve --help\n{binary} world join --help\n" | | 97 | + "\nUse this exact executable with the separately downloaded game wasm.\n" | 77 | 98 | ) | 78 | 99 | names = sorted(path.name for path in staged.iterdir()) | 79 | | - (staged / 'SHA256SUMS').write_text(''.join( | 80 | | - f'{hashlib.file_digest((staged / name).open("rb"), "sha256").hexdigest()} {name}\n' | 81 | | - for name in names)) | | 100 | + (staged / "SHA256SUMS").write_text( | | 101 | + "".join( | | 102 | + f"{hashlib.file_digest((staged / name).open('rb'), 'sha256').hexdigest()} {name}\n" | | 103 | + for name in names | | 104 | + ) | | 105 | + ) | 82 | 106 | # Copy to a sibling staging directory, then atomically publish it. | 83 | 107 | output.parent.mkdir(parents=True, exist_ok=True) | 84 | | - with tempfile.TemporaryDirectory(prefix='.id-runtime-', dir=output.parent) as sibling: | 85 | | - package = Path(sibling) / 'artifact' | | 108 | + with tempfile.TemporaryDirectory( | | 109 | + prefix=".id-runtime-", dir=output.parent | | 110 | + ) as sibling: | | 111 | + package = Path(sibling) / "artifact" | 86 | 112 | shutil.copytree(staged, package) | 87 | 113 | if output.exists(): | 88 | | - raise RuntimeError('output appeared while packaging; refusing overwrite') | | 114 | + raise RuntimeError( | | 115 | + "output appeared while packaging; refusing overwrite" | | 116 | + ) | 89 | 117 | package.rename(output) | 90 | | - print(f'Packaged {store} at {sha}: {output}') | | 118 | + print(f"Packaged {store} at {sha}: {output}") | 91 | 119 | return 0 | 92 | 120 |
| 93 | 121 |
| 94 | | -if __name__ == '__main__': | | 122 | +if __name__ == "__main__": | 95 | 123 | raise SystemExit(main()) |
Collapse file Copy file name to clipboardExpand all lines: .github/test-suite-registry.json +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1832 | 1832 | "pkgs/id/crates/id-sync/tests/federation_b22.rs", | 1833 | 1833 | "pkgs/id/crates/id-sync/tests/federation_b23.rs", | 1834 | 1834 | "pkgs/id/crates/id-sync/tests/federation_b24.rs", | | 1835 | + "pkgs/id/crates/id-sync/tests/federation_b27.rs", | 1835 | 1836 | "pkgs/id/crates/id-sync/tests/federation_b28.rs", | 1836 | 1837 | "pkgs/id/crates/id-sync/tests/federation_b31.rs", | 1837 | 1838 | "pkgs/id/crates/id-sync/tests/federation_b32.rs", | | 1881 | 1882 | "pkgs/id/crates/id-import-notion/tests/recorded_comments.rs", | 1882 | 1883 | "pkgs/id/crates/id-import-notion/tests/recorded_content.rs", | 1883 | 1884 | "pkgs/id/crates/id-import-notion/tests/recorded_databases.rs", | 1884 | | - "pkgs/id/crates/id-import-notion/tests/recorded_reimport.rs" | | 1885 | + "pkgs/id/crates/id-import-notion/tests/recorded_reimport.rs", | | 1886 | + "pkgs/id/crates/id-import-notion/tests/recorded_fidelity.rs" | 1885 | 1887 | ], | 1886 | 1888 | "invocation": "nix flake check ./pkgs/id (check test-sandbox runs cargo nextest --all-features for default workspace members)", | 1887 | 1889 | "venue": { | |
Collapse file Copy file name to clipboardExpand all lines: .github/tests/test_id_runtime_artifact.py +75-41Lines changed: 75 additions & 41 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | No compiler or network is used. Each fake subprocess records its invocation; | 5 | 5 | invalid CLI inputs must have no subprocess or output-directory side effects. | 6 | 6 | """ | | 7 | + | 7 | 8 | import gzip | 8 | 9 | import hashlib | 9 | 10 | import json | | 15 | 16 | import unittest | 16 | 17 |
| 17 | 18 | ROOT = Path(__file__).resolve().parents[2] | 18 | | -SCRIPT = ROOT / '.github/scripts/id-runtime-artifact.py' | 19 | | -SHA = 'a' * 40 | | 19 | +SCRIPT = ROOT / ".github/scripts/id-runtime-artifact.py" | | 20 | +SHA = "a" * 40 | 20 | 21 |
| 21 | 22 |
| 22 | 23 | class RuntimeArtifactTests(unittest.TestCase): | 23 | 24 | def setUp(self): | 24 | 25 | self.tmp = tempfile.TemporaryDirectory() | 25 | 26 | self.addCleanup(self.tmp.cleanup) | 26 | 27 | self.root = Path(self.tmp.name) | 27 | | - self.tools = self.root / 'tools' | | 28 | + self.tools = self.root / "tools" | 28 | 29 | self.tools.mkdir() | 29 | | - self.package = self.root / 'package' | 30 | | - (self.package / 'bin').mkdir(parents=True) | 31 | | - self.log = self.root / 'calls' | 32 | | - fake = '''#!/usr/bin/env python3 | | 30 | + self.package = self.root / "package" | | 31 | + (self.package / "bin").mkdir(parents=True) | | 32 | + self.log = self.root / "calls" | | 33 | + fake = """#!/usr/bin/env python3 | 33 | 34 | import os, pathlib, sys | 34 | 35 | name = pathlib.Path(sys.argv[0]).name | 35 | 36 | with open(os.environ['CALLS'], 'a') as log: | @@ -45,28 +46,51 @@ def setUp(self): | 45 | 46 | print(os.environ['PACKAGE']) | 46 | 47 | elif not os.environ.get('EMPTY_EXPORT'): | 47 | 48 | sys.stdout.buffer.write(b'closure-fixture') | 48 | | -''' | 49 | | - for path in (self.tools / 'git', self.tools / 'nix', self.tools / 'nix-store', self.package / 'bin/id'): | | 49 | +""" | | 50 | + for path in ( | | 51 | + self.tools / "git", | | 52 | + self.tools / "nix", | | 53 | + self.tools / "nix-store", | | 54 | + self.package / "bin/id", | | 55 | + ): | 50 | 56 | path.write_text(fake) | 51 | 57 | path.chmod(0o755) | 52 | | - self.env = dict(os.environ, PATH=f'{self.tools}:{os.environ["PATH"]}', | 53 | | - CALLS=str(self.log), PACKAGE=str(self.package), SOURCE_SHA=SHA) | 54 | | - self.out = self.root / 'artifact' | | 58 | + self.env = dict( | | 59 | + os.environ, | | 60 | + PATH=f"{self.tools}:{os.environ['PATH']}", | | 61 | + CALLS=str(self.log), | | 62 | + PACKAGE=str(self.package), | | 63 | + SOURCE_SHA=SHA, | | 64 | + ) | | 65 | + self.out = self.root / "artifact" | 55 | 66 |
| 56 | 67 | def run_script(self, *args, **env): | 57 | | - return subprocess.run([sys.executable, str(SCRIPT), *args], | 58 | | - env=dict(self.env, **env), capture_output=True, text=True) | | 68 | + return subprocess.run( | | 69 | + [sys.executable, str(SCRIPT), *args], | | 70 | + env=dict(self.env, **env), | | 71 | + capture_output=True, | | 72 | + text=True, | | 73 | + ) | 59 | 74 |
| 60 | 75 | def args(self): | 61 | | - return ['--output-dir', str(self.out), '--source-sha', SHA] | | 76 | + return ["--output-dir", str(self.out), "--source-sha", SHA] | 62 | 77 |
| 63 | 78 | def test_invalid_arguments_have_no_side_effects(self): | 64 | 79 | # Model: exactly one output directory and a 40-character hex revision. | 65 | | - cases = [[], ['extra'], ['--unknown'], ['--output-dir'], | 66 | | - ['--source-sha'], [*self.args(), 'extra'], | 67 | | - [*self.args(), '--typo'], [*self.args(), '--source-sha', SHA]] | 68 | | - cases += [['--output-dir', str(self.out), '--source-sha', sha] | 69 | | - for sha in ('', 'main', 'a' * 39, 'a' * 41, 'z' * 40)] | | 80 | + cases = [ | | 81 | + [], | | 82 | + ["extra"], | | 83 | + ["--unknown"], | | 84 | + ["--output-dir"], | | 85 | + ["--source-sha"], | | 86 | + [*self.args(), "extra"], | | 87 | + [*self.args(), "--typo"], | | 88 | + [*self.args(), "--source-sha", SHA], | | 89 | + ] | | 90 | + cases += [ | | 91 | + ["--output-dir", str(self.out), "--source-sha", sha] | | 92 | + for sha in ("", "main", "a" * 39, "a" * 41, "z" * 40) | | 93 | + ] | 70 | 94 | for args in cases: | 71 | 95 | with self.subTest(args=args): | 72 | 96 | result = self.run_script(*args) | @@ -77,40 +101,50 @@ def test_invalid_arguments_have_no_side_effects(self): | 77 | 101 | def test_complete_artifact_probes_cli_and_has_verifiable_bytes(self): | 78 | 102 | result = self.run_script(*self.args()) | 79 | 103 | self.assertEqual(result.returncode, 0, result.stderr) | 80 | | - self.assertTrue(self.out.is_dir(), 'successful packaging must publish an artifact') | 81 | | - manifest = json.loads((self.out / 'manifest.json').read_text()) | 82 | | - self.assertEqual(manifest['source_sha'], SHA) | 83 | | - self.assertEqual(manifest['store_path'], str(self.package)) | 84 | | - self.assertEqual(gzip.decompress((self.out / 'runtime.closure.gz').read_bytes()), | 85 | | - b'closure-fixture') | 86 | | - for line in (self.out / 'SHA256SUMS').read_text().splitlines(): | 87 | | - digest, name = line.split(' ') | 88 | | - self.assertEqual(digest, hashlib.sha256((self.out / name).read_bytes()).hexdigest()) | | 104 | + self.assertTrue( | | 105 | + self.out.is_dir(), "successful packaging must publish an artifact" | | 106 | + ) | | 107 | + manifest = json.loads((self.out / "manifest.json").read_text()) | | 108 | + self.assertEqual(manifest["source_sha"], SHA) | | 109 | + self.assertEqual(manifest["store_path"], str(self.package)) | | 110 | + self.assertEqual( | | 111 | + gzip.decompress((self.out / "runtime.closure.gz").read_bytes()), | | 112 | + b"closure-fixture", | | 113 | + ) | | 114 | + for line in (self.out / "SHA256SUMS").read_text().splitlines(): | | 115 | + digest, name = line.split(" ") | | 116 | + self.assertEqual( | | 117 | + digest, hashlib.sha256((self.out / name).read_bytes()).hexdigest() | | 118 | + ) | 89 | 119 | calls = self.log.read_text() | 90 | | - self.assertIn('id serve --help', calls) | 91 | | - self.assertIn('id world join --help', calls) | 92 | | - self.assertEqual(calls.count('nix build '), 1) | 93 | | - self.assertIn('nix-store --export ', calls) | 94 | | - self.assertIn('nix-store --import', (self.out / 'INSTALL.txt').read_text()) | 95 | | - self.assertNotIn('profile install', (self.out / 'INSTALL.txt').read_text()) | | 120 | + self.assertIn("id serve --help", calls) | | 121 | + self.assertIn("id world join --help", calls) | | 122 | + self.assertEqual(calls.count("nix build "), 1) | | 123 | + self.assertIn("nix-store --export ", calls) | | 124 | + self.assertIn("nix-store --import", (self.out / "INSTALL.txt").read_text()) | | 125 | + self.assertNotIn("profile install", (self.out / "INSTALL.txt").read_text()) | 96 | 126 |
| 97 | 127 | def test_failed_tools_or_empty_export_publish_nothing(self): | 98 | | - for env in ({'FAIL_TOOL': 'nix'}, {'FAIL_TOOL': 'nix-store'}, | 99 | | - {'FAIL_TOOL': 'id'}, {'EMPTY_EXPORT': '1'}): | | 128 | + for env in ( | | 129 | + {"FAIL_TOOL": "nix"}, | | 130 | + {"FAIL_TOOL": "nix-store"}, | | 131 | + {"FAIL_TOOL": "id"}, | | 132 | + {"EMPTY_EXPORT": "1"}, | | 133 | + ): | 100 | 134 | with self.subTest(env=env): | 101 | 135 | result = self.run_script(*self.args(), **env) | 102 | 136 | self.assertNotEqual(result.returncode, 0) | 103 | 137 | self.assertFalse(self.out.exists()) | 104 | 138 |
| 105 | 139 | def test_existing_output_is_never_overwritten(self): | 106 | 140 | self.out.mkdir() | 107 | | - marker = self.out / 'keep' | 108 | | - marker.write_text('existing work') | | 141 | + marker = self.out / "keep" | | 142 | + marker.write_text("existing work") | 109 | 143 | result = self.run_script(*self.args()) | 110 | 144 | self.assertNotEqual(result.returncode, 0) | 111 | | - self.assertEqual(marker.read_text(), 'existing work') | | 145 | + self.assertEqual(marker.read_text(), "existing work") | 112 | 146 | self.assertFalse(self.log.exists()) | 113 | 147 |
| 114 | 148 |
| 115 | | -if __name__ == '__main__': | | 149 | +if __name__ == "__main__": | 116 | 150 | unittest.main() |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/org-run.yml +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -441,6 +441,18 @@ jobs: | 441 | 441 | # image already ships without the listing. | 442 | 442 | usermod --append --groups nixbld "$user" | 443 | 443 | done | | 444 | + - name: Provide native build dependencies | | 445 | + run: | | | 446 | + set -euo pipefail | | 447 | + # Cargo legs across the fleet repos link native libraries | | 448 | + # through *-sys build scripts (openssl-sys needs OpenSSL | | 449 | + # headers, wayland-sys needs wayland-client). The fleet-build | | 450 | + # image does not ship them, so every dispatched command had | | 451 | + # to apt-get its own workarounds — and the one that forgot a | | 452 | + # library failed opaquely in a build script (#16282). Provide | | 453 | + # the common set once, here, instead. | | 454 | + apt-get update -qq | | 455 | + apt-get install -y -qq pkg-config libssl-dev libwayland-dev | 444 | 456 | - name: Run command | 445 | 457 | if: ${{ matrix.mode == 'single' }} | 446 | 458 | env: | |
|