Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0460c51e14
|
No files matched your search
@@ -57,7 +57,6 @@ 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,12 +70,10 @@ 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", "node-artifact"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile == "node-artifact":
|
||||
allowed = ("profile", "orb_version", "default_branch", "node_version", "context", "npm_scopes", "artifact_path", "build_branches")
|
||||
elif profile in ("qbit", "core"):
|
||||
if 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")
|
||||
@@ -106,24 +104,6 @@ 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":
|
||||
if "node_version" not in data or not re.fullmatch(r"\d+\.\d+(?:\.\d+)?", node):
|
||||
raise ManifestError("Node artifact requires an explicit minor or patch image version")
|
||||
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",)
|
||||
@@ -150,7 +130,7 @@ def load_manifest(path, setup_version):
|
||||
raise ManifestError("Unsupported QBit release tag policy")
|
||||
test_policy = data.get("test_branch_policy", "all")
|
||||
if test_policy not in ("all", "non-release", "non-release-no-integration", "feature", "non-release-no-main",
|
||||
"non-release-no-hotfix", "non-release-no-hotfix-integration", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
"non-release-no-hotfix", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
raise ManifestError("Unsupported QBit test branch policy")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"java_version": java, "node_version": node, "browsers": boolean(data, "browsers", True),
|
||||
@@ -258,7 +238,6 @@ def qbit_template(config, branch, tag):
|
||||
"feature": "/(develop|main|release/.*|integration.*)/",
|
||||
"non-release-no-main": "/(develop|main|release/.*)/",
|
||||
"non-release-no-hotfix": "/(develop|release/.*|hotfix/.*)/",
|
||||
"non-release-no-hotfix-integration": "/(develop|release/.*|hotfix/.*|integration.*)/",
|
||||
"non-release-no-main-hotfix": "/(develop|main|release/.*|hotfix/.*)/",
|
||||
"feature-no-hotfix": "/(develop|main|release/.*|hotfix/.*|integration.*)/"}
|
||||
ignored = ignores[config.get("test_branch_policy", "all")]
|
||||
@@ -427,18 +406,9 @@ def cli_template(config, branch, tag):
|
||||
|
||||
|
||||
def marketing_template(config, branch, tag):
|
||||
del config
|
||||
# Select the existing branch policy once; automation PRs use normal PR checks.
|
||||
selected = {"main": "production", "develop": "develop", "staging": "staging"}.get(
|
||||
branch, "release-candidate" if branch.startswith("release/") else "pr-checks")
|
||||
result = copy.deepcopy(MARKETING_TEMPLATE)
|
||||
workflow = result["workflows"][selected]
|
||||
for job in workflow["jobs"]:
|
||||
next(iter(job.values()))["filters"] = {
|
||||
"branches": {"ignore": "/.*/" if tag else "automation/qbit-rc-pending"},
|
||||
"tags": {"ignore": "/.*/"}}
|
||||
result["workflows"] = {"verify": workflow}
|
||||
return result
|
||||
del config, branch, tag
|
||||
# One final continuation; Munitor supplies jobs, never another setup pipeline.
|
||||
return copy.deepcopy(MARKETING_TEMPLATE)
|
||||
|
||||
|
||||
def android_template(config, branch, tag):
|
||||
@@ -489,30 +459,6 @@ 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/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592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1We5RdkEVpbMBcESesUnAdp1k6yexGmfU4/ZCRPp3MuSaesmRC78a1sD7DklrvXmT0YARGCsLpQDOSuNadvtxoL/UWKD7tvd31tATHTA163EFMmHCs7NnQhxUVmAUZZU6UsFJGFONy0qJGsmnbAOcp0XLe9nBPIC383EoLBRUslUV6xlIvvQJa5HiAG2N3tC7A5VbWHq9OUGE+oH36OESrpHNSbwisDKUpiUAXA7mVTJtQLMrlxBvVEeCEJH3NuWaixjJhzjzZdzkd5uwuBi4lqMLhtYxAB55MhljDK/FxwWZt9eA1h7q5bhl1xZIi0jFAj877NMiNroODxhCJwJFCDLAMPyzkv2Evh4B4ua3UnszaZivYfpDdYdh90Q2r3ASKkRsYnnCul03vlOhczDvadI6hTwZuR1dkwNh0kCl2aQav0o9nKADl4CTWLY6l9pKyMLeDK7Y913+ZQu3wHbW7MJeSF2OfS2Ve/vAO9Md/fCl6c/jta/E2wugw+g3AlOQ8")))
|
||||
REPOSITORY_POLICY_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNqdVltv2zYUfs+vIPwiGYjotgGGIa0fis7YAnRO0HgtgigwaOnIZkKRGkkl9gL/951DXSK7aDNML+K56ON3bqSeTxgbPYJ10ujROXvH356S5t6sHIrPuCa7UDIXHpLKKJntegOacpM9gEXNbathvS3YZSnWgOZRJsv1pNr5jdHnZ/ztu1HvtW9Xd6cdqAVnapvBMlPCEY+RK4VSo97BeajcwaajbAPZg6l973RExNZ6wLtValEGchfaedyA+Q2wm49/fmaVsA7DOj10z0xZCp3TF00kZywpWSUrJluAJMmlEyuFqZJV0uY1CdzY1Y6gp9Nf+Bt+Nhog719S8X/If22rE9iLqsISCU/bFhaArazQ2eY/RJKmHz5EVzeLPy7nUaplWRnr2b0zOtWFNRim8BslV6y1XKHYu7l6VVmTgXO9alsqDh4Z8JmCErRfEBvh2GzR++xEqVLEJ2jHpgMYHlK2xHpWtY9vo7X00SmLlEsKqcDROvknuhvzHDKTQxzVvkh+jcbcYfg+jtL0TTR+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MLhBvcODhzy/8NhuSgd0qmCc63igtrquPby93r+YJYRLv2LvsES1XuKmGFfvJ2KKEXuXrpFNIZckKt+llQ4TGNc4tq+2Q4P/lbJzxWTdv1zpUIqCgP7xvAsqdy0RzH5xLWSGaDdSHcIdhhOlM5ICViCMXjA/2UdqH2StngXvklasNCw0DJJpDXl2LCGh83UxJ3R4zXJxIEFHsEuIwaBKuUb5T+chfEh62tks9Z/qkigP/+63PR6Mvr6Oub/cvR+XeL+e3q0Gf0Hgnpc+w==")))
|
||||
|
||||
|
||||
class ManifestError(ValueError):
|
||||
@@ -70,12 +70,10 @@ 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", "node-artifact"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile == "node-artifact":
|
||||
allowed = ("profile", "orb_version", "default_branch", "node_version", "context", "npm_scopes", "artifact_path", "build_branches")
|
||||
elif profile in ("qbit", "core"):
|
||||
if 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")
|
||||
@@ -106,24 +104,6 @@ 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":
|
||||
if "node_version" not in data or not re.fullmatch(r"\d+\.\d+(?:\.\d+)?", node):
|
||||
raise ManifestError("Node artifact requires an explicit minor or patch image version")
|
||||
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",)
|
||||
@@ -150,7 +130,7 @@ def load_manifest(path, setup_version):
|
||||
raise ManifestError("Unsupported QBit release tag policy")
|
||||
test_policy = data.get("test_branch_policy", "all")
|
||||
if test_policy not in ("all", "non-release", "non-release-no-integration", "feature", "non-release-no-main",
|
||||
"non-release-no-hotfix", "non-release-no-hotfix-integration", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
"non-release-no-hotfix", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
raise ManifestError("Unsupported QBit test branch policy")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"java_version": java, "node_version": node, "browsers": boolean(data, "browsers", True),
|
||||
@@ -258,7 +238,6 @@ def qbit_template(config, branch, tag):
|
||||
"feature": "/(develop|main|release/.*|integration.*)/",
|
||||
"non-release-no-main": "/(develop|main|release/.*)/",
|
||||
"non-release-no-hotfix": "/(develop|release/.*|hotfix/.*)/",
|
||||
"non-release-no-hotfix-integration": "/(develop|release/.*|hotfix/.*|integration.*)/",
|
||||
"non-release-no-main-hotfix": "/(develop|main|release/.*|hotfix/.*)/",
|
||||
"feature-no-hotfix": "/(develop|main|release/.*|hotfix/.*|integration.*)/"}
|
||||
ignored = ignores[config.get("test_branch_policy", "all")]
|
||||
@@ -427,18 +406,9 @@ def cli_template(config, branch, tag):
|
||||
|
||||
|
||||
def marketing_template(config, branch, tag):
|
||||
del config
|
||||
# Select the existing branch policy once; automation PRs use normal PR checks.
|
||||
selected = {"main": "production", "develop": "develop", "staging": "staging"}.get(
|
||||
branch, "release-candidate" if branch.startswith("release/") else "pr-checks")
|
||||
result = copy.deepcopy(MARKETING_TEMPLATE)
|
||||
workflow = result["workflows"][selected]
|
||||
for job in workflow["jobs"]:
|
||||
next(iter(job.values()))["filters"] = {
|
||||
"branches": {"ignore": "/.*/" if tag else "automation/qbit-rc-pending"},
|
||||
"tags": {"ignore": "/.*/"}}
|
||||
result["workflows"] = {"verify": workflow}
|
||||
return result
|
||||
del config, branch, tag
|
||||
# One final continuation; Munitor supplies jobs, never another setup pipeline.
|
||||
return copy.deepcopy(MARKETING_TEMPLATE)
|
||||
|
||||
|
||||
def android_template(config, branch, tag):
|
||||
@@ -489,30 +459,6 @@ 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,6 +88,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -162,6 +184,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -187,6 +228,7 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
@@ -257,6 +299,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -282,6 +343,7 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
@@ -360,6 +422,27 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -387,6 +470,7 @@
|
||||
"health_db": "false",
|
||||
"requires": [
|
||||
"code-quality",
|
||||
"coverage",
|
||||
"secrets-scan",
|
||||
"sast-scan",
|
||||
"security-scan"
|
||||
|
||||
@@ -47,7 +47,6 @@ PROFILE_PARAMETERS = {
|
||||
"mcp-policy": {},
|
||||
"repository-policy": {},
|
||||
"marketing": {},
|
||||
"node-artifact": {},
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +66,6 @@ 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:
|
||||
|
||||
@@ -18,35 +18,6 @@ def runs():
|
||||
|
||||
|
||||
class EnforcementTests(unittest.TestCase):
|
||||
def test_profile_gates_match_shared_branch_workflows(self):
|
||||
spec = importlib.util.spec_from_file_location('pipeline',
|
||||
Path(__file__).resolve().parents[1] / 'src/scripts/generate_pipeline.py')
|
||||
pipeline = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(pipeline)
|
||||
for profile in ('all', 'cli', 'android', 'app-starter', 'mcp-policy'):
|
||||
desired = enforcement.gates(profile)
|
||||
for branch in ('main', 'develop', 'feature/change'):
|
||||
config = {'orb_version': '0.8', 'publish': {'snapshot': False, 'release': False}}
|
||||
output = pipeline.PROFILE_TEMPLATES[profile](config, branch, '')
|
||||
self.assertEqual([desired[1]['context']], list(output['workflows']))
|
||||
successful = [{'id': i, 'name': gate['context'], 'app': {'id': 18001},
|
||||
'conclusion': 'success'} for i, gate in enumerate(desired)]
|
||||
before = {'required_status_checks': {'checks': [
|
||||
*desired, {'context': 'scanner', 'app_id': 15368}]}}
|
||||
checks = enforcement.required_checks(before, successful, desired)['checks']
|
||||
self.assertTrue(enforcement.same_checks(before['required_status_checks']['checks'], checks))
|
||||
self.assertNotIn({'context': 'verify', 'app_id': 18001}, checks)
|
||||
for bad in (successful[:1], [*successful, dict(successful[1], id=99, conclusion='failure')],
|
||||
[dict(run, app={'id': 999}) for run in successful]):
|
||||
with self.subTest(profile=profile), self.assertRaises(ValueError):
|
||||
enforcement.required_checks(before, bad, desired)
|
||||
record, effective = self.ruleset_fixture()
|
||||
record['rules'][0]['parameters']['required_status_checks'] = [
|
||||
{'context': gate['context'], 'integration_id': gate['app_id']} for gate in desired]
|
||||
enforcement.verified_rulesets('QRun-IO/example', effective, lambda path: record, desired)
|
||||
with self.assertRaises(ValueError):
|
||||
enforcement.verified_rulesets('QRun-IO/example', effective, lambda path: record)
|
||||
|
||||
def test_check_comparison_ignores_only_order(self):
|
||||
checks = [*enforcement.DESIRED, {'context': 'scanner', 'app_id': 15368}]
|
||||
self.assertTrue(enforcement.same_checks(checks, list(reversed(checks))))
|
||||
|
||||
@@ -29,9 +29,6 @@ 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'], node_version='20.19',
|
||||
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')
|
||||
|
||||
@@ -29,17 +29,6 @@ class FinishTests(unittest.TestCase):
|
||||
{'statuses': [{'context': 'legacy-test', 'state': 'pending'}]}]):
|
||||
self.assertEqual(['legacy-test', 'scanner', 'verify'], finish.qualification('QRun-IO/example', 'b' * 40))
|
||||
|
||||
def test_profile_qualification_requires_its_actual_workflow(self):
|
||||
for profile in ('all', 'cli', 'android', 'app-starter', 'mcp-policy'):
|
||||
checks = self.checks()
|
||||
checks[1]['name'] = finish.enforcement.PROFILE_GATES[profile]
|
||||
with mock.patch.object(finish.remote, 'api', side_effect=[
|
||||
{'check_runs': checks}, {'statuses': []}]):
|
||||
self.assertEqual([], finish.qualification('QRun-IO/example', 'b' * 40, profile))
|
||||
with mock.patch.object(finish.remote, 'api', side_effect=[
|
||||
{'check_runs': self.checks()}, {'statuses': []}]):
|
||||
self.assertEqual([checks[1]['name']], finish.qualification('QRun-IO/example', 'b' * 40, profile))
|
||||
|
||||
def test_failed_or_missing_checks_never_merge(self):
|
||||
with mock.patch.object(finish.remote, 'verify_submission'), mock.patch.object(finish.remote, 'command', return_value=json.dumps(self.pr)) as command, mock.patch.object(finish.remote, 'api', return_value={'commit': {'sha': self.plan['head']}}), mock.patch.object(finish, 'qualification', return_value=['verify']):
|
||||
self.assertEqual('waiting-checks', finish.merge_ready(self.plan, self.result)['state'])
|
||||
@@ -83,7 +72,7 @@ class FinishTests(unittest.TestCase):
|
||||
enforce.assert_called_once_with(current)
|
||||
|
||||
def test_unknown_gate_profile_never_merges_or_enforces(self):
|
||||
self.plan['profile'] = 'voyage'
|
||||
self.plan['profile'] = 'all'
|
||||
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,45 +34,23 @@ 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"]
|
||||
build["test_commands"] = json.dumps([
|
||||
"npm run lint", "npm run build",
|
||||
*json.loads(build["test_commands"])])
|
||||
for branch, selected in (("feature/example", "pr-checks"), ("main", "production"),
|
||||
("develop", "develop"), ("staging", "staging"),
|
||||
("release/1", "release-candidate"), ("automation/enroll", "pr-checks")):
|
||||
for branch in ("feature/example", "main", "develop", "staging", "release/1"):
|
||||
result = pipeline.marketing_template({}, branch, "")
|
||||
expected = copy.deepcopy(baseline)
|
||||
workflow = expected["workflows"][selected]
|
||||
for job in workflow["jobs"]:
|
||||
next(iter(job.values()))["filters"] = {"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}}
|
||||
expected["workflows"] = {"verify": workflow}
|
||||
self.assertEqual(result, expected)
|
||||
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.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):
|
||||
for branch in ("main", "develop", "staging", "release/1", "automation/enroll"):
|
||||
result = pipeline.marketing_template({}, branch, "")
|
||||
workflow = result["workflows"]["verify"]
|
||||
result = pipeline.marketing_template({}, "main", "")
|
||||
for name, workflow in result["workflows"].items():
|
||||
jobs = {next(iter(entry)): next(iter(entry.values())) for entry in workflow["jobs"]}
|
||||
build = jobs["munitor/node_build_and_test"]
|
||||
self.assertEqual(build["node_version"], "22")
|
||||
@@ -80,11 +58,11 @@ class MarketingContractTests(unittest.TestCase):
|
||||
"npm run lint", "npm run build",
|
||||
"npx playwright install chromium --with-deps",
|
||||
"npm run test:chromium", "npm run lighthouse"])
|
||||
if branch == "main":
|
||||
if name == "production":
|
||||
cd = jobs["munitor/update_cd_repo"]
|
||||
self.assertEqual(cd["cd_repo"], "KofTwentyTwo/cluster-gitops")
|
||||
self.assertEqual(cd["cd_path"], "tenants/qrun/website/kustomization.yaml")
|
||||
self.assertEqual(cd["filters"]["tags"], {"ignore": "/.*/"})
|
||||
self.assertEqual(cd["filters"], {"branches": {"only": "main"}})
|
||||
self.assertEqual(cd["requires"], ["docker-build-push"])
|
||||
self.assertEqual(jobs["munitor/github_release"]["requires"], ["docker-build-push"])
|
||||
self.assertEqual(jobs["munitor/docker_build_push"]["health_path"], "/")
|
||||
@@ -92,7 +70,7 @@ class MarketingContractTests(unittest.TestCase):
|
||||
else:
|
||||
self.assertNotIn("munitor/update_cd_repo", jobs)
|
||||
result["workflows"].clear()
|
||||
self.assertEqual(list(pipeline.marketing_template({}, "main", "")["workflows"]), ["verify"])
|
||||
self.assertEqual(len(pipeline.marketing_template({}, "main", "")["workflows"]), 5)
|
||||
|
||||
def test_marketing_manifest_rejects_custom_policy_and_wrong_branch(self):
|
||||
data = {"profile": "marketing", "orb_version": "0.7.0", "default_branch": "main"}
|
||||
@@ -213,65 +191,6 @@ class PipelineTests(unittest.TestCase):
|
||||
self.assertNotIn("Traceback", result.stderr)
|
||||
return result
|
||||
|
||||
def test_marketing_branch_dispatch_source_and_packed(self):
|
||||
self.write_manifest(profile="marketing", default_branch="main")
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
for branch in ("main", "develop", "staging", "release/1", "feature/change", "automation/enroll"):
|
||||
output = self.render(packed=packed, CIRCLE_BRANCH=branch)
|
||||
self.assertEqual(["verify"], list(output["workflows"]))
|
||||
jobs = output["workflows"]["verify"]["jobs"]
|
||||
names = [next(iter(job)) for job in jobs]
|
||||
self.assertEqual(branch == "main", "munitor/update_cd_repo" in names)
|
||||
self.assertEqual(branch in ("main", "release/1"), "munitor/github_release" in names)
|
||||
self.assertEqual(branch in ("main", "develop", "staging", "release/1"), "munitor/docker_build_push" in names)
|
||||
self.assertIn("munitor/node_build_and_test", names)
|
||||
output = self.render(packed=packed, CIRCLE_BRANCH="main", CIRCLE_TAG="v1.0.0")
|
||||
for job in output["workflows"]["verify"]["jobs"]:
|
||||
self.assertEqual({"branches": {"ignore": "/.*/"}, "tags": {"ignore": "/.*/"}}, next(iter(job.values()))["filters"])
|
||||
|
||||
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.19")
|
||||
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_requires_explicit_minor_or_patch_image(self):
|
||||
baseline = {"profile": "node-artifact", "context": "registry", "npm_scopes": [],
|
||||
"artifact_path": "dist/bundle.js", "build_branches": ["main"]}
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
for version in (None, "20", "22"):
|
||||
self.write_manifest(**baseline, **({"node_version": version} if version else {}))
|
||||
result = self.render(packed=packed, ok=False)
|
||||
self.assertIn("explicit minor or patch", result.stderr)
|
||||
for version in ("20.19", "20.19.0"):
|
||||
self.write_manifest(**baseline, node_version=version)
|
||||
result = self.render(packed=packed)
|
||||
self.assertEqual("cimg/node:" + version, result["jobs"]["node_artifact"]["docker"][0]["image"])
|
||||
|
||||
def test_node_artifact_rejects_commands_paths_and_branch_regex(self):
|
||||
baseline = {"profile": "node-artifact", "context": "registry", "npm_scopes": [], "node_version": "20.19",
|
||||
"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", {}))
|
||||
@@ -700,7 +619,7 @@ class PipelineTests(unittest.TestCase):
|
||||
def test_marketing_source_and_packed_parity(self):
|
||||
self.write_manifest(profile="marketing", default_branch="main")
|
||||
result = self.render(CIRCLE_BRANCH="main")
|
||||
self.assertEqual(result, pipeline.marketing_template({}, "main", ""))
|
||||
self.assertEqual(result, pipeline.MARKETING_TEMPLATE)
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="main"))
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
"""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,9 +20,6 @@ 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'], 'node_version': '20.19',
|
||||
'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'))
|
||||
|
||||
@@ -3,7 +3,6 @@ import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
@@ -16,38 +15,6 @@ spec.loader.exec_module(migration)
|
||||
|
||||
|
||||
class MigrationTests(unittest.TestCase):
|
||||
def test_hotfix_and_integration_exclusion_preserves_main_tests_and_publications(self):
|
||||
pattern = "/(develop|release/.*|hotfix/.*|integration.*)/"
|
||||
config = self.config(filters={"branches": {"ignore": pattern}, "tags": {"only": []}})
|
||||
for kind, branch in (("snapshot", "develop"), ("release_candidate", r"/release\/.*/"), ("hotfix", r"/hotfix\/.*/")):
|
||||
config["workflows"][kind] = {"jobs": [{"qqq-orb/mvn_publish": {
|
||||
"branch_type": kind, "filters": {"branches": {"only": [branch]}}}}]}
|
||||
config["workflows"]["release"] = {"jobs": [{"qqq-orb/mvn_publish": {
|
||||
"branch_type": "release", "filters": {"branches": {"ignore": "/.*/"},
|
||||
"tags": {"only": [r"/^v\d+\.\d+\.\d+$/"]}}}}]}
|
||||
manifest = migration.infer_manifest(config, "0.8", "develop")
|
||||
self.assertEqual("non-release-no-hotfix-integration", manifest["test_branch_policy"])
|
||||
self.assertFalse(manifest["release_on_main"])
|
||||
self.assertEqual("stable", manifest["release_tag_policy"])
|
||||
self.assertTrue(all(manifest["publish"][kind] for kind in ("snapshot", "release_candidate", "release", "hotfix")))
|
||||
spec = importlib.util.spec_from_file_location("filter_pipeline", Path(__file__).resolve().parents[1] / "src/scripts/generate_pipeline.py")
|
||||
pipeline = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(pipeline)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "manifest.yml"
|
||||
path.write_text(yaml.safe_dump(manifest), encoding="utf-8")
|
||||
loaded = pipeline.load_manifest(path, "0.8")
|
||||
with mock.patch.object(pipeline, "proven_ci_maintenance", return_value=False), mock.patch.object(pipeline, "proven_docs_only", return_value=False), mock.patch.object(pipeline, "git", return_value=b"qualified-head\n"):
|
||||
for branch, tag, kind in (("main", "", None), ("feature/test", "", None),
|
||||
("integration-test", "", None), ("develop", "", "snapshot"),
|
||||
("release/1.0", "", "release_candidate"), ("hotfix/1.0.1", "", "hotfix"),
|
||||
("", "v1.0.0", "release")):
|
||||
result = pipeline.qbit_template(loaded, branch, tag)
|
||||
options = next(iter(next(iter(result["workflows"].values()))["jobs"][0].values()))
|
||||
self.assertEqual(kind, options.get("branch_type"))
|
||||
if kind is None:
|
||||
self.assertEqual(["automation/qbit-rc-pending", pattern], options["filters"]["branches"]["ignore"])
|
||||
|
||||
def test_630_original_filter_intersections_equal_generated_publications(self):
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"publication_pipeline", Path(__file__).resolve().parents[1] / "src/scripts/generate_pipeline.py")
|
||||
|
||||
+19
-41
@@ -14,22 +14,7 @@ spec = importlib.util.spec_from_file_location('standard', ROOT / 'src/scripts/va
|
||||
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', 'node-artifact', 'marketing')}
|
||||
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) | {'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])]
|
||||
PROFILES = {'qbit', 'core', 'frontend-core', 'frontend-material', 'repository-policy'}
|
||||
|
||||
|
||||
def same_checks(left, right):
|
||||
@@ -56,17 +41,17 @@ 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, 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):
|
||||
def required_checks(before, runs):
|
||||
"""Append app-bound gates only after both succeeded; preserve all other gates."""
|
||||
for desired in DESIRED:
|
||||
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 app-bound gate: ' + desired['context'])
|
||||
raise ValueError('Current branch head has no successful CircleCI ' + 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}
|
||||
checks += [{'context': name, 'app_id': -1} for name in prior.get('contexts', []) if name not in represented]
|
||||
for desired in desired_gates:
|
||||
for desired in DESIRED:
|
||||
matches = [check for check in checks if check['context'] == desired['context']]
|
||||
if any(check.get('app_id') not in (None, -1, desired['app_id']) for check in matches):
|
||||
raise ValueError('Existing gate uses a different app: ' + desired['context'])
|
||||
@@ -75,7 +60,7 @@ def required_checks(before, runs, desired_gates=DESIRED, observed_gates=None):
|
||||
return {'strict': True, 'checks': checks}
|
||||
|
||||
|
||||
def verified_rulesets(repo, effective, request=api, desired_gates=DESIRED):
|
||||
def verified_rulesets(repo, effective, request=api):
|
||||
"""Recognize active repository rulesets with bound gates and no bypass actors."""
|
||||
selected = [rule for rule in effective if rule['type'] == 'required_status_checks']
|
||||
if not selected or any(rule.get('ruleset_source_type') != 'Repository'
|
||||
@@ -91,7 +76,7 @@ def verified_rulesets(repo, effective, request=api, desired_gates=DESIRED):
|
||||
records.append(record)
|
||||
requirements = [rule['parameters'] for record in records for rule in record['rules']
|
||||
if rule['type'] == 'required_status_checks']
|
||||
for desired in desired_gates:
|
||||
for desired in DESIRED:
|
||||
if not any(check['context'] == desired['context'] and check.get('integration_id') == desired['app_id']
|
||||
for parameters in requirements for check in parameters['required_status_checks']):
|
||||
raise ValueError('Ruleset is missing app-bound gate: ' + desired['context'])
|
||||
@@ -117,16 +102,10 @@ def inspect(repo, branch, version, request=api):
|
||||
raise ValueError('Canonical declarations must be regular files')
|
||||
source.append(base64.b64decode(item['content'], validate=False).decode('utf-8'))
|
||||
standard.validate(*source, version)
|
||||
profile = standard.load_yaml(source[1])['profile']
|
||||
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()
|
||||
if standard.load_yaml(source[1])['profile'] not in PROFILES:
|
||||
raise ValueError('Profile does not use the shared setup/verify gate pair')
|
||||
rules = request(root + '/rules/branches/' + branch)
|
||||
rulesets, ruleset_strict = verified_rulesets(repo, rules, request, desired_gates) if rules else ([], False)
|
||||
rulesets, ruleset_strict = verified_rulesets(repo, rules, request) if rules else ([], False)
|
||||
before = request(prefix + '/protection')
|
||||
restrictions = (before or {}).get('restrictions')
|
||||
use_ruleset = (not rulesets and restrictions is not None
|
||||
@@ -140,33 +119,32 @@ def inspect(repo, branch, version, request=api):
|
||||
if len(batch) < 100:
|
||||
break
|
||||
page += 1
|
||||
desired = required_checks(before, runs, desired_gates, observed_gates)
|
||||
desired = required_checks(before, runs)
|
||||
if use_ruleset:
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before, 'gates': desired_gates,
|
||||
'required_status_checks': {'strict': False, 'checks': desired_gates},
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before,
|
||||
'required_status_checks': {'strict': False, 'checks': DESIRED},
|
||||
'changed': True, 'protection_mode': 'create-ruleset'}
|
||||
if rulesets:
|
||||
desired['strict'] = ruleset_strict or bool(((before or {}).get('required_status_checks') or {}).get('strict'))
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before, 'gates': desired_gates,
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before,
|
||||
'required_status_checks': desired, 'changed': False, 'protection_mode': 'rulesets',
|
||||
'effective_rules': rules, 'rulesets': rulesets}
|
||||
current = (before or {}).get('required_status_checks') or {}
|
||||
ready = (current.get('strict') is True and same_checks(current.get('checks', []), desired['checks'])
|
||||
and (before or {}).get('enforce_admins', {}).get('enabled') is True)
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before, 'gates': desired_gates,
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before,
|
||||
'required_status_checks': desired, 'changed': not ready}
|
||||
|
||||
|
||||
def enforce(plan, request=api):
|
||||
"""Recheck drift, use narrow updates, and verify preservation of other settings."""
|
||||
desired_gates = plan.get('gates', DESIRED)
|
||||
root = 'repos/' + plan['repository']
|
||||
prefix = root + '/branches/' + plan['branch']
|
||||
if request(prefix)['commit']['sha'] != plan['head'] or request(prefix + '/protection') != plan['before']:
|
||||
raise ValueError('Branch or protection changed after preflight')
|
||||
rules = request(root + '/rules/branches/' + plan['branch'])
|
||||
if plan.get('protection_mode') == 'rulesets':
|
||||
if rules != plan['effective_rules'] or verified_rulesets(plan['repository'], rules, request, desired_gates)[0] != plan['rulesets']:
|
||||
if rules != plan['effective_rules'] or verified_rulesets(plan['repository'], rules, request)[0] != plan['rulesets']:
|
||||
raise ValueError('Ruleset changed after preflight')
|
||||
return
|
||||
if rules:
|
||||
@@ -187,9 +165,9 @@ def enforce(plan, request=api):
|
||||
'rules': [{'type': 'required_status_checks', 'parameters': {
|
||||
'strict_required_status_checks_policy': False, 'do_not_enforce_on_create': False,
|
||||
'required_status_checks': [{'context': gate['context'], 'integration_id': gate['app_id']}
|
||||
for gate in desired_gates]}}]})
|
||||
for gate in DESIRED]}}]})
|
||||
effective = request(root + '/rules/branches/' + plan['branch'])
|
||||
verified_rulesets(plan['repository'], effective, request, desired_gates)
|
||||
verified_rulesets(plan['repository'], effective, request)
|
||||
if request(prefix + '/protection') != plan['before']:
|
||||
raise ValueError('Classic access policy changed during ruleset creation')
|
||||
return
|
||||
|
||||
@@ -5,8 +5,8 @@ import enforce_orb_checks as enforcement
|
||||
import reconcile_enrollment as remote
|
||||
|
||||
|
||||
def qualification(repo, head, profile='qbit'):
|
||||
"""Require profile-specific app-bound gates and every advertised latest check/status."""
|
||||
def qualification(repo, head):
|
||||
"""Require both app-bound orb 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']
|
||||
@@ -15,9 +15,8 @@ def qualification(repo, head, profile='qbit'):
|
||||
break
|
||||
page += 1
|
||||
reasons = []
|
||||
for gate in enforcement.gates(profile):
|
||||
name = gate['context']
|
||||
found = [check for check in checks if check['name'] == name and check['app']['id'] == gate['app_id']]
|
||||
for name in ('setup', 'verify'):
|
||||
found = [check for check in checks if check['name'] == name and check['app']['id'] == 18001]
|
||||
if not found or max(found, key=lambda check: check['id'])['conclusion'] != 'success':
|
||||
reasons.append(name)
|
||||
for check in checks:
|
||||
@@ -50,9 +49,7 @@ 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'])
|
||||
pending = qualification(repo, head)
|
||||
if pending:
|
||||
return {'state': 'waiting-checks', 'checks': pending, 'url': result['url']}
|
||||
remote.command(['gh', 'pr', 'merge', str(pr['number']), '--repo', repo, '--squash', '--match-head-commit', head])
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
"""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
|
||||
@@ -91,7 +91,6 @@ def test_filters(filters):
|
||||
"/(develop|main|release/.*|integration.*)/": "feature",
|
||||
"/(develop|main|release/.*)/": "non-release-no-main",
|
||||
"/(develop|release/.*|hotfix/.*)/": "non-release-no-hotfix",
|
||||
"/(develop|release/.*|hotfix/.*|integration.*)/": "non-release-no-hotfix-integration",
|
||||
"/(develop|main|release/.*|hotfix/.*)/": "non-release-no-main-hotfix",
|
||||
"/(develop|main|release/.*|hotfix/.*|integration.*)/": "feature-no-hotfix",
|
||||
}.get(pattern.replace(r"\/", "/"))
|
||||
|
||||
Reference in new issue
Block a user