Compare commits

...
Author SHA1 Message Date
james.maesandCodex 8160559838 ci: run business E2E on changes and preserve main validation
Co-Authored-By: Codex <noreply@openai.com>
2026-10-21 01:14:58 -05:00
james.maesandCodex 5e9bbb54ec ci: add batch version rollout for canonical consumers (#54)
Validate every checkout before updating its orb pin. Preserve publication policy, filters, credentials contexts and forwarded parameters; reject custom callers and mismatched declarations. Cover all 12 profiles, dry runs, no-op repeats, invalid batches and duplicate input with six new tests in the existing contract job. Existing migration and standard tests pass; Linux packed generator check passes.

Co-authored-by: Codex <noreply@openai.com>
2026-10-21 00:45:50 -05:00
8 changed files with 238 additions and 11 deletions

No files matched your search

+1
View File
@@ -49,6 +49,7 @@ jobs:
python3 tests/test_cli_ci_contract.py
python3 tests/test_maven_ci_contract.py
python3 tests/test_standardize_qbit.py
python3 tests/test_rollout_version.py
python3 tests/test_validate_standard.py
python3 tests/test_voyage_profile.py
python3 tests/test_next_native.py
+1
View File
@@ -58,6 +58,7 @@ test-pipelines: pack
bash tests/test_cli_ci_behavior.sh
python3 tests/test_cli_ci_contract.py
python3 tests/test_standardize_qbit.py
python3 tests/test_rollout_version.py
python3 tests/test_validate_standard.py
python3 tests/test_voyage_profile.py
python3 tests/test_next_native.py
+26
View File
@@ -65,3 +65,29 @@ actionlint .github/workflows/workflow-lint.yml
Tests cover exact no-CI allowlists and drift, unknown repositories, missing configured
profiles/native bridges, retained legacy workflows, bootstrap dependency/gate removal,
required-check unknown states, and the lint image/tool/command/caller contract.
## Batch orb-version rollout
Upgrade existing canonical CircleCI consumers with one command:
```sh
python tools/rollout_version.py --orb-version 0.7.11 /checkouts/qbit-one /checkouts/qqq-cli
python tools/rollout_version.py --orb-version 0.7.11 --write /checkouts/qbit-one /checkouts/qqq-cli
```
The first command previews the batch. The second updates only `.qqq-ci.yml` and
`.circleci/config.yml`, after every supplied checkout passes the existing manifest
and canonical-caller validators. It preserves publication opt-outs, release filters,
credential context names and forwarded profile parameters. Already-current files
are unchanged. Duplicate checkouts, custom jobs, invalid options and mismatched
pins reject the batch before writing; resolve these in the central profile first.
Use isolated checkouts of the intended repository heads, inspect the resulting
patches, then commit and push through the normal automated gates. The tool does not
commit, push, publish packages, change GitHub rules or modify native/RC worker pins.
A version update does not prove a publication succeeded: retain exact-head hosted
verification and artifact evidence. The requested version must already be published.
```sh
python3 -m unittest discover -s tests -p test_rollout_version.py
```
+1 -6
View File
@@ -256,11 +256,6 @@
"main"
]
},
"schedule": [
{
"cron": "17 6 * * *"
}
],
"workflow_dispatch": null
},
"permissions": {
@@ -268,7 +263,7 @@
},
"concurrency": {
"group": "e2e-${{ github.ref }}",
"cancel-in-progress": true
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
},
"jobs": {
"validate": {
+6 -3
View File
@@ -29,11 +29,14 @@ class BusinessE2ETests(unittest.TestCase):
self.assertEqual('always()', self.worker['jobs']['e2e']['steps'][-1]['if'])
self.assertEqual('docker compose -f deploy/compose/docker-compose.yml down -v', self.worker['jobs']['e2e']['steps'][-1]['run'])
def test_events_permissions_path_and_single_concurrency_owner_preserved(self):
self.assertEqual(self.original['events'], self.caller['on'])
def test_code_changes_and_manual_runs_keep_full_gate_without_nightly_duplicates(self):
expected_events = copy.deepcopy(self.original['events'])
del expected_events['schedule']
self.assertEqual(expected_events, self.caller['on'])
self.assertEqual(self.original['workflow']['permissions'], self.caller['permissions'])
self.assertEqual(self.caller['permissions'], self.worker['permissions'])
self.assertEqual(self.original['workflow']['concurrency'], self.caller['concurrency'])
self.assertEqual(self.original['workflow']['concurrency']['group'], self.caller['concurrency']['group'])
self.assertEqual("${{ github.event_name == 'pull_request' }}", self.caller['concurrency']['cancel-in-progress'])
self.assertNotIn('concurrency', self.worker)
self.assertEqual('.github/workflows/e2e.yml', aux.BRIDGES['business-e2e']['path'])
self.assertEqual({'workflow_call': {'secrets': {'E2E_ALERT_WEBHOOK_URL': {'required': False}}}}, self.worker['on'])
+109
View File
@@ -0,0 +1,109 @@
"""Version rollouts preserve policy and reject drift before changing any repo."""
import importlib.util
from pathlib import Path
import tempfile
import unittest
import yaml
spec = importlib.util.spec_from_file_location('rollout', Path(__file__).resolve().parents[1] / 'tools/rollout_version.py')
rollout = importlib.util.module_from_spec(spec)
spec.loader.exec_module(rollout)
class RolloutTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
def checkout(self, name, profile='qbit', explicit=False, **policy):
root = self.root / name
(root / '.circleci').mkdir(parents=True)
manifest = {'profile': profile, 'orb_version': '0.7.4', 'default_branch': 'develop', **policy}
caller = rollout.standard.canonical_caller(profile, '0.7.4', explicit_manifest=explicit,
release_tag_policy=manifest.get('release_tag_policy'))
(root / '.qqq-ci.yml').write_text(yaml.safe_dump(manifest), encoding='utf-8')
(root / '.circleci/config.yml').write_text(yaml.safe_dump(caller), encoding='utf-8')
return root
def contents(self, root):
return [(root / path).read_bytes() for path in ('.circleci/config.yml', '.qqq-ci.yml')]
def test_batch_preserves_opt_outs_filters_contexts_and_forwarded_parameters(self):
qbit = self.checkout('qbit', release_tag_policy='none', release_on_main=False,
test_branch_policy='feature', browsers=False,
publish={'snapshot': False, 'release_candidate': False, 'release': False})
core = self.checkout('core', profile='core', explicit=True)
cli = self.checkout('cli', profile='cli', publish={'release': True}, publish_context='npm-publisher')
roots = [qbit, core, cli]
originals = [yaml.safe_load((root / '.qqq-ci.yml').read_text()) for root in roots]
results = rollout.rollout(roots, '0.7.11', write=True)
self.assertTrue(all(result['changed'] for result in results))
for root, original in zip(roots, originals):
expected = {**original, 'orb_version': '0.7.11'}
self.assertEqual(expected, yaml.safe_load((root / '.qqq-ci.yml').read_text()))
rollout.standard.validate(*(data.decode() for data in self.contents(root)), '0.7.11')
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.7.11')
core_caller = yaml.safe_load((core / '.circleci/config.yml').read_text())
options = core_caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']
self.assertEqual('.qqq-ci.yml', options['manifest'])
self.assertEqual('<< pipeline.parameters.mongo_bind_diagnostics >>', options['mongo_bind_diagnostics'])
def test_all_supported_profiles_remain_valid_after_the_same_batch_upgrade(self):
roots = [self.checkout(profile, profile=profile, default_branch='main') for profile in rollout.standard.PROFILE_PARAMETERS]
results = rollout.rollout(roots, '0.7.11', write=True)
self.assertEqual(set(rollout.standard.PROFILE_PARAMETERS), {item['profile'] for item in results})
for root in roots:
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.7.11')
rollout.standard.validate(*(data.decode() for data in self.contents(root)), '0.7.11')
def test_dry_run_and_repeated_application_do_not_rewrite_files(self):
root = self.checkout('qbit')
before = self.contents(root)
self.assertTrue(rollout.rollout([root], '0.7.11')[0]['changed'])
self.assertEqual(before, self.contents(root))
rollout.rollout([root], '0.7.11', write=True)
applied = self.contents(root)
self.assertFalse(rollout.rollout([root], '0.7.11', write=True)[0]['changed'])
self.assertEqual(applied, self.contents(root))
def test_one_custom_caller_rejects_entire_batch_before_any_write(self):
good = self.checkout('good')
bad = self.checkout('bad')
before = self.contents(good)
with (bad / '.circleci/config.yml').open('a') as stream:
stream.write('\njobs: {custom: {steps: [checkout]}}\n')
with self.assertRaises(ValueError):
rollout.rollout([good, bad], '0.7.11', write=True)
self.assertEqual(before, self.contents(good))
def test_duplicate_manifest_keys_unknown_settings_and_mismatched_pins_are_rejected(self):
for suffix in ['orb_version: 0.7.4\n', 'unknown_setting: true\n', 'publish: {release: maybe}\n']:
with self.subTest(suffix=suffix):
root = self.checkout(str(len(list(self.root.iterdir()))))
with (root / '.qqq-ci.yml').open('a') as stream:
stream.write(suffix)
before = self.contents(root)
with self.assertRaises(ValueError):
rollout.rollout([root], '0.7.11', write=True)
self.assertEqual(before, self.contents(root))
root = self.checkout('mismatch')
path = root / '.circleci/config.yml'
path.write_text(path.read_text().replace('0.7.4', '0.7.3'))
with self.assertRaises(ValueError):
rollout.rollout([root], '0.7.11', write=True)
def test_invalid_target_and_duplicate_checkout_are_rejected(self):
root = self.checkout('qbit')
before = self.contents(root)
for version in ['latest', 'dev:test', '0.7', '0.7.11\n']:
with self.assertRaises(ValueError):
rollout.rollout([root], version, write=True)
with self.assertRaises(ValueError):
rollout.rollout([root, root], '0.7.11', write=True)
self.assertEqual(before, self.contents(root))
if __name__ == '__main__':
unittest.main()
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""Upgrade canonical CircleCI callers in one batch; dry-run unless --write.
Only the orb pin changes. Repository publication policy and profile parameters
are preserved. Git commits, pushes and hosted verification remain separate.
"""
import argparse
import importlib.util
import json
from pathlib import Path
import re
import sys
import yaml
ROOT = Path(__file__).resolve().parents[1]
def module(name):
spec = importlib.util.spec_from_file_location(name, ROOT / 'src/scripts' / (name + '.py'))
result = importlib.util.module_from_spec(spec)
spec.loader.exec_module(result)
return result
standard = module('validate_standard')
pipeline = module('generate_pipeline')
def plan(checkout, version):
root = Path(checkout).resolve(strict=True)
paths = [root / '.circleci/config.yml', root / '.qqq-ci.yml']
if any(not path.resolve(strict=True).is_relative_to(root) for path in paths):
raise ValueError('CI declarations must remain inside their checkout')
originals = [path.read_bytes() for path in paths]
caller_raw, manifest_raw = [data.decode('utf-8') for data in originals]
manifest = standard.load_yaml(manifest_raw)
if not isinstance(manifest, dict):
raise ValueError('Existing manifest must be a mapping')
previous = manifest.get('orb_version')
standard.validate(caller_raw, manifest_raw, previous)
pipeline.load_manifest(paths[1], previous)
caller = standard.load_yaml(caller_raw)
if previous == version:
replacements = originals
else:
manifest['orb_version'] = version
caller['orbs']['qqq-orb'] = 'kingsrook/qqq-orb@' + version
caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']['orb_version'] = version
new_caller = yaml.safe_dump(caller, sort_keys=False)
new_manifest = yaml.safe_dump(manifest, sort_keys=False)
standard.validate(new_caller, new_manifest, version)
replacements = [new_caller.encode('utf-8'), new_manifest.encode('utf-8')]
return {'checkout': str(root), 'profile': manifest['profile'], 'from': previous, 'to': version,
'files': list(zip(paths, originals, replacements))}
def rollout(checkouts, version, write=False):
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
raise ValueError('Fleet upgrades require an explicit stable orb version')
# Validate the entire batch before writing any repository.
plans = [plan(path, version) for path in checkouts]
if len({item['checkout'] for item in plans}) != len(plans):
raise ValueError('Each checkout may appear only once')
if write:
for item in plans:
for path, original, replacement in item['files']:
if path.read_bytes() != original:
raise ValueError('CI declaration changed after preflight; rerun the rollout')
for item in plans:
for path, original, replacement in item['files']:
if replacement != original:
path.write_bytes(replacement)
return [{**{key: value for key, value in item.items() if key != 'files'},
'changed': any(old != new for _, old, new in item['files']), 'written': write}
for item in plans]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('checkouts', nargs='+', type=Path)
parser.add_argument('--orb-version', required=True)
parser.add_argument('--write', action='store_true')
args = parser.parse_args()
print(json.dumps(rollout(args.checkouts, args.orb_version, args.write), indent=2))
if __name__ == '__main__':
try:
main()
except (ValueError, OSError) as error:
sys.exit('Version rollout rejected: ' + str(error))
+2 -2
View File
@@ -2,7 +2,7 @@
"""Replace audited standard QBit pipelines with the canonical orb caller.
Only modifies the two CI declarations in a supplied checkout. Git operations and
publication remain separate. Unknown jobs/options fail closed for human review.
publication remain separate. Unknown jobs/options fail closed for central profile resolution.
"""
import argparse
from pathlib import Path
@@ -158,7 +158,7 @@ def main():
manifest_path = args.checkout / ".qqq-ci.yml"
config = yaml.safe_load(config_path.read_text(encoding="utf-8"))
if manifest_path.exists():
raise ValueError("Already has a manifest; use the version rollout operation")
raise ValueError("Already has a manifest; use tools/rollout_version.py")
manifest = infer_manifest(config, args.orb_version, args.default_branch)
caller = canonical_caller(args.orb_version, manifest["release_tag_policy"])
if args.write: