Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8221161d4 | ||
|
|
4677cf8d17 |
No files matched your search
@@ -57,6 +57,7 @@ jobs:
|
||||
python3 tests/test_ci_maintenance.py
|
||||
python3 tests/test_rollout_version.py
|
||||
python3 tests/test_enforce_orb_checks.py
|
||||
python3 tests/test_native_next_gates.py
|
||||
python3 tests/test_enroll_consumers.py
|
||||
python3 tests/test_reconcile_enrollment.py
|
||||
python3 tests/test_discover_enrollment.py
|
||||
|
||||
@@ -70,10 +70,12 @@ def load_manifest(path, setup_version):
|
||||
if not isinstance(data, dict):
|
||||
raise ManifestError("Manifest must be a mapping")
|
||||
profile = data.get("profile")
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "node-artifact"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
if profile == "node-artifact":
|
||||
allowed = ("profile", "orb_version", "default_branch", "node_version", "context", "npm_scopes", "artifact_path", "build_branches")
|
||||
elif profile in ("qbit", "core"):
|
||||
allowed += ("java_version", "browsers", "api_checks")
|
||||
if profile == "qbit":
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
@@ -104,6 +106,22 @@ def load_manifest(path, setup_version):
|
||||
node = data.get("node_version", "24.21" if profile == "frontend-core" else "20")
|
||||
if not isinstance(node, str) or not re.fullmatch(r"\d+(?:\.\d+){0,2}", node):
|
||||
raise ManifestError("node_version must be an explicit numeric version string")
|
||||
if profile == "node-artifact":
|
||||
context = data.get("context", "")
|
||||
scopes = data.get("npm_scopes", [])
|
||||
artifact = data.get("artifact_path")
|
||||
branches = data.get("build_branches")
|
||||
if not isinstance(context, str) or not re.fullmatch(r"[A-Za-z0-9_-]+", context):
|
||||
raise ManifestError("Node artifact requires an explicit context")
|
||||
if not isinstance(scopes, list) or any(not isinstance(x, str) or not re.fullmatch(r"@[a-z0-9][a-z0-9-]*", x) for x in scopes) or len(scopes) != len(set(scopes)):
|
||||
raise ManifestError("Invalid npm registry scopes")
|
||||
if not isinstance(artifact, str) or not re.fullmatch(r"[A-Za-z0-9_-]+(?:/[A-Za-z0-9_.-]+)+", artifact) or any(x in (".", "..") for x in artifact.split("/")):
|
||||
raise ManifestError("Artifact must be a relative file path")
|
||||
if not isinstance(branches, list) or not branches or any(not isinstance(x, str) or not re.fullmatch(r"[A-Za-z0-9_-]+(?:/[A-Za-z0-9_.-]+)*", x) for x in branches) or len(branches) != len(set(branches)):
|
||||
raise ManifestError("Build branches must be distinct literal branch names")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"node_version": node, "context": context, "npm_scopes": scopes,
|
||||
"artifact_path": artifact, "build_branches": branches}
|
||||
publish_keys = ("snapshot", "release_candidate", "release")
|
||||
if profile == "all":
|
||||
publish_keys = ("snapshot",)
|
||||
@@ -460,6 +478,30 @@ PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
|
||||
"cli": cli_template, "voyage": voyage_template, "frontend-next": next_template, "all": all_template, "app-starter": starter_template, "android": android_template, "mcp-policy": policy_template, "marketing": marketing_template}
|
||||
|
||||
|
||||
def node_artifact_template(config, branch, tag):
|
||||
# One checkout/install is shared by tests and an optional artifact build.
|
||||
lines = ["registry=https://registry.npmjs.org/"]
|
||||
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
||||
if config["npm_scopes"]:
|
||||
lines.append("//npm.pkg.github.com/:_authToken=${NPM_TOKEN}")
|
||||
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
||||
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
||||
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
||||
{"run": {"name": "Install locked dependencies", "command": "npm ci --prefer-offline --cache ~/.npm"}},
|
||||
{"save_cache": {"key": 'node-artifact-npm-v1-{{ checksum "package-lock.json" }}', "paths": ["~/.npm"]}},
|
||||
{"run": {"name": "Test project", "command": "npm test"}}]
|
||||
if not tag and branch in config["build_branches"]:
|
||||
steps += [{"run": {"name": "Build artifact", "command": "npm run build"}},
|
||||
{"store_artifacts": {"path": config["artifact_path"], "destination": config["artifact_path"].split("/")[-1]}}]
|
||||
return {"version": 2.1,
|
||||
"jobs": {"node_artifact": {"docker": [{"image": "cimg/node:" + config["node_version"]}], "steps": steps}},
|
||||
"workflows": {"verify": {"jobs": [{"node_artifact": {"context": [config["context"]],
|
||||
"filters": {"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}}}}]}}}
|
||||
|
||||
|
||||
PROFILE_TEMPLATES["node-artifact"] = node_artifact_template
|
||||
|
||||
|
||||
def runtime_boolean(name):
|
||||
value = os.environ.get(name, "false").lower()
|
||||
if value in ("true", "1"):
|
||||
|
||||
@@ -25,7 +25,7 @@ STARTER_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNp1UMGKwkAMvc9X
|
||||
ANDROID_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtWG1v2zYQ/p5fQWgF6rSW3CXYMDhJ13YNkm5rkrrugKEKDFqiZCYUyZBUbC/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592Iv+CF45vULxjSSfsRoh7Hce7Ef7AV7HvCtnIYr0daQc2p8Q7Spt2CTLEiUG6Fae7DLcUasghJABcTPcDSjnJRQHKvBqeWMSYJzZrySsKo4PG2ItCA+NkeiGYmuRW7aYipNCvAJRfxU4ZgRPwKFbXUNxvaZnDu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RNnQXHBUtRKhVqAnHXCs7NqjgQT01NjV6tMIZ24tAQ9hlSCBRzD4n0e8mwmhf9RWyXuvvMhPej5+Xe7z2Jl/nY/4X0bu+xPz0ZLAe/APdOacY")))
|
||||
|
||||
|
||||
class ManifestError(ValueError):
|
||||
@@ -70,10 +70,12 @@ def load_manifest(path, setup_version):
|
||||
if not isinstance(data, dict):
|
||||
raise ManifestError("Manifest must be a mapping")
|
||||
profile = data.get("profile")
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "node-artifact"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
if profile == "node-artifact":
|
||||
allowed = ("profile", "orb_version", "default_branch", "node_version", "context", "npm_scopes", "artifact_path", "build_branches")
|
||||
elif profile in ("qbit", "core"):
|
||||
allowed += ("java_version", "browsers", "api_checks")
|
||||
if profile == "qbit":
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
@@ -104,6 +106,22 @@ def load_manifest(path, setup_version):
|
||||
node = data.get("node_version", "24.21" if profile == "frontend-core" else "20")
|
||||
if not isinstance(node, str) or not re.fullmatch(r"\d+(?:\.\d+){0,2}", node):
|
||||
raise ManifestError("node_version must be an explicit numeric version string")
|
||||
if profile == "node-artifact":
|
||||
context = data.get("context", "")
|
||||
scopes = data.get("npm_scopes", [])
|
||||
artifact = data.get("artifact_path")
|
||||
branches = data.get("build_branches")
|
||||
if not isinstance(context, str) or not re.fullmatch(r"[A-Za-z0-9_-]+", context):
|
||||
raise ManifestError("Node artifact requires an explicit context")
|
||||
if not isinstance(scopes, list) or any(not isinstance(x, str) or not re.fullmatch(r"@[a-z0-9][a-z0-9-]*", x) for x in scopes) or len(scopes) != len(set(scopes)):
|
||||
raise ManifestError("Invalid npm registry scopes")
|
||||
if not isinstance(artifact, str) or not re.fullmatch(r"[A-Za-z0-9_-]+(?:/[A-Za-z0-9_.-]+)+", artifact) or any(x in (".", "..") for x in artifact.split("/")):
|
||||
raise ManifestError("Artifact must be a relative file path")
|
||||
if not isinstance(branches, list) or not branches or any(not isinstance(x, str) or not re.fullmatch(r"[A-Za-z0-9_-]+(?:/[A-Za-z0-9_.-]+)*", x) for x in branches) or len(branches) != len(set(branches)):
|
||||
raise ManifestError("Build branches must be distinct literal branch names")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"node_version": node, "context": context, "npm_scopes": scopes,
|
||||
"artifact_path": artifact, "build_branches": branches}
|
||||
publish_keys = ("snapshot", "release_candidate", "release")
|
||||
if profile == "all":
|
||||
publish_keys = ("snapshot",)
|
||||
@@ -460,6 +478,30 @@ PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
|
||||
"cli": cli_template, "voyage": voyage_template, "frontend-next": next_template, "all": all_template, "app-starter": starter_template, "android": android_template, "mcp-policy": policy_template, "marketing": marketing_template}
|
||||
|
||||
|
||||
def node_artifact_template(config, branch, tag):
|
||||
# One checkout/install is shared by tests and an optional artifact build.
|
||||
lines = ["registry=https://registry.npmjs.org/"]
|
||||
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
||||
if config["npm_scopes"]:
|
||||
lines.append("//npm.pkg.github.com/:_authToken=${NPM_TOKEN}")
|
||||
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
||||
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
||||
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
||||
{"run": {"name": "Install locked dependencies", "command": "npm ci --prefer-offline --cache ~/.npm"}},
|
||||
{"save_cache": {"key": 'node-artifact-npm-v1-{{ checksum "package-lock.json" }}', "paths": ["~/.npm"]}},
|
||||
{"run": {"name": "Test project", "command": "npm test"}}]
|
||||
if not tag and branch in config["build_branches"]:
|
||||
steps += [{"run": {"name": "Build artifact", "command": "npm run build"}},
|
||||
{"store_artifacts": {"path": config["artifact_path"], "destination": config["artifact_path"].split("/")[-1]}}]
|
||||
return {"version": 2.1,
|
||||
"jobs": {"node_artifact": {"docker": [{"image": "cimg/node:" + config["node_version"]}], "steps": steps}},
|
||||
"workflows": {"verify": {"jobs": [{"node_artifact": {"context": [config["context"]],
|
||||
"filters": {"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}}}}]}}}
|
||||
|
||||
|
||||
PROFILE_TEMPLATES["node-artifact"] = node_artifact_template
|
||||
|
||||
|
||||
def runtime_boolean(name):
|
||||
value = os.environ.get(name, "false").lower()
|
||||
if value in ("true", "1"):
|
||||
|
||||
@@ -88,28 +88,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_coverage": {
|
||||
"name": "coverage",
|
||||
"node_version": "22",
|
||||
"package_manager": "npm",
|
||||
"min_coverage": "0",
|
||||
"coverage_tool": "jest",
|
||||
"coverage_summary_path": "coverage/coverage-summary.json",
|
||||
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
|
||||
"requires": [
|
||||
"build-and-test"
|
||||
],
|
||||
"filters": {
|
||||
"branches": {
|
||||
"only": [
|
||||
"/feature\\/.*/",
|
||||
"/hotfix\\/.*/"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_security_scan": {
|
||||
"name": "security-scan",
|
||||
@@ -184,25 +162,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_coverage": {
|
||||
"name": "coverage",
|
||||
"node_version": "22",
|
||||
"package_manager": "npm",
|
||||
"min_coverage": "0",
|
||||
"coverage_tool": "jest",
|
||||
"coverage_summary_path": "coverage/coverage-summary.json",
|
||||
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
|
||||
"requires": [
|
||||
"build-and-test"
|
||||
],
|
||||
"filters": {
|
||||
"branches": {
|
||||
"only": "develop"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_security_scan": {
|
||||
"name": "security-scan",
|
||||
@@ -228,7 +187,6 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
@@ -299,25 +257,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_coverage": {
|
||||
"name": "coverage",
|
||||
"node_version": "22",
|
||||
"package_manager": "npm",
|
||||
"min_coverage": "0",
|
||||
"coverage_tool": "jest",
|
||||
"coverage_summary_path": "coverage/coverage-summary.json",
|
||||
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
|
||||
"requires": [
|
||||
"build-and-test"
|
||||
],
|
||||
"filters": {
|
||||
"branches": {
|
||||
"only": "staging"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_security_scan": {
|
||||
"name": "security-scan",
|
||||
@@ -343,7 +282,6 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
@@ -422,27 +360,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_coverage": {
|
||||
"name": "coverage",
|
||||
"node_version": "22",
|
||||
"package_manager": "npm",
|
||||
"min_coverage": "0",
|
||||
"coverage_tool": "jest",
|
||||
"coverage_summary_path": "coverage/coverage-summary.json",
|
||||
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
|
||||
"requires": [
|
||||
"build-and-test"
|
||||
],
|
||||
"filters": {
|
||||
"branches": {
|
||||
"only": [
|
||||
"/release\\/.*/"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"munitor/node_security_scan": {
|
||||
"name": "security-scan",
|
||||
@@ -470,7 +387,6 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
|
||||
@@ -47,6 +47,7 @@ PROFILE_PARAMETERS = {
|
||||
"mcp-policy": {},
|
||||
"repository-policy": {},
|
||||
"marketing": {},
|
||||
"node-artifact": {},
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +67,8 @@ def canonical_caller(profile, version, explicit_manifest=False, release_tag_poli
|
||||
"orb_version": version,
|
||||
"filters": {"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"only": "/.*/"}},
|
||||
}
|
||||
if profile == "node-artifact":
|
||||
options["filters"]["tags"] = {"ignore": "/.*/"}
|
||||
if profile == "frontend-next":
|
||||
options["filters"]["branches"] = {"ignore": "/.*/"}
|
||||
if profile == "qbit" and release_tag_policy is not None:
|
||||
|
||||
@@ -29,6 +29,9 @@ class EnrollmentTests(unittest.TestCase):
|
||||
target = self.legacy(profile)
|
||||
root = Path(target['checkout'])
|
||||
data = {'profile': profile, 'orb_version': '0.7.4', 'default_branch': 'main'}
|
||||
if profile == 'node-artifact':
|
||||
data.update(context='registry', npm_scopes=['@example'],
|
||||
artifact_path='dist/bundle.js', build_branches=['main'])
|
||||
(root / '.qqq-ci.yml').write_text(yaml.safe_dump(data), encoding='utf-8')
|
||||
(root / '.circleci/config.yml').write_text(yaml.safe_dump(
|
||||
enrollment.rollout.standard.canonical_caller(profile, '0.7.4')), encoding='utf-8')
|
||||
|
||||
@@ -83,7 +83,7 @@ class FinishTests(unittest.TestCase):
|
||||
enforce.assert_called_once_with(current)
|
||||
|
||||
def test_unknown_gate_profile_never_merges_or_enforces(self):
|
||||
self.plan['profile'] = 'frontend-next'
|
||||
self.plan['profile'] = 'marketing'
|
||||
with mock.patch.object(finish.remote, 'command') as command, mock.patch.object(finish.enforcement, 'inspect') as inspect:
|
||||
self.assertEqual('unsupported-gates', finish.merge_ready(self.plan, self.result)['state'])
|
||||
self.assertEqual('unsupported-gates', finish.enforce_current(self.plan)['state'])
|
||||
|
||||
@@ -34,6 +34,12 @@ class MarketingContractTests(unittest.TestCase):
|
||||
# The original delegated job never builds: require the shared profile
|
||||
# to prepare the standalone artifact before browser/Lighthouse checks.
|
||||
for workflow in baseline["workflows"].values():
|
||||
# Omit the legacy zero-threshold job that fabricated 100% coverage.
|
||||
workflow["jobs"] = [job for job in workflow["jobs"] if "munitor/node_coverage" not in job]
|
||||
for job in workflow["jobs"]:
|
||||
options = next(iter(job.values()))
|
||||
if "requires" in options:
|
||||
options["requires"] = [name for name in options["requires"] if name != "coverage"]
|
||||
for entry in workflow["jobs"]:
|
||||
if "munitor/node_build_and_test" in entry:
|
||||
build = entry["munitor/node_build_and_test"]
|
||||
@@ -45,9 +51,18 @@ class MarketingContractTests(unittest.TestCase):
|
||||
self.assertEqual(result, baseline)
|
||||
self.assertNotIn("setup", result)
|
||||
self.assertEqual(result["orbs"], {"munitor": "kof22/munitor@0.3.11"})
|
||||
self.assertEqual(sum(len(w["jobs"]) for w in result["workflows"].values()), 33)
|
||||
self.assertEqual(sum(len(w["jobs"]) for w in result["workflows"].values()), 29)
|
||||
self.assertNotIn("generate_pipeline", json.dumps(result))
|
||||
|
||||
def test_no_fabricated_coverage_or_dangling_dependency(self):
|
||||
result = pipeline.marketing_template({}, "develop", "")
|
||||
self.assertNotIn("coverage-summary.json", json.dumps(result))
|
||||
self.assertNotIn("munitor/node_coverage", json.dumps(result))
|
||||
for workflow in result["workflows"].values():
|
||||
names = {next(iter(job.values())).get("name", next(iter(job))) for job in workflow["jobs"]}
|
||||
for job in workflow["jobs"]:
|
||||
self.assertTrue(set(next(iter(job.values())).get("requires", [])) <= names)
|
||||
|
||||
def test_production_deployment_and_actual_test_contracts(self):
|
||||
result = pipeline.marketing_template({}, "main", "")
|
||||
for name, workflow in result["workflows"].items():
|
||||
@@ -191,6 +206,36 @@ class PipelineTests(unittest.TestCase):
|
||||
self.assertNotIn("Traceback", result.stderr)
|
||||
return result
|
||||
|
||||
def test_node_artifact_reuses_install_and_preserves_branch_artifact_policy(self):
|
||||
self.write_manifest(profile="node-artifact", context="qqq-maven-registry-credentials",
|
||||
npm_scopes=["@nocode-js", "@qrunio"], artifact_path="dist/q-sequential-workflow.bundle.js",
|
||||
build_branches=["main", "feature/initial-dev"], node_version="20")
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
for branch in ("main", "develop", "feature/initial-dev", "feature/change"):
|
||||
output = self.render(packed=packed, CIRCLE_BRANCH=branch)
|
||||
self.assertEqual(["verify"], list(output["workflows"]))
|
||||
self.assertEqual(["node_artifact"], list(output["jobs"]))
|
||||
steps = output["jobs"]["node_artifact"]["steps"]
|
||||
self.assertEqual(1, steps.count("checkout"))
|
||||
commands = [step["run"]["command"] for step in steps if isinstance(step, dict) and "run" in step]
|
||||
self.assertEqual(1, commands.count("npm ci --prefer-offline --cache ~/.npm"))
|
||||
self.assertEqual(1, commands.count("npm test"))
|
||||
self.assertEqual(branch in ("main", "feature/initial-dev"), "npm run build" in commands)
|
||||
artifacts = [step["store_artifacts"] for step in steps if isinstance(step, dict) and "store_artifacts" in step]
|
||||
self.assertEqual(int(branch in ("main", "feature/initial-dev")), len(artifacts))
|
||||
self.assertNotIn("npm publish", str(output))
|
||||
self.assertIn("${NPM_TOKEN}", commands[0])
|
||||
self.assertEqual({"ignore": "/.*/"}, output["workflows"]["verify"]["jobs"][0]["node_artifact"]["filters"]["tags"])
|
||||
|
||||
def test_node_artifact_rejects_commands_paths_and_branch_regex(self):
|
||||
baseline = {"profile": "node-artifact", "context": "registry", "npm_scopes": [],
|
||||
"artifact_path": "dist/bundle.js", "build_branches": ["main"]}
|
||||
for invalid in ({"artifact_path": "dist/../secret"}, {"artifact_path": "/etc/passwd"},
|
||||
{"build_branches": ["/.*/"]}, {"npm_scopes": ["@scope;echo bad"]},
|
||||
{"publish": {"release": True}}, {"context": "$(echo bad)"}):
|
||||
self.write_manifest(**{**baseline, **invalid})
|
||||
self.render(ok=False)
|
||||
|
||||
def assert_full(self, result, workflow="test_only"):
|
||||
self.assertEqual(list(result["workflows"]), ["verify"])
|
||||
self.assertNotIn("docs_only", result.get("jobs", {}))
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
"""Recognize native ownership without duplicate CI or weaker PR protections."""
|
||||
import base64
|
||||
import copy
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
import enforce_orb_checks as enforcement
|
||||
import finish_enrollment as finish
|
||||
|
||||
|
||||
class NativeTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.pin = 'a' * 40
|
||||
self.head = 'b' * 40
|
||||
self.caller = enforcement.native.bridge.canonical_next(self.pin)
|
||||
self.signed = True
|
||||
self.worker_drift = False
|
||||
self.runs = [{'id': i, 'name': gate['context'], 'app': {'id': 15368},
|
||||
'status': 'completed', 'conclusion': 'success'}
|
||||
for i, gate in enumerate(enforcement.native.gates())]
|
||||
self.record = {'id': 1, 'enforcement': 'active', 'target': 'branch',
|
||||
'source_type': 'Repository', 'source': 'QRun-IO/example', 'bypass_actors': [],
|
||||
'rules': [{'type': 'required_status_checks', 'parameters': {
|
||||
'strict_required_status_checks_policy': False,
|
||||
'required_status_checks': [{'context': g['context'], 'integration_id': g['app_id']}
|
||||
for g in enforcement.gates('frontend-next')]}}]}
|
||||
|
||||
def request(self, path, method='GET', payload=None):
|
||||
self.assertEqual('GET', method, 'Recognition must not mutate correct protections')
|
||||
if '/contents/' in path:
|
||||
if '.github/workflows/ci.yml?' in path:
|
||||
raw = yaml.safe_dump(self.caller)
|
||||
elif 'repos/QRun-IO/qqq-orb/' in path:
|
||||
name = path.split('/contents/')[1].split('?')[0]
|
||||
raw = (ROOT / name).read_text(encoding='utf-8') + ('# drift' if self.worker_drift else '')
|
||||
else:
|
||||
data = ({'profile': 'frontend-next', 'orb_version': '0.8', 'default_branch': 'main'}
|
||||
if '/.qqq-ci.yml?' in path else enforcement.standard.canonical_caller('frontend-next', '0.8'))
|
||||
raw = yaml.safe_dump(data)
|
||||
return {'type': 'file', 'encoding': 'base64', 'content': base64.b64encode(raw.encode()).decode()}
|
||||
if path.endswith('/commits/' + self.pin):
|
||||
return {'commit': {'verification': {'verified': self.signed}}}
|
||||
if '/check-runs?' in path:
|
||||
return {'check_runs': copy.deepcopy(self.runs)}
|
||||
if '/status?' in path:
|
||||
return {'statuses': []}
|
||||
if '/rulesets/1' in path:
|
||||
return copy.deepcopy(self.record)
|
||||
if '/rules/branches/' in path:
|
||||
return [{'type': 'required_status_checks', 'ruleset_source_type': 'Repository',
|
||||
'ruleset_source': 'QRun-IO/example', 'ruleset_id': 1}]
|
||||
if path.endswith('/protection'):
|
||||
return None
|
||||
if '/branches/' in path:
|
||||
return {'commit': {'sha': self.head}}
|
||||
return {'archived': False}
|
||||
|
||||
def test_main_recognition_retains_all_eight_pr_gates_without_image_run(self):
|
||||
plan = enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
self.assertFalse(plan['changed'])
|
||||
self.assertEqual('rulesets', plan['protection_mode'])
|
||||
self.assertEqual(enforcement.gates('frontend-next'), plan['required_status_checks']['checks'])
|
||||
self.assertEqual(8, len(plan['gates']))
|
||||
enforcement.enforce(plan, self.request)
|
||||
|
||||
def test_caller_drift_unsigned_and_changed_workers_fail_closed(self):
|
||||
self.caller['jobs']['ci']['uses'] = 'untrusted/repo/ci.yml@' + self.pin
|
||||
with self.assertRaisesRegex(ValueError, 'canonical'):
|
||||
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
self.caller = enforcement.native.bridge.canonical_next(self.pin)
|
||||
self.signed = False
|
||||
with self.assertRaisesRegex(ValueError, 'not verified'):
|
||||
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
self.signed = True
|
||||
self.worker_drift = True
|
||||
with self.assertRaisesRegex(ValueError, 'supported contract'):
|
||||
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
|
||||
def test_missing_main_gate_wrong_app_and_missing_pr_protection_reject(self):
|
||||
self.runs[0]['app']['id'] = 18001
|
||||
with self.assertRaises(ValueError):
|
||||
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
self.runs[0]['app']['id'] = 15368
|
||||
self.record['rules'][0]['parameters']['required_status_checks'].pop()
|
||||
with self.assertRaisesRegex(ValueError, 'missing app-bound gate'):
|
||||
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
|
||||
|
||||
def test_pr_qualification_requires_both_image_architectures(self):
|
||||
with mock.patch.object(finish.remote, 'api', side_effect=self.request):
|
||||
missing = finish.qualification('QRun-IO/example', self.head, 'frontend-next')
|
||||
self.assertEqual(sorted(enforcement.native.PR_GATES[-2:]), missing)
|
||||
for i, name in enumerate(enforcement.native.PR_GATES[-2:], 20):
|
||||
self.runs.append({'id': i, 'name': name, 'app': {'id': 15368},
|
||||
'status': 'completed', 'conclusion': 'success'})
|
||||
self.assertEqual([], finish.qualification('QRun-IO/example', self.head, 'frontend-next'))
|
||||
|
||||
def test_develop_has_no_native_push_contract(self):
|
||||
with self.assertRaisesRegex(ValueError, 'main only'):
|
||||
enforcement.native.validate('QRun-IO/example', self.head, 'develop', self.request, enforcement.standard.load_yaml)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -20,6 +20,9 @@ class RolloutTests(unittest.TestCase):
|
||||
def checkout(self, name, profile='qbit', explicit=False, **policy):
|
||||
root = self.root / name
|
||||
(root / '.circleci').mkdir(parents=True)
|
||||
if profile == 'node-artifact':
|
||||
policy = {'context': 'registry', 'npm_scopes': ['@example'],
|
||||
'artifact_path': 'dist/bundle.js', 'build_branches': ['main'], **policy}
|
||||
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'))
|
||||
|
||||
@@ -15,14 +15,19 @@ standard = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(standard)
|
||||
DESIRED = [{'context': name, 'app_id': 18001} for name in ('setup', 'verify')]
|
||||
PROFILE_GATES = {profile: 'verify' for profile in (
|
||||
'qbit', 'core', 'frontend-core', 'frontend-material', 'repository-policy')}
|
||||
'qbit', 'core', 'frontend-core', 'frontend-material', 'repository-policy', 'node-artifact')}
|
||||
PROFILE_GATES.update({'all': 'verify-and-smoke', 'cli': 'test_only',
|
||||
'app-starter': 'test_only', 'android': 'test-and-build',
|
||||
'mcp-policy': 'validate'})
|
||||
PROFILES = set(PROFILE_GATES)
|
||||
PROFILES = set(PROFILE_GATES) | {'frontend-next'}
|
||||
_native_spec = importlib.util.spec_from_file_location('native_next_gates', ROOT / 'tools/native_next_gates.py')
|
||||
native = importlib.util.module_from_spec(_native_spec)
|
||||
_native_spec.loader.exec_module(native)
|
||||
|
||||
|
||||
def gates(profile):
|
||||
if profile == 'frontend-next':
|
||||
return native.gates(pull_request=True)
|
||||
return [{'context': name, 'app_id': 18001}
|
||||
for name in ('setup', PROFILE_GATES[profile])]
|
||||
|
||||
@@ -51,12 +56,12 @@ def api(path, method='GET', payload=None):
|
||||
return json.loads(result.stdout) if result.stdout.strip() else None
|
||||
|
||||
|
||||
def required_checks(before, runs, desired_gates=DESIRED):
|
||||
"""Append app-bound gates only after both succeeded; preserve all other gates."""
|
||||
for desired in desired_gates:
|
||||
def required_checks(before, runs, desired_gates=DESIRED, observed_gates=None):
|
||||
"""Require successful event-appropriate gates and preserve every PR requirement."""
|
||||
for desired in (desired_gates if observed_gates is None else observed_gates):
|
||||
matches = [run for run in runs if run['name'] == desired['context'] and run['app']['id'] == desired['app_id']]
|
||||
if not matches or max(matches, key=lambda run: run['id'])['conclusion'] != 'success':
|
||||
raise ValueError('Current branch head has no successful CircleCI ' + desired['context'])
|
||||
raise ValueError('Current branch head has no successful app-bound gate: ' + desired['context'])
|
||||
prior = (before or {}).get('required_status_checks') or {}
|
||||
checks = [dict(check) for check in prior.get('checks', [])]
|
||||
represented = {check['context'] for check in checks}
|
||||
@@ -116,6 +121,10 @@ def inspect(repo, branch, version, request=api):
|
||||
if profile not in PROFILES:
|
||||
raise ValueError('Profile has no supported shared branch gates')
|
||||
desired_gates = gates(profile)
|
||||
observed_gates = desired_gates
|
||||
if profile == 'frontend-next':
|
||||
native.validate(repo, head, branch, request, standard.load_yaml)
|
||||
observed_gates = native.gates()
|
||||
rules = request(root + '/rules/branches/' + branch)
|
||||
rulesets, ruleset_strict = verified_rulesets(repo, rules, request, desired_gates) if rules else ([], False)
|
||||
before = request(prefix + '/protection')
|
||||
@@ -131,7 +140,7 @@ def inspect(repo, branch, version, request=api):
|
||||
if len(batch) < 100:
|
||||
break
|
||||
page += 1
|
||||
desired = required_checks(before, runs, desired_gates)
|
||||
desired = required_checks(before, runs, desired_gates, observed_gates)
|
||||
if use_ruleset:
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before, 'gates': desired_gates,
|
||||
'required_status_checks': {'strict': False, 'checks': desired_gates},
|
||||
|
||||
@@ -6,7 +6,7 @@ import reconcile_enrollment as remote
|
||||
|
||||
|
||||
def qualification(repo, head, profile='qbit'):
|
||||
"""Require both app-bound orb gates and every advertised latest check/status."""
|
||||
"""Require profile-specific app-bound gates and every advertised latest check/status."""
|
||||
checks, page = [], 1
|
||||
while True:
|
||||
batch = remote.api(f'repos/{repo}/commits/{head}/check-runs?filter=latest&per_page=100&page={page}')['check_runs']
|
||||
@@ -17,7 +17,7 @@ def qualification(repo, head, profile='qbit'):
|
||||
reasons = []
|
||||
for gate in enforcement.gates(profile):
|
||||
name = gate['context']
|
||||
found = [check for check in checks if check['name'] == name and check['app']['id'] == 18001]
|
||||
found = [check for check in checks if check['name'] == name and check['app']['id'] == gate['app_id']]
|
||||
if not found or max(found, key=lambda check: check['id'])['conclusion'] != 'success':
|
||||
reasons.append(name)
|
||||
for check in checks:
|
||||
@@ -50,6 +50,8 @@ def merge_ready(plan, result):
|
||||
if pr['state'] != 'MERGED':
|
||||
if pr['baseRefOid'] != plan['head'] or remote.api(f'repos/{repo}/branches/{plan["branch"]}')['commit']['sha'] != plan['head']:
|
||||
return {'state': 'stale-base', 'url': result['url']}
|
||||
if plan['profile'] == 'frontend-next':
|
||||
enforcement.native.validate(repo, head, plan['branch'], remote.api, enforcement.standard.load_yaml)
|
||||
pending = qualification(repo, head, plan['profile'])
|
||||
if pending:
|
||||
return {'state': 'waiting-checks', 'checks': pending, 'url': result['url']}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Validate the canonical native bridge and its immutable shared worker contract."""
|
||||
import base64
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('next_bridge', ROOT / 'src/scripts/generate_next_workflow.py')
|
||||
bridge = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(bridge)
|
||||
MAIN_GATES = [
|
||||
'ci / Typecheck, lint, unit tests and coverage',
|
||||
'ci / Mocked e2e (Playwright, chromium)',
|
||||
'ci / Collaboration e2e (MSW; chromium, firefox, webkit, mobile, tablet)',
|
||||
'ci / Bundle budget (static export)', 'ci / Storybook build',
|
||||
'acceptance / acceptance gate',
|
||||
]
|
||||
PR_GATES = MAIN_GATES + ['dashboard-image / build (amd64, ubuntu-24.04)',
|
||||
'dashboard-image / build (arm64, ubuntu-24.04-arm)']
|
||||
|
||||
|
||||
def gates(pull_request=False):
|
||||
return [{'context': name, 'app_id': 15368} for name in (PR_GATES if pull_request else MAIN_GATES)]
|
||||
|
||||
|
||||
def validate(repo, head, branch, request, load_yaml):
|
||||
"""Only main has a push trigger; require exact caller and reviewed worker bytes."""
|
||||
if branch != 'main':
|
||||
raise ValueError('Next native branch verification supports main only')
|
||||
|
||||
def content(owner, path, ref):
|
||||
item = request(f'repos/{owner}/contents/{path}?ref={ref}')
|
||||
if item.get('type') != 'file' or item.get('encoding') != 'base64':
|
||||
raise ValueError('Native workflow must be a regular file')
|
||||
return base64.b64decode(item['content']).decode('utf-8').replace('\r\n', '\n')
|
||||
|
||||
caller = load_yaml(content(repo, '.github/workflows/ci.yml', head))
|
||||
try:
|
||||
pin = caller['jobs']['ci']['uses'].rsplit('@', 1)[1]
|
||||
expected = bridge.canonical_next(pin)
|
||||
except (KeyError, TypeError, IndexError, ValueError):
|
||||
raise ValueError('Native caller has no valid immutable worker pin') from None
|
||||
if caller != expected:
|
||||
raise ValueError('Native caller differs from the canonical shared bridge')
|
||||
commit = request('repos/QRun-IO/qqq-orb/commits/' + pin)
|
||||
if not commit['commit']['verification']['verified']:
|
||||
raise ValueError('Shared native worker commit is not verified')
|
||||
for name in ('next-ci.yml', 'next-acceptance.yml', 'next-dashboard-image.yml'):
|
||||
path = '.github/workflows/' + name
|
||||
if content('QRun-IO/qqq-orb', path, pin) != (ROOT / path).read_text(encoding='utf-8'):
|
||||
raise ValueError('Pinned native worker differs from the supported contract: ' + name)
|
||||
return pin
|
||||
Reference in new issue
Block a user