Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
266ee6db53 | ||
|
|
434be19c65 | ||
|
|
bf962c79d7 | ||
|
|
c77891e63d | ||
|
|
98eb544670 | ||
|
|
f001c73cb0 | ||
|
|
736ab0e985 | ||
|
|
ee3cc63cdd | ||
|
|
d61e7ac070 | ||
|
|
c8221161d4 | ||
|
|
4677cf8d17 | ||
|
|
bbca434b39 | ||
|
|
66b93dccce | ||
|
|
a53af9ca33 | ||
|
|
978d6939d7 | ||
|
|
0131a1f415 | ||
|
|
5bdda2f8c9 | ||
|
|
7b1756818f | ||
|
|
68f17d3b09 | ||
|
|
130bc35ab0 | ||
|
|
9b7161c3c8 | ||
|
|
482d72ce21 | ||
|
|
45a439796f | ||
|
|
02f0b93e41 | ||
|
|
5e433ec629 | ||
|
|
cec7a76f12 | ||
|
|
8717d3536e | ||
|
|
8229a66bc5 | ||
|
|
9687feb36c | ||
|
|
0fefe6a064 | ||
|
|
2956e3ffce | ||
|
|
0afe2a231f | ||
|
|
65265e48a4 | ||
|
|
49399deb3d | ||
|
|
9fe4257490 | ||
|
|
0965a45653 | ||
|
|
bfd41c8e0d | ||
|
|
9c30a30754 | ||
|
|
ee8953bd93 | ||
|
|
5bc3167286 | ||
|
|
1a3368e119 | ||
|
|
1ddba883c9 | ||
|
|
da8044d6f2 | ||
|
|
67ba48da1f | ||
|
|
5196609974 | ||
|
|
49e09a6776 | ||
|
|
748016f105 | ||
|
|
6514aaa688 | ||
|
|
3ac47adc21 |
No files matched your search
@@ -60,6 +60,7 @@ jobs:
|
||||
python3 tests/test_enforce_orb_checks.py
|
||||
python3 tests/test_native_next_gates.py
|
||||
python3 tests/test_native_gitops_gates.py
|
||||
python3 tests/test_native_specialist_gates.py
|
||||
python3 tests/test_enroll_consumers.py
|
||||
python3 tests/test_reconcile_enrollment.py
|
||||
python3 tests/test_discover_enrollment.py
|
||||
@@ -71,6 +72,7 @@ jobs:
|
||||
python3 tests/test_next_native.py
|
||||
python3 tests/test_auxiliary_workflows.py
|
||||
python3 tests/test_qbit_codeql.py
|
||||
sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends shellcheck
|
||||
python3 tests/test_repository_policy.py
|
||||
python3 tests/test_intellij_plugin.py
|
||||
python3 tests/test_workflow_lint.py
|
||||
|
||||
+52
-10
@@ -1,11 +1,53 @@
|
||||
# GitOps validation
|
||||
|
||||
The orb owns `.github/workflows/gitops.yml`. The consumer keeps only the immutable caller generated by `generate_auxiliary_workflow.py gitops --ref <orb-commit>` at `.github/workflows/validate.yml`.
|
||||
|
||||
One native job downloads Kustomize 5.7.1 with its pinned official SHA-256 and renders every Kustomization, including bases, overlays and proxy declarations. Missing configurations or a failed render fail the job. Rendered resources are discarded rather than logged or uploaded because they may contain Secrets. This checks rendering, not Kubernetes schema compatibility or cluster health. No cluster access or publication credentials are required.
|
||||
|
||||
The caller runs on main pushes and pull requests without path filters, so a required check always reports. Superseded PR runs are canceled. Feature pushes do not create duplicate jobs. Remove the old Circle pipeline only after the native job passes on the consumer, then disable obsolete Circle build requests and require the observed native check with no human review.
|
||||
|
||||
For marketing-website-cd, the prior Circle job only printed Hello World. Its former production role moved to KofTwentyTwo/cluster-gitops; validation does not re-enable that retired deployment path.
|
||||
# GitOps validation
|
||||
|
||||
The shared registry includes marketing-website-cd and voyage-cd. Daily enrollment recognizes their canonical main-branch caller without creating Circle configuration. Recognition requires a signed immutable worker pin matching the supported worker, a complete source tree, and no additional Circle or GitHub workflows. Enforcement requires the GitHub Actions app-bound gitops / validate gate and preserves existing branch rules. Unavailable private-repository protections remain an explicit enforcement failure; recognition alone is not enforcement.
|
||||
The orb owns `.github/workflows/gitops.yml`. The consumer keeps only the immutable caller generated by `generate_auxiliary_workflow.py gitops --ref <orb-commit>` at `.github/workflows/validate.yml`.
|
||||
|
||||
One native job downloads Kustomize 5.7.1 with its pinned official SHA-256 and renders every Kustomization, including bases, overlays and proxy declarations. Missing configurations or a failed render fail the job. Rendered resources are discarded rather than logged or uploaded because they may contain Secrets. This checks rendering, not Kubernetes schema compatibility or cluster health. No cluster access or publication credentials are required.
|
||||
|
||||
The caller runs on main pushes and pull requests without path filters, so a required check always reports. Superseded PR runs are canceled. Feature pushes do not create duplicate jobs. Remove the old Circle pipeline only after the native job passes on the consumer, then disable obsolete Circle build requests and require the observed native check with no human review.
|
||||
|
||||
For marketing-website-cd, the prior Circle job only printed Hello World. Its former production role moved to KofTwentyTwo/cluster-gitops; validation does not re-enable that retired deployment path.
|
||||
|
||||
The shared registry includes marketing-website-cd and voyage-cd. Daily enrollment recognizes their canonical main-branch caller without creating Circle configuration. Recognition requires a signed immutable worker pin matching the supported worker, a complete source tree, and no additional Circle or GitHub workflows. Enforcement requires the GitHub Actions app-bound gitops / validate gate and preserves existing branch rules. Unavailable private-repository protections remain an explicit enforcement failure; recognition alone is not enforcement.
|
||||
|
||||
|
||||
### Documentation repositories with shell automation
|
||||
|
||||
Use the canonical `repository-policy` manifest with `shell_checks: true` for
|
||||
repositories containing documentation, YAML/JSON, Mermaid source, and shell tools.
|
||||
The shared job remains one small executor with no publication or deployment.
|
||||
It installs ShellCheck only for this opt-in and checks every tracked `.sh` file
|
||||
with `bash -n` and ShellCheck at warning severity; scripts are never executed.
|
||||
Mermaid files are treated as UTF-8 documentation, not rendered or syntax-validated.
|
||||
Application manifests and other executable languages still require a build profile.
|
||||
|
||||
|
||||
### Homebrew distribution taps
|
||||
|
||||
The `homebrew-tap` profile takes only `tap` (lowercase owner/name) and `formula`.
|
||||
One small job in a digest-pinned Homebrew container validates the exact checkout,
|
||||
reads all OS/architecture variants, fetches their binaries with checksum verification,
|
||||
then installs and tests the Linux formula. It does not publish or update formulae.
|
||||
macOS downloads are verified, but this Linux job does not execute macOS binaries.
|
||||
|
||||
|
||||
### Application template acceptance
|
||||
|
||||
The `application-template` profile renders the checked-out template through pinned
|
||||
qctl code and a checksum-verified catalog. It runs transforms but never post-generation
|
||||
hooks, then performs Maven verify on the generated application with all its tests.
|
||||
The renderer and Maven dependencies are cached; test reports and the generated JAR
|
||||
are retained. This is acceptance of a generated consumer, not Maven publication.
|
||||
Only the standard profile, orb version, and default branch are consumer settings.
|
||||
|
||||
The coordinator also recognizes qctl on main/develop and the approved .github,
|
||||
business-platform, MCP-RAG and IntelliJ callers on main. It verifies each complete
|
||||
workflow inventory, canonical caller, signed immutable orb pin and matching shared
|
||||
worker source before recognizing the repository. Native verification gates bind to
|
||||
the GitHub Actions app; release-only jobs are not merge requirements. No CircleCI
|
||||
caller is added to these native consumers. qctl requires its shared tests; the native binary job is push-only, and
|
||||
full platform release builds retain their existing shared-worker policy.
|
||||
|
||||
Existing classic branch protections without a required-status-check section gain
|
||||
an additive shared ruleset. Signing, reviews, history and access restrictions remain
|
||||
unchanged, and a subsequent reconciliation verifies the effective ruleset.
|
||||
@@ -12,7 +12,7 @@ text = source.read_text(encoding="utf-8")
|
||||
start = text.index("# BEGIN PROFILE RESOURCES")
|
||||
end = text.index("# END PROFILE RESOURCES") + len("# END PROFILE RESOURCES")
|
||||
embedded = ["# Generated by scripts/pack_pipeline.py; edit source/resources, then regenerate.", "import base64", "import zlib"]
|
||||
for variable, name in (("CORE_TEMPLATE", "core"), ("MATERIAL_TEMPLATE", "frontend-material"), ("VOYAGE_TEMPLATE", "voyage"), ("NEXT_TEMPLATE", "frontend-next"), ("ALL_TEMPLATE", "all"), ("STARTER_TEMPLATE", "app-starter"), ("ANDROID_TEMPLATE", "android"), ("POLICY_TEMPLATE", "mcp-policy"), ("REPOSITORY_POLICY_TEMPLATE", "repository-policy"), ("MARKETING_TEMPLATE", "marketing")):
|
||||
for variable, name in (("CORE_TEMPLATE", "core"), ("MATERIAL_TEMPLATE", "frontend-material"), ("VOYAGE_TEMPLATE", "voyage"), ("NEXT_TEMPLATE", "frontend-next"), ("ALL_TEMPLATE", "all"), ("STARTER_TEMPLATE", "app-starter"), ("ANDROID_TEMPLATE", "android"), ("POLICY_TEMPLATE", "mcp-policy"), ("REPOSITORY_POLICY_TEMPLATE", "repository-policy"), ("MARKETING_TEMPLATE", "marketing"), ("HOMEBREW_TEMPLATE", "homebrew-tap"), ("APPLICATION_TEMPLATE", "application-template")):
|
||||
resource = (source.parent / "templates" / (name + ".json")).read_text(encoding="utf-8").encode("utf-8")
|
||||
payload = base64.b64encode(zlib.compress(resource, level=9)).decode("ascii")
|
||||
embedded.append(f'{variable} = json.loads(zlib.decompress(base64.b64decode("{payload}")))')
|
||||
|
||||
@@ -25,6 +25,8 @@ ANDROID_TEMPLATE = json.loads((_TEMPLATE_DIR / "android.json").read_text(encodin
|
||||
POLICY_TEMPLATE = json.loads((_TEMPLATE_DIR / "mcp-policy.json").read_text(encoding="utf-8"))
|
||||
REPOSITORY_POLICY_TEMPLATE = json.loads((_TEMPLATE_DIR / "repository-policy.json").read_text(encoding="utf-8"))
|
||||
MARKETING_TEMPLATE = json.loads((_TEMPLATE_DIR / "marketing.json").read_text(encoding="utf-8"))
|
||||
HOMEBREW_TEMPLATE = json.loads((_TEMPLATE_DIR / "homebrew-tap.json").read_text(encoding="utf-8"))
|
||||
APPLICATION_TEMPLATE = json.loads((_TEMPLATE_DIR / "application-template.json").read_text(encoding="utf-8"))
|
||||
# END PROFILE RESOURCES
|
||||
|
||||
|
||||
@@ -70,10 +72,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", "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", "node-artifact", "homebrew-tap", "application-template"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile == "node-artifact":
|
||||
if profile == "homebrew-tap":
|
||||
allowed = ("profile", "orb_version", "default_branch", "tap", "formula")
|
||||
elif 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")
|
||||
@@ -81,7 +85,7 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
elif profile == "cli":
|
||||
allowed += ("publish_context",)
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "application-template"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -89,6 +93,8 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("node_version",)
|
||||
if profile == "frontend-material":
|
||||
allowed += ("java_version",)
|
||||
if profile == "repository-policy":
|
||||
allowed += ("shell_checks",)
|
||||
mapping(data, allowed, "manifest")
|
||||
version = data.get("orb_version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
@@ -100,6 +106,14 @@ def load_manifest(path, setup_version):
|
||||
raise ManifestError("default_branch must be main or develop")
|
||||
if profile == "marketing" and default_branch != "main":
|
||||
raise ManifestError("Marketing requires the audited main production branch")
|
||||
if profile == "homebrew-tap":
|
||||
tap, formula = data.get("tap"), data.get("formula")
|
||||
if not isinstance(tap, str) or not re.fullmatch(r"[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*", tap):
|
||||
raise ManifestError("Homebrew requires an explicit lowercase owner/tap")
|
||||
if not isinstance(formula, str) or not re.fullmatch(r"[a-z0-9][a-z0-9+@._-]*", formula):
|
||||
raise ManifestError("Homebrew requires a literal formula name")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"tap": tap, "formula": formula}
|
||||
java = data.get("java_version", "21")
|
||||
if java not in ("17", "21"):
|
||||
raise ManifestError("java_version must be the string 17 or 21")
|
||||
@@ -155,12 +169,13 @@ def load_manifest(path, setup_version):
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"java_version": java, "node_version": node, "browsers": boolean(data, "browsers", True),
|
||||
"api_checks": boolean(data, "api_checks", False),
|
||||
"shell_checks": boolean(data, "shell_checks", False),
|
||||
"release_completion": boolean(data, "release_completion", False),
|
||||
"release_on_main": boolean(data, "release_on_main", False),
|
||||
"release_tag_policy": tag_policy, "test_branch_policy": test_policy,
|
||||
"docs_only": boolean(data, "docs_only", False),
|
||||
"publish_context": publish_context,
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy", "application-template")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
for key in publish_keys}}
|
||||
|
||||
@@ -483,11 +498,31 @@ def voyage_template(config, branch, tag):
|
||||
|
||||
|
||||
def repository_policy_template(config, branch, tag):
|
||||
del branch, tag
|
||||
result = copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
if config.get("shell_checks", False):
|
||||
job = result["jobs"]["validate-policy"]
|
||||
job["environment"] = {"QQQ_POLICY_SHELL": "true"}
|
||||
job["steps"].insert(1, {"run": {
|
||||
"name": "Install static shell validation",
|
||||
"command": "sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends shellcheck"}})
|
||||
return result
|
||||
|
||||
|
||||
def homebrew_template(config, branch, tag):
|
||||
del branch, tag
|
||||
result = copy.deepcopy(HOMEBREW_TEMPLATE)
|
||||
result["jobs"]["validate-tap"]["environment"].update({
|
||||
"QQQ_HOMEBREW_TAP": config["tap"], "QQQ_HOMEBREW_FORMULA": config["formula"]})
|
||||
return result
|
||||
|
||||
|
||||
def application_template(config, branch, tag):
|
||||
del config, branch, tag
|
||||
return copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
return copy.deepcopy(APPLICATION_TEMPLATE)
|
||||
|
||||
|
||||
PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
|
||||
PROFILE_TEMPLATES = {"application-template": application_template, "homebrew-tap": homebrew_template, "qbit": qbit_template, "core": core_template,
|
||||
"repository-policy": repository_policy_template,
|
||||
"frontend-material": frontend_template, "frontend-core": frontend_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}
|
||||
|
||||
@@ -24,8 +24,10 @@ ALL_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNq1T7EOgjAU3PmKpjNI
|
||||
STARTER_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNp1UMGKwkAMvc9XlDmKtejR0yJ42MsKCl5EQnUzZbbTiZ0ZqiL9d1OpWqt7y3t5eS/JRUSRrNB5TVZOo8loPGwYcjvP8MI1o7IsY2aYkLm2mXdEedKSXwCL5QzW8+Xqe/EDIHmkvnkcyeXK0LFjFNAHIGvOD4rJP7plbVocPTrd7KSoLHwab2V7Kg7aIOxQkUPgi7RqZCo1Hod9rQ14Ci+ZnbQirdDGDjPtgzvHe4e/aINmI/ki3/ZslTaBH/m2W3N3mn3iuaMzy/s2n01Gg0T2BLX4Dz3re7UVd1SLWlwByepyJQ==")))
|
||||
ANDROID_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtWG1v2zYQ/p5fQWgF6rSW3CXYMDhJ13YNkm5rkrrugKEKDFqiZCYUyZBUbC/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592Iv+CF45vULxjSSfsRoh7Hce7Ef7AV7HvCtnIYr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MuSaesmRC78a1sD7DklrvXmT0YARGCsLpQDOSuNadvtxoL/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+Ab4ltjElbMwKYxmtsGasscsiKO6QF66Mb9TnqaZU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j5TeEU271nU9gUJo7pSaPXA/y3oSNxiUqkTftVA1hDnnZbrlefrbk3EKCGlxirQI1KP8CVWIhZicvOERrpfQ1tqdWpq56ICEVPglO5XKcaawwXVTeleH7U26Lqr5cG9y+4voifiO8m9GLC73HubfLfoWdKtdxOtd42wjKjYvHnyHPc8YjGdELA9YYvL2+w0u1fJNevCFZvwUisTwt4kjZTPZXCByUa4XIdeVFyxvtDqbuavMdXu5EwMNsV0ucWbDarXn2/KWhQPa1tMRU2F67MTbq2hFGHCRYzxbs969jjwlg1qT6qR+XVR0Yzr+WbDGhRpUQ90GHcV5I4uxAJRKXTM9jpiYb0J4pz4gE7cWx7buBTPE5csk4Xj0Y5HOx7teLTj0TtU9Zui6XjvG+O9T0+Vdoy910ttHtIAjoo8jckddXhcozfXd/XpvajKdLPNayipNbfQR7vLSxnNdBq2m0Swqd9Uf+zH48bhBkg83liObnP3LTkOt1Z52FwooRvGtwbRbQcdNN4zjsBesoncYoKx4cimI5uObDqy6cjmLlW4LZqObDqy+dhkc7fYe8Vk8wEN4Mjm05jckc3HNbojm45sPnAE9pJNxTJGcctGvfHkSDVztNPRTkc7He10tPPOb640NdW9COw46vN+d/T/BepbezH0Cazl2O8L8I+jys/YQ45XO179gsK1PrSGzcqbY7XGkRb3E55ej/I7u+WFHrB/4nakUDKuoub06K5F3LWIuxZx1yLuWmTrNXVOuXBfxb+1aw531r53Hva03zbtkMZ3CpSqMN80hVFsjwabo6TGkSi2YbxW5G6Ge3/L5GyGu8j8bCaDKKuwkCiClU5iOemMwl2eKylyRNsUxxNez8S4Z+bUAqY4GZ4X/mU9qNUg7cRdsDVocYY2CjUTVOjSjg0aeNAubfPan9M8W5uBh6hlyNBRmb0E4p/MDP561DfIVtYvtSfgz8+vlzs8WPg6knZfhl4lXeZ/We1d7/0Hg+30Mg==")))
|
||||
HOMEBREW_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNqVVNtu2zAMfc9XCMYeNqBurk7SAgXmpRlaIM2lTVYM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tqAyJwhcAwZrsOCQHNuRD+tgvaT+TCdTuKKbN3T20NMDh8vXCe/gn7rVJqvDMvCv+mxRsJ0QMjzbeNbNR3aNw4vtaOHz5OW1GDuXzd4O1tTM3z++4l7cdGxp6V/7hT0yV60oSkTTBGz3ReCAodqilZl+7TTz/Zp83uOLn95Mn3ybQ9y94r/1nnT3faZ+xI4LidpqJNtx5vEMcL/fMjsLHeSVLEAMMszFigQ9R2qZKD8d/QoALm5ENn0HAVrubD5YsTliVTsISzf09SHaH/j2tSs9HdvSevb/th5G/vnRhptMDqKb5zhH3Ud+6w4a76sYyoGEoIQWv7Nm/Hihfjq5rxwL715e74t/dn9s/8DqAZZ8g==")))
|
||||
|
||||
|
||||
class ManifestError(ValueError):
|
||||
@@ -70,10 +72,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", "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", "node-artifact", "homebrew-tap", "application-template"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile == "node-artifact":
|
||||
if profile == "homebrew-tap":
|
||||
allowed = ("profile", "orb_version", "default_branch", "tap", "formula")
|
||||
elif 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")
|
||||
@@ -81,7 +85,7 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
elif profile == "cli":
|
||||
allowed += ("publish_context",)
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "application-template"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -89,6 +93,8 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("node_version",)
|
||||
if profile == "frontend-material":
|
||||
allowed += ("java_version",)
|
||||
if profile == "repository-policy":
|
||||
allowed += ("shell_checks",)
|
||||
mapping(data, allowed, "manifest")
|
||||
version = data.get("orb_version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
@@ -100,6 +106,14 @@ def load_manifest(path, setup_version):
|
||||
raise ManifestError("default_branch must be main or develop")
|
||||
if profile == "marketing" and default_branch != "main":
|
||||
raise ManifestError("Marketing requires the audited main production branch")
|
||||
if profile == "homebrew-tap":
|
||||
tap, formula = data.get("tap"), data.get("formula")
|
||||
if not isinstance(tap, str) or not re.fullmatch(r"[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*", tap):
|
||||
raise ManifestError("Homebrew requires an explicit lowercase owner/tap")
|
||||
if not isinstance(formula, str) or not re.fullmatch(r"[a-z0-9][a-z0-9+@._-]*", formula):
|
||||
raise ManifestError("Homebrew requires a literal formula name")
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"tap": tap, "formula": formula}
|
||||
java = data.get("java_version", "21")
|
||||
if java not in ("17", "21"):
|
||||
raise ManifestError("java_version must be the string 17 or 21")
|
||||
@@ -155,12 +169,13 @@ def load_manifest(path, setup_version):
|
||||
return {"profile": profile, "orb_version": version, "default_branch": default_branch,
|
||||
"java_version": java, "node_version": node, "browsers": boolean(data, "browsers", True),
|
||||
"api_checks": boolean(data, "api_checks", False),
|
||||
"shell_checks": boolean(data, "shell_checks", False),
|
||||
"release_completion": boolean(data, "release_completion", False),
|
||||
"release_on_main": boolean(data, "release_on_main", False),
|
||||
"release_tag_policy": tag_policy, "test_branch_policy": test_policy,
|
||||
"docs_only": boolean(data, "docs_only", False),
|
||||
"publish_context": publish_context,
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy", "application-template")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
for key in publish_keys}}
|
||||
|
||||
@@ -483,11 +498,31 @@ def voyage_template(config, branch, tag):
|
||||
|
||||
|
||||
def repository_policy_template(config, branch, tag):
|
||||
del branch, tag
|
||||
result = copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
if config.get("shell_checks", False):
|
||||
job = result["jobs"]["validate-policy"]
|
||||
job["environment"] = {"QQQ_POLICY_SHELL": "true"}
|
||||
job["steps"].insert(1, {"run": {
|
||||
"name": "Install static shell validation",
|
||||
"command": "sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends shellcheck"}})
|
||||
return result
|
||||
|
||||
|
||||
def homebrew_template(config, branch, tag):
|
||||
del branch, tag
|
||||
result = copy.deepcopy(HOMEBREW_TEMPLATE)
|
||||
result["jobs"]["validate-tap"]["environment"].update({
|
||||
"QQQ_HOMEBREW_TAP": config["tap"], "QQQ_HOMEBREW_FORMULA": config["formula"]})
|
||||
return result
|
||||
|
||||
|
||||
def application_template(config, branch, tag):
|
||||
del config, branch, tag
|
||||
return copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
return copy.deepcopy(APPLICATION_TEMPLATE)
|
||||
|
||||
|
||||
PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
|
||||
PROFILE_TEMPLATES = {"application-template": application_template, "homebrew-tap": homebrew_template, "qbit": qbit_template, "core": core_template,
|
||||
"repository-policy": repository_policy_template,
|
||||
"frontend-material": frontend_template, "frontend-core": frontend_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}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"version": 2.1,
|
||||
"jobs": {
|
||||
"verify-template": {
|
||||
"docker": [
|
||||
{
|
||||
"image": "cimg/openjdk:21.0"
|
||||
}
|
||||
],
|
||||
"resource_class": "medium",
|
||||
"steps": [
|
||||
"checkout",
|
||||
{
|
||||
"restore_cache": {
|
||||
"keys": [
|
||||
"qqq-template-v1-java21-d84a5783bf09c58e42ba72203247f20bd5779302"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": {
|
||||
"name": "Prepare pinned qctl renderer",
|
||||
"command": "set -euo pipefail\ntool_dir=\"${QQQ_TEMPLATE_TOOL_DIR:-$HOME/.cache/qqq-template-renderer}\"\nmaven_repo=\"${QQQ_TEMPLATE_MAVEN_REPO:-$HOME/.m2/repository}\"\nif [[ ! -d \"$tool_dir/.git\" ]]; then\n git init \"$tool_dir\"\n git -C \"$tool_dir\" remote add origin https://github.com/QRun-IO/qctl.git\n git -C \"$tool_dir\" fetch --depth=1 origin d84a5783bf09c58e42ba72203247f20bd5779302\n git -C \"$tool_dir\" checkout --detach FETCH_HEAD\nfi\ntest \"$(git -C \"$tool_dir\" rev-parse HEAD)\" = d84a5783bf09c58e42ba72203247f20bd5779302\ncd \"$tool_dir\"\n# Build the immutable, already-qualified renderer, not another copy of the consumer.\nif [[ ! -f \"$tool_dir/qctl-qqq/target/qctl-qqq-0.2.1.jar\" || ! -f \"$maven_repo/io/qrun/qctl/qctl-qqq/0.2.1/qctl-qqq-0.2.1.pom\" ]]; then\n mvn -B -ntp -f \"$tool_dir/pom.xml\" -Dmaven.repo.local=\"$maven_repo\" -pl qctl-qqq -am install -DskipTests\nfi\nmvn -B -ntp -f \"$tool_dir/pom.xml\" -Dmaven.repo.local=\"$maven_repo\" -pl qctl-qqq dependency:build-classpath -Dmdep.outputFile=\"$tool_dir/classpath.txt\"\n",
|
||||
"no_output_timeout": "10m"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": {
|
||||
"name": "Render the exact template checkout without hooks",
|
||||
"command": "set -euo pipefail\ntool_dir=\"${QQQ_TEMPLATE_TOOL_DIR:-$HOME/.cache/qqq-template-renderer}\"\noutput=\"${QQQ_TEMPLATE_OUTPUT:-$HOME/qqq-template-acceptance}\"\nwork=\"${QQQ_TEMPLATE_WORK:-/tmp/qqq-template-check}\"\nmkdir -p \"$work\"\ncurl --fail --silent --show-error --location --retry 2 --max-time 60 https://raw.githubusercontent.com/QRun-IO/qqq-templates-hub/4d22fc650967eee609107476d5dc3ac5dffeb071/templates.yaml -o \"$work/catalog.yaml\"\necho \"9342ef716f11ffea25a684fba6865e4daf303d968b5fa6a1ddcc6de43a6bb193 $work/catalog.yaml\" | sha256sum --check --status\ncat > \"$work/QqqTemplateCheck.java\" \\<<'JAVA'\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\nimport com.fasterxml.jackson.databind.JsonNode;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.dataformat.yaml.YAMLFactory;\nimport io.qrun.qctl.qqq.template.TemplateEngine;\nimport io.qrun.qctl.qqq.template.TemplateManifest;\nimport io.qrun.qctl.qqq.template.TransformExecutor;\n\npublic class QqqTemplateCheck\n{\n public static void main(String[] args) throws Exception\n {\n if(args.length != 3)\n {\n throw new IllegalArgumentException(\"Expected catalog, checked-out template, fresh output directory\");\n }\n Path output = Path.of(args[2]);\n if(Files.exists(output))\n {\n throw new IllegalArgumentException(\"Output directory must not exist\");\n }\n ObjectMapper mapper = new ObjectMapper(new YAMLFactory());\n JsonNode index = mapper.readTree(Path.of(args[0]).toFile());\n TemplateManifest manifest = null;\n for(JsonNode entry : index.get(\"templates\"))\n {\n if(\"new-qqq-application\".equals(entry.path(\"id\").asText()))\n {\n if(manifest != null) throw new IllegalArgumentException(\"Duplicate template entry\");\n manifest = mapper.treeToValue(entry, TemplateManifest.class);\n }\n }\n if(manifest == null) throw new IllegalArgumentException(\"Template missing from catalog\");\n TemplateEngine engine = new TemplateEngine();\n Map<String, String> variables = new LinkedHashMap<>(Map.of(\n \"projectName\", \"ci-template\", \"groupId\", \"io.qrun.ci\",\n \"artifactId\", \"ci-template\", \"packageName\", \"io.qrun.ci\"));\n variables = engine.evaluateComputed(manifest.computed(), variables);\n Files.createDirectories(output);\n int count = engine.render(Path.of(args[1]), output, variables, manifest);\n if(manifest.transforms() != null)\n {\n new TransformExecutor().execute(output, manifest.transforms(), variables);\n }\n if(count == 0 || !Files.isRegularFile(output.resolve(\"pom.xml\")))\n {\n throw new IllegalStateException(\"Renderer did not create the application\");\n }\n System.out.println(\"Rendered \" + count + \" files from the exact local template; hooks not executed\");\n }\n}\nJAVA\njava -cp \"$(cat \"$tool_dir/classpath.txt\"):$tool_dir/qctl-qqq/target/classes\" \"$work/QqqTemplateCheck.java\" \"$work/catalog.yaml\" \"$PWD\" \"$output\"\n"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": {
|
||||
"name": "Verify generated application and package",
|
||||
"command": "set -euo pipefail\nmvn -B -ntp -f \"${QQQ_TEMPLATE_OUTPUT:-$HOME/qqq-template-acceptance}/pom.xml\" -Dmaven.repo.local=\"${QQQ_TEMPLATE_MAVEN_REPO:-$HOME/.m2/repository}\" verify\n",
|
||||
"no_output_timeout": "10m"
|
||||
}
|
||||
},
|
||||
{
|
||||
"store_test_results": {
|
||||
"path": "~/qqq-template-acceptance/target/surefire-reports"
|
||||
}
|
||||
},
|
||||
{
|
||||
"store_artifacts": {
|
||||
"path": "~/qqq-template-acceptance/target/ci-template.jar",
|
||||
"destination": "generated-application.jar"
|
||||
}
|
||||
},
|
||||
{
|
||||
"save_cache": {
|
||||
"key": "qqq-template-v1-java21-d84a5783bf09c58e42ba72203247f20bd5779302",
|
||||
"paths": [
|
||||
"~/.m2/repository",
|
||||
"~/.cache/qqq-template-renderer"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"workflows": {
|
||||
"verify": {
|
||||
"jobs": [
|
||||
"verify-template"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": 2.1,
|
||||
"jobs": {
|
||||
"validate-tap": {
|
||||
"docker": [
|
||||
{
|
||||
"image": "ghcr.io/homebrew/brew@sha256:0e2563de582c530c92c55420cfa67e5b60bcb541781297ee34c6508ca6e746a3"
|
||||
}
|
||||
],
|
||||
"resource_class": "small",
|
||||
"working_directory": "/home/linuxbrew/project",
|
||||
"environment": {
|
||||
"HOMEBREW_NO_AUTO_UPDATE": "1",
|
||||
"HOMEBREW_NO_ANALYTICS": "1",
|
||||
"HOMEBREW_NO_INSTALL_CLEANUP": "1"
|
||||
},
|
||||
"steps": [
|
||||
"checkout",
|
||||
{
|
||||
"run": {
|
||||
"name": "Verify all platform downloads and install the exact tap revision",
|
||||
"no_output_timeout": "5m",
|
||||
"command": "set -euo pipefail\nbrew tap \"$QQQ_HOMEBREW_TAP\" \"$PWD\"\ntest \"$(git -C \"$(brew --repository \"$QQQ_HOMEBREW_TAP\")\" rev-parse HEAD)\" = \"$(git rev-parse HEAD)\"\nbrew trust \"$QQQ_HOMEBREW_TAP\"\nbrew readall --syntax --os=all --arch=all \"$QQQ_HOMEBREW_TAP\"\nbrew fetch --all-platforms --build-from-source \"$QQQ_HOMEBREW_TAP/$QQQ_HOMEBREW_FORMULA\"\nbrew install \"$QQQ_HOMEBREW_TAP/$QQQ_HOMEBREW_FORMULA\"\nbrew test \"$QQQ_HOMEBREW_TAP/$QQQ_HOMEBREW_FORMULA\"\n"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"workflows": {
|
||||
"verify": {
|
||||
"jobs": [
|
||||
"validate-tap"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
{
|
||||
"run": {
|
||||
"name": "Validate the application-free branch",
|
||||
"command": "python3 \\<<'PYTHON'\nimport json\nfrom pathlib import Path\nimport subprocess\nimport xml.etree.ElementTree as ET\nimport yaml\n\npaths = subprocess.check_output(['git', 'ls-files', '-z']).decode('utf-8').split('\\0')\npaths = [Path(name) for name in paths if name]\nif not paths:\n raise SystemExit('No tracked policy files')\nnames = {'LICENSE', 'NOTICE', 'COPYING', 'CODEOWNERS', '.gitignore', '.gitattributes',\n '.editorconfig', 'mvnw', 'mvnw.cmd'}\nsuffixes = {'.md', '.rst', '.txt', '.adoc', '.yml', '.yaml', '.json', '.properties'}\nmanifests = {'pom.xml', 'package.json', 'cargo.toml', 'pyproject.toml', 'go.mod',\n 'build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'}\nfor path in paths:\n if path.is_symlink() or path.name.lower() in manifests:\n raise SystemExit(f'Application or symlink requires a build profile: {path}')\n if path.as_posix() == '.mvn/wrapper/maven-wrapper.jar':\n continue\n if path.as_posix() == 'checkstyle/config.xml':\n ET.fromstring(path.read_text(encoding='utf-8'))\n continue\n if path.name not in names and path.suffix.lower() not in suffixes:\n raise SystemExit(f'Unsupported policy file; select a build profile: {path}')\n text = path.read_text(encoding='utf-8')\n if path.suffix.lower() in ('.yml', '.yaml'):\n list(yaml.safe_load_all(text))\n elif path.suffix.lower() == '.json':\n json.loads(text)\nprint(f'Validated {len(paths)} tracked policy/documentation files; no application build or publication')\nPYTHON\n"
|
||||
"command": "python3 \\<<'PYTHON'\nimport json\nimport os\nfrom pathlib import Path\nimport subprocess\nimport xml.etree.ElementTree as ET\nimport yaml\n\npaths = subprocess.check_output(['git', 'ls-files', '-z']).decode('utf-8').split('\\0')\npaths = [Path(name) for name in paths if name]\nif not paths:\n raise SystemExit('No tracked policy files')\nnames = {'LICENSE', 'NOTICE', 'COPYING', 'CODEOWNERS', '.gitignore', '.gitattributes',\n '.editorconfig', 'mvnw', 'mvnw.cmd'}\nshell_checks = os.environ.get('QQQ_POLICY_SHELL') == 'true'\nsuffixes = {'.md', '.rst', '.txt', '.adoc', '.yml', '.yaml', '.json', '.properties'}\nmanifests = {'pom.xml', 'package.json', 'cargo.toml', 'pyproject.toml', 'go.mod',\n 'build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'}\nfor path in paths:\n if path.is_symlink() or path.name.lower() in manifests:\n raise SystemExit(f'Application or symlink requires a build profile: {path}')\n if path.as_posix() == '.mvn/wrapper/maven-wrapper.jar':\n continue\n if path.as_posix() == 'checkstyle/config.xml':\n ET.fromstring(path.read_text(encoding='utf-8'))\n continue\n if shell_checks and path.suffix.lower() == '.sh':\n subprocess.run(['bash', '-n', '--', str(path)], check=True)\n subprocess.run(['shellcheck', '--severity=warning', '--', str(path)], check=True)\n continue\n if shell_checks and path.suffix.lower() == '.mmd':\n path.read_text(encoding='utf-8')\n continue\n if path.name not in names and path.suffix.lower() not in suffixes:\n raise SystemExit(f'Unsupported policy file; select a build profile: {path}')\n text = path.read_text(encoding='utf-8')\n if path.suffix.lower() in ('.yml', '.yaml'):\n list(yaml.safe_load_all(text))\n elif path.suffix.lower() == '.json':\n json.loads(text)\nprint(f'Validated {len(paths)} tracked policy/documentation files; no application build or publication')\nPYTHON\n"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -48,6 +48,8 @@ PROFILE_PARAMETERS = {
|
||||
"repository-policy": {},
|
||||
"marketing": {},
|
||||
"node-artifact": {},
|
||||
"homebrew-tap": {},
|
||||
"application-template": {},
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +69,7 @@ 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":
|
||||
if profile in ("node-artifact", "homebrew-tap", "application-template"):
|
||||
options["filters"]["tags"] = {"ignore": "/.*/"}
|
||||
if profile == "frontend-next":
|
||||
options["filters"]["branches"] = {"ignore": "/.*/"}
|
||||
|
||||
@@ -324,13 +324,32 @@ class AuditTests(unittest.TestCase):
|
||||
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in report['findings']])
|
||||
|
||||
def test_new_circle_profile_mappings_require_actual_configuration(self):
|
||||
for name, profile in [('qqq-android', 'android'), ('qqq-mcp-rag-standard-policies', 'mcp-policy'), ('marketing-website', 'marketing')]:
|
||||
for name, profile in [('qqq-android', 'android'), ('qqq-mcp-rag-standard-policies', 'mcp-policy'), ('marketing-website', 'marketing'), ('qqq-templates-hub', 'repository-policy'), ('qqq-meta-manager', 'repository-policy'), ('homebrew-qctl', 'homebrew-tap'), ('new-qqq-application-template', 'application-template')]:
|
||||
entry = dict(ENTRY, name=name, nameWithOwner='QRun-IO/' + name)
|
||||
report = audit.audit(entry, Snapshot({}), VERSION, SHA, {})
|
||||
self.assertEqual(profile, report['profile'])
|
||||
self.assertIn('missing_manifest', [f['code'] for f in report['findings']])
|
||||
self.assertIn('missing_canonical_caller', [f['code'] for f in report['findings']])
|
||||
|
||||
def test_catalog_requires_canonical_policy_pipeline(self):
|
||||
self.assertNotIn('QRun-IO/qqq-templates-hub', audit.NO_CI)
|
||||
entry = dict(ENTRY, name='qqq-templates-hub', nameWithOwner='QRun-IO/qqq-templates-hub')
|
||||
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({
|
||||
'profile': 'repository-policy', 'orb_version': VERSION, 'default_branch': 'main'}),
|
||||
'.circleci/config.yml': audit.generator.yaml.safe_dump(
|
||||
audit.standard.canonical_caller('repository-policy', VERSION)),
|
||||
'templates.yaml': 'version: 1.0'}
|
||||
policy = {'managed_branches': ['main'], 'required_checks': {'main': ['setup', 'verify']}}
|
||||
snapshot = Snapshot(files, ['setup', 'verify'])
|
||||
snapshot.branch = 'main'
|
||||
report = audit.audit(entry, snapshot, VERSION, SHA, policy)
|
||||
self.assertEqual('repository-policy', report['profile'])
|
||||
self.assertEqual([], report['findings'])
|
||||
self.assertEqual('pass', report['status'])
|
||||
files.pop('.circleci/config.yml')
|
||||
report = audit.audit(entry, snapshot, VERSION, SHA, policy)
|
||||
self.assertIn('missing_canonical_caller', [f['code'] for f in report['findings']])
|
||||
|
||||
def test_intellij_is_native_product_not_no_ci_exception(self):
|
||||
repository = 'QRun-IO/qqq-app-developer-intellij-plugin'
|
||||
self.assertNotIn(repository, audit.NO_CI)
|
||||
@@ -340,7 +359,7 @@ class AuditTests(unittest.TestCase):
|
||||
self.assertIn('missing_native_maintenance_bridge', [f['code'] for f in report['findings']])
|
||||
|
||||
def test_approved_no_ci_is_exact_allowlist_with_evidence_not_check_pass(self):
|
||||
self.assertEqual(7, len(audit.NO_CI))
|
||||
self.assertEqual(3, len(audit.NO_CI))
|
||||
self.assertNotIn("QRun-IO/voyage-cd", audit.NO_CI)
|
||||
for repository, policy in audit.NO_CI.items():
|
||||
entry = dict(ENTRY, name=repository.split('/')[-1], nameWithOwner=repository)
|
||||
|
||||
@@ -203,8 +203,21 @@ class EnforcementTests(unittest.TestCase):
|
||||
enforcement.verified_rulesets('QRun-IO/example', effective, lambda path: record)
|
||||
|
||||
def test_empty_push_allowlist_gains_ruleset_without_changing_access(self):
|
||||
classic = {'restrictions': {'users': [], 'teams': [], 'apps': []},
|
||||
'enforce_admins': {'enabled': False}, 'required_signatures': {'enabled': True}}
|
||||
self.assert_ruleset_preserves_classic({
|
||||
'restrictions': {'users': [], 'teams': [], 'apps': []},
|
||||
'enforce_admins': {'enabled': False}, 'required_signatures': {'enabled': True}})
|
||||
|
||||
def test_existing_protection_without_status_section_gains_ruleset(self):
|
||||
for admin in (False, True):
|
||||
with self.subTest(enforce_admins=admin):
|
||||
self.assert_ruleset_preserves_classic({
|
||||
'enforce_admins': {'enabled': admin},
|
||||
'required_signatures': {'enabled': True},
|
||||
'required_linear_history': {'enabled': True},
|
||||
'required_pull_request_reviews': {'required_approving_review_count': 2},
|
||||
'required_conversation_resolution': {'enabled': True}})
|
||||
|
||||
def assert_ruleset_preserves_classic(self, classic):
|
||||
state = {'ruleset': None, 'writes': []}
|
||||
|
||||
def request(path, method='GET', payload=None):
|
||||
@@ -241,7 +254,6 @@ class EnforcementTests(unittest.TestCase):
|
||||
self.assertEqual(1, len(state['writes']))
|
||||
self.assertEqual([], state['writes'][0]['bypass_actors'])
|
||||
self.assertEqual({'include': ['refs/heads/main'], 'exclude': []}, state['writes'][0]['conditions']['ref_name'])
|
||||
self.assertFalse(plan['before']['enforce_admins']['enabled'])
|
||||
self.assertEqual(classic, plan['before'])
|
||||
repeat = enforcement.inspect('QRun-IO/example', 'main', '0.8', request)
|
||||
self.assertFalse(repeat['changed'])
|
||||
|
||||
@@ -32,6 +32,8 @@ class EnrollmentTests(unittest.TestCase):
|
||||
if profile == 'node-artifact':
|
||||
data.update(context='registry', npm_scopes=['@example'], node_version='20.19',
|
||||
artifact_path='dist/bundle.js', build_branches=['main'])
|
||||
if profile == 'homebrew-tap':
|
||||
data.update(tap='qrun-io/qctl', formula='qctl')
|
||||
(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')
|
||||
|
||||
@@ -378,6 +378,72 @@ class PipelineTests(unittest.TestCase):
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="", CIRCLE_TAG="publish-test"))
|
||||
|
||||
def test_application_template_source_and_packed_is_exact_source_acceptance(self):
|
||||
self.write_manifest(profile="application-template")
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
result = self.render(packed=packed, CIRCLE_BRANCH="main")
|
||||
self.assertEqual({"verify": {"jobs": ["verify-template"]}}, result["workflows"])
|
||||
self.assertEqual({"verify-template"}, set(result["jobs"]))
|
||||
job = result["jobs"]["verify-template"]
|
||||
self.assertEqual("cimg/openjdk:21.0", job["docker"][0]["image"])
|
||||
runs = [step["run"]["command"] for step in job["steps"] if isinstance(step, dict) and "run" in step]
|
||||
self.assertEqual(3, len(runs))
|
||||
self.assertIn('"$PWD" "$output"', runs[1])
|
||||
self.assertIn('engine.render(Path.of(args[1])', runs[1])
|
||||
self.assertNotIn('PostGenExecutor', runs[1])
|
||||
self.assertIn(' verify', runs[2])
|
||||
self.assertNotIn('skipTests', runs[2])
|
||||
self.assertNotIn('deploy', runs[2])
|
||||
for invalid in ({"publish": {"release": True}}, {"command": "true"}, {"renderer_sha": "main"}):
|
||||
self.write_manifest(profile="application-template", **invalid)
|
||||
self.render(ok=False)
|
||||
|
||||
def test_template_uncached_renderer_build_runs_in_renderer_directory(self):
|
||||
self.write_manifest(profile="application-template")
|
||||
tool = self.root / "renderer"
|
||||
(tool / ".git").mkdir(parents=True)
|
||||
binaries = self.root / "bin"
|
||||
binaries.mkdir()
|
||||
commands = {
|
||||
"git": "#!/bin/bash\nprintf '%s\\n' d84a5783bf09c58e42ba72203247f20bd5779302\n",
|
||||
"mvn": '#!/bin/bash\nset -eu\ntest "$PWD" = "$QQQ_TEMPLATE_TOOL_DIR"\nprintf "%s\\n" "$*" >> "$MAVEN_CALLS"\n',
|
||||
}
|
||||
for name, script in commands.items():
|
||||
path = binaries / name
|
||||
path.write_text(script, encoding="utf-8")
|
||||
path.chmod(0o755)
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
with self.subTest(packed=packed):
|
||||
result = self.render(packed=packed, CIRCLE_BRANCH="main")
|
||||
bootstrap = next(step["run"]["command"] for step in result["jobs"]["verify-template"]["steps"]
|
||||
if isinstance(step, dict) and "run" in step)
|
||||
calls = self.root / ("maven-packed.log" if packed else "maven-source.log")
|
||||
env = {**self.env, "PATH": str(binaries) + os.pathsep + os.environ["PATH"],
|
||||
"QQQ_TEMPLATE_TOOL_DIR": str(tool), "QQQ_TEMPLATE_MAVEN_REPO": str(self.root / "m2"),
|
||||
"MAVEN_CALLS": str(calls)}
|
||||
completed = subprocess.run(["bash", "-c", bootstrap], cwd=self.repo, env=env,
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(0, completed.returncode, completed.stderr)
|
||||
invoked = calls.read_text().splitlines()
|
||||
self.assertEqual(2, len(invoked))
|
||||
self.assertIn(" install ", invoked[0])
|
||||
self.assertIn("dependency:build-classpath", invoked[1])
|
||||
|
||||
def test_homebrew_source_and_packed_is_one_nonpublishing_job(self):
|
||||
self.write_manifest(profile="homebrew-tap", tap="qrun-io/qctl", formula="qctl")
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
result = self.render(packed=packed, CIRCLE_BRANCH="main")
|
||||
self.assertEqual({"verify": {"jobs": ["validate-tap"]}}, result["workflows"])
|
||||
self.assertEqual({"validate-tap"}, set(result["jobs"]))
|
||||
job = result["jobs"]["validate-tap"]
|
||||
self.assertEqual("small", job["resource_class"])
|
||||
self.assertEqual("qrun-io/qctl", job["environment"]["QQQ_HOMEBREW_TAP"])
|
||||
self.assertIn("@sha256:", job["docker"][0]["image"])
|
||||
for invalid in ({"tap": "qrun-io/qctl;echo bad"}, {"formula": "../qctl"},
|
||||
{"publish": {"release": True}}, {"command": "true"}):
|
||||
self.write_manifest(profile="homebrew-tap", **dict({"tap": "qrun-io/qctl", "formula": "qctl"}, **invalid))
|
||||
self.render(ok=False)
|
||||
|
||||
def test_repository_policy_source_and_packed_never_select_publication(self):
|
||||
self.write_manifest(profile="repository-policy")
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
@@ -387,6 +453,15 @@ class PipelineTests(unittest.TestCase):
|
||||
self.assertEqual({"validate-policy"}, set(result["jobs"]))
|
||||
self.assertNotIn("orbs", result)
|
||||
|
||||
def test_repository_shell_option_source_and_packed(self):
|
||||
self.write_manifest(profile="repository-policy", shell_checks=True)
|
||||
for packed in ([False, True] if PACKED else [False]):
|
||||
result = self.render(packed=packed, CIRCLE_BRANCH="main")
|
||||
self.assertEqual({"verify": {"jobs": ["validate-policy"]}}, result["workflows"])
|
||||
self.assertEqual({"QQQ_POLICY_SHELL": "true"}, result["jobs"]["validate-policy"]["environment"])
|
||||
self.write_manifest(profile="repository-policy", shell_checks="true")
|
||||
self.render(ok=False)
|
||||
|
||||
def test_stable_tags_require_ascii_digits_in_source_and_packed_generator(self):
|
||||
tag = "v\u0661.\u0662.\u0663"
|
||||
self.git("tag", tag)
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
"""Native recognition proves central ownership and app-bound verification gates."""
|
||||
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 native_specialist_gates as native
|
||||
import reconcile_enrollment as remote
|
||||
import enforce_orb_checks as enforcement
|
||||
import finish_enrollment as finish
|
||||
|
||||
|
||||
class NativeTests(unittest.TestCase):
|
||||
def fixture(self, repo):
|
||||
self.repo, self.pin, self.head = repo, 'a' * 40, 'b' * 40
|
||||
self.profile, self.branches, kinds, _ = native.DEFINITIONS[repo]
|
||||
self.callers = dict(native.caller(kind, self.pin) for kind in kinds)
|
||||
self.paths = list(self.callers)
|
||||
self.signed, self.drift, self.truncated = True, False, False
|
||||
self.mode = '100644'
|
||||
self.runs = [{'id': i, 'name': gate['context'], 'app': {'id': gate['app_id']},
|
||||
'status': 'completed', 'conclusion': 'success'}
|
||||
for i, gate in enumerate(native.gates(self.profile))]
|
||||
self.before = {'required_status_checks': {'strict': True, 'checks': native.gates(self.profile)},
|
||||
'enforce_admins': {'enabled': True}}
|
||||
|
||||
def request(self, path, method='GET', payload=None):
|
||||
self.assertEqual('GET', method)
|
||||
if '/contents/' in path:
|
||||
self.assertNotIn('.circleci/', path)
|
||||
file = path.split('/contents/')[1].split('?')[0]
|
||||
if path.startswith('repos/QRun-IO/qqq-orb/'):
|
||||
raw = (ROOT / file).read_text() + ('# changed' if self.drift else '')
|
||||
else:
|
||||
raw = yaml.safe_dump(self.callers[file], sort_keys=False)
|
||||
return {'type': 'file', 'encoding': 'base64', 'content': base64.b64encode(raw.encode()).decode()}
|
||||
if '/git/trees/' in path:
|
||||
return {'truncated': self.truncated, 'tree': [{'path': p, 'type': 'blob', 'mode': self.mode} for p in self.paths]}
|
||||
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 path.endswith('/protection'):
|
||||
return copy.deepcopy(self.before)
|
||||
if '/rules/branches/' in path:
|
||||
return []
|
||||
if '/branches/' in path:
|
||||
return {'commit': {'sha': self.head}}
|
||||
return {'archived': False, 'default_branch': 'main'}
|
||||
|
||||
def test_all_approved_callers_discover_enforce_and_qualify_without_mutation(self):
|
||||
for repo in native.DEFINITIONS:
|
||||
self.fixture(repo)
|
||||
for branch in self.branches:
|
||||
with self.subTest(repo=repo, branch=branch), mock.patch.object(remote, 'api', side_effect=self.request):
|
||||
plan = remote.inspect({'repository': repo, 'branch': branch}, '0.8')
|
||||
self.assertEqual(self.profile, plan['profile'])
|
||||
self.assertFalse(plan['changed'])
|
||||
self.assertEqual(set(self.callers), set(plan['worker_pins']))
|
||||
self.assertEqual({'state': 'unchanged'}, remote.apply(plan))
|
||||
self.assertEqual({'state': 'unchanged'}, finish.merge_ready(plan, {'state': 'unchanged'}))
|
||||
self.assertEqual([], finish.qualification(repo, self.head, self.profile))
|
||||
protected = enforcement.inspect(repo, branch, '0.8', self.request)
|
||||
self.assertFalse(protected['changed'])
|
||||
enforcement.enforce(protected, self.request)
|
||||
|
||||
def test_failed_missing_wrong_app_and_newer_failed_gate_reject(self):
|
||||
for repo in native.DEFINITIONS:
|
||||
self.fixture(repo)
|
||||
good = copy.deepcopy(self.runs)
|
||||
for bad in [[], good[1:], [dict(x, app={'id': 18001}) for x in good],
|
||||
good + [dict(good[0], id=99, conclusion='failure')]]:
|
||||
self.runs = bad
|
||||
with self.subTest(repo=repo), self.assertRaises(ValueError):
|
||||
enforcement.inspect(repo, 'main', '0.8', self.request)
|
||||
|
||||
def test_custom_caller_unsigned_or_changed_worker_rejects(self):
|
||||
for repo in native.DEFINITIONS:
|
||||
for defect in ('caller', 'unsigned', 'worker', 'mutable'):
|
||||
self.fixture(repo)
|
||||
if defect == 'caller':
|
||||
next(iter(self.callers.values()))['extra'] = True
|
||||
elif defect == 'unsigned':
|
||||
self.signed = False
|
||||
elif defect == 'worker':
|
||||
self.drift = True
|
||||
else:
|
||||
jobs = next(iter(self.callers.values()))['jobs']
|
||||
job = next(iter(jobs.values()))
|
||||
job['uses'] = job['uses'].replace(self.pin, 'main')
|
||||
with self.subTest(repo=repo, defect=defect), self.assertRaises(ValueError):
|
||||
native.validate(repo, self.head, 'main', self.request)
|
||||
|
||||
def test_complete_workflow_inventory_required(self):
|
||||
self.fixture('QRun-IO/qqq-business-platform')
|
||||
for path in ('.circleci/config.yml', '.github/workflows/custom.yml', '.github/workflows/extra.yaml'):
|
||||
self.paths.append(path)
|
||||
with self.assertRaisesRegex(ValueError, 'additional orchestration'):
|
||||
native.validate(self.repo, self.head, 'main', self.request)
|
||||
self.paths.pop()
|
||||
self.truncated = True
|
||||
with self.assertRaisesRegex(ValueError, 'complete source tree'):
|
||||
native.validate(self.repo, self.head, 'main', self.request)
|
||||
|
||||
def test_symlinked_or_missing_caller_rejects(self):
|
||||
self.fixture('QRun-IO/qctl')
|
||||
self.mode = '120000'
|
||||
with self.assertRaisesRegex(ValueError, 'regular source file'):
|
||||
native.validate(self.repo, self.head, 'main', self.request)
|
||||
self.paths = []
|
||||
with self.assertRaisesRegex(ValueError, 'regular source file'):
|
||||
native.validate(self.repo, self.head, 'main', self.request)
|
||||
|
||||
def test_unknown_repo_and_unapproved_branch_reject(self):
|
||||
self.fixture('QRun-IO/qqq-mcp-rag')
|
||||
for repo, branch in [('QRun-IO/unknown', 'main'), (self.repo, 'develop'), ('QRun-IO/qctl', 'release/old')]:
|
||||
with self.assertRaises(ValueError):
|
||||
native.validate(repo, self.head, branch, self.request)
|
||||
|
||||
def test_qctl_pr_gate_excludes_push_only_native_binary_job(self):
|
||||
worker = native.load_workflow((ROOT / '.github/workflows/qctl-native.yml').read_text())
|
||||
self.assertNotIn('if', worker['jobs']['test'])
|
||||
self.assertEqual("github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.full_native)",
|
||||
worker['jobs']['build-native']['if'])
|
||||
self.assertEqual([{'context': 'native / test', 'app_id': 15368}], native.gates('qctl'))
|
||||
|
||||
def test_github_yaml_events_and_duplicate_keys(self):
|
||||
self.assertEqual({'on': {'push': None}, 'enabled': True},
|
||||
native.load_workflow('on:\n push:\nenabled: true\n'))
|
||||
for raw in ('on: {}\non: {}\n', 'jobs: {build: {}, build: {}}\n', '1: value\n'):
|
||||
with self.subTest(raw=raw), self.assertRaises(ValueError):
|
||||
native.load_workflow(raw)
|
||||
|
||||
def test_native_enforcement_preserves_other_required_checks(self):
|
||||
self.fixture('QRun-IO/qctl')
|
||||
self.before['required_status_checks']['checks'].append({'context': 'security', 'app_id': 15368})
|
||||
plan = enforcement.inspect(self.repo, 'main', '0.8', self.request)
|
||||
self.assertIn({'context': 'security', 'app_id': 15368}, plan['required_status_checks']['checks'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Execute the policy job against real git indexes, including application promotion."""
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -35,7 +36,7 @@ class RepositoryPolicyTests(unittest.TestCase):
|
||||
subprocess.run([sys.executable, str(root / 'scripts/pack_pipeline.py'), '--check'], check=True)
|
||||
self.assertEqual(packed, (root / 'src/scripts/packed_generate_pipeline.py').read_bytes())
|
||||
|
||||
def execute(self, files, untracked=None):
|
||||
def execute(self, files, untracked=None, shell_checks=False):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
subprocess.run(['git', 'init', '-q'], cwd=root, check=True)
|
||||
@@ -46,7 +47,8 @@ class RepositoryPolicyTests(unittest.TestCase):
|
||||
subprocess.run(['git', 'add', '.'], cwd=root, check=True)
|
||||
for name, content in (untracked or {}).items():
|
||||
(root / name).write_text(content, encoding='utf-8')
|
||||
return subprocess.run([sys.executable, '-c', SCRIPT], cwd=root, capture_output=True, text=True)
|
||||
env = dict(os.environ, QQQ_POLICY_SHELL='true' if shell_checks else 'false')
|
||||
return subprocess.run([sys.executable, '-c', SCRIPT], cwd=root, env=env, capture_output=True, text=True)
|
||||
|
||||
def test_placeholder_with_wrappers_and_workflows(self):
|
||||
result = self.execute({'LICENSE': 'Apache-2.0', 'docs/DESIGN.md': '# Planned application',
|
||||
@@ -74,6 +76,34 @@ class RepositoryPolicyTests(unittest.TestCase):
|
||||
def test_only_tracked_files_are_policy_inputs(self):
|
||||
self.assertEqual(0, self.execute({'README.md': '# Docs'}, {'main.py': 'temporary tool'}).returncode)
|
||||
|
||||
def test_shell_validation_is_opt_in_and_never_executes_scripts(self):
|
||||
files = {'automation/safe.sh': '#!/bin/bash\nexit 42\n', 'diagram.mmd': 'flowchart LR\n A-->B\n'}
|
||||
self.assertNotEqual(0, self.execute(files).returncode)
|
||||
result = self.execute(files, shell_checks=True)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
|
||||
def test_shell_validation_rejects_syntax_warnings_and_application_sources(self):
|
||||
for name, content in [('broken.sh', '#!/bin/bash\nif then\n'),
|
||||
('unsafe.sh', '#!/bin/bash\necho $unquoted\n'),
|
||||
('main.py', 'print(42)'), ('package.json', '{}')]:
|
||||
with self.subTest(name=name):
|
||||
self.assertNotEqual(0, self.execute({name: content}, shell_checks=True).returncode)
|
||||
|
||||
def test_shell_option_is_strict_and_keeps_single_small_nonpublishing_job(self):
|
||||
manifest = {'profile': 'repository-policy', 'orb_version': '0.8',
|
||||
'default_branch': 'main', 'shell_checks': True}
|
||||
with patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
config = pipeline.load_manifest('unused', '0.8')
|
||||
result = pipeline.repository_policy_template(config, 'main', '')
|
||||
self.assertFalse(any(config['publish'].values()))
|
||||
self.assertEqual({'validate-policy'}, set(result['jobs']))
|
||||
self.assertEqual('small', result['jobs']['validate-policy']['resource_class'])
|
||||
self.assertEqual({'QQQ_POLICY_SHELL': 'true'}, result['jobs']['validate-policy']['environment'])
|
||||
for overrides in ({'shell_checks': 'true'}, {'profile': 'qbit'}):
|
||||
with patch.object(Path, 'read_text', return_value=yaml.safe_dump(dict(manifest, **overrides))):
|
||||
with self.assertRaises(pipeline.ManifestError):
|
||||
pipeline.load_manifest('unused', '0.8')
|
||||
|
||||
def test_manifest_cannot_enable_publication(self):
|
||||
manifest = {'profile': 'repository-policy', 'orb_version': '0.7.14', 'default_branch': 'develop'}
|
||||
with patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
|
||||
@@ -23,6 +23,8 @@ class RolloutTests(unittest.TestCase):
|
||||
if profile == 'node-artifact':
|
||||
policy = {'context': 'registry', 'npm_scopes': ['@example'], 'node_version': '20.19',
|
||||
'artifact_path': 'dist/bundle.js', 'build_branches': ['main'], **policy}
|
||||
if profile == 'homebrew-tap':
|
||||
policy = {'tap': 'qrun-io/qctl', 'formula': 'qctl', **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'))
|
||||
|
||||
@@ -46,7 +46,7 @@ PROFILES = {'qqq': 'core', 'qqq-frontend-material-dashboard': 'frontend-material
|
||||
'qqq-android': 'android', 'qqq-mcp-rag-standard-policies': 'mcp-policy',
|
||||
'marketing-website': 'marketing', 'qqq-mcp-rag': 'native-mcp',
|
||||
'qqq-business-platform': 'native-business', '.github': 'native-workflow-lint',
|
||||
'qqq-orb': 'owner-bootstrap', 'marketing-website-cd': 'native-gitops', 'voyage-cd': 'native-gitops'}
|
||||
'new-qqq-application-template': 'application-template', 'homebrew-qctl': 'homebrew-tap', 'qqq-meta-manager': 'repository-policy', 'qqq-templates-hub': 'repository-policy', 'qqq-orb': 'owner-bootstrap', 'marketing-website-cd': 'native-gitops', 'voyage-cd': 'native-gitops'}
|
||||
NO_CI = json.loads((ROOT / 'tools/no-ci-policy.json').read_text(encoding='utf-8'))
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ 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', 'voyage')}
|
||||
'qbit', 'core', 'frontend-core', 'frontend-material', 'repository-policy', 'node-artifact', 'homebrew-tap', 'application-template', 'marketing', 'voyage')}
|
||||
PROFILE_GATES.update({'all': 'verify-and-smoke', 'cli': 'test_only',
|
||||
'app-starter': 'test_only', 'android': 'test-and-build',
|
||||
'mcp-policy': 'validate'})
|
||||
@@ -27,8 +27,15 @@ _gitops_spec = importlib.util.spec_from_file_location('native_gitops_gates', ROO
|
||||
gitops = importlib.util.module_from_spec(_gitops_spec)
|
||||
_gitops_spec.loader.exec_module(gitops)
|
||||
|
||||
_specialist_spec = importlib.util.spec_from_file_location('native_specialist_gates', ROOT / 'tools/native_specialist_gates.py')
|
||||
specialists = importlib.util.module_from_spec(_specialist_spec)
|
||||
_specialist_spec.loader.exec_module(specialists)
|
||||
PROFILES |= specialists.PROFILES
|
||||
|
||||
|
||||
def gates(profile):
|
||||
if profile in specialists.PROFILES:
|
||||
return specialists.gates(profile)
|
||||
if profile == 'native-gitops':
|
||||
return gitops.gates()
|
||||
if profile == 'frontend-next':
|
||||
@@ -115,7 +122,9 @@ def inspect(repo, branch, version, request=api):
|
||||
raise ValueError('Archived repository')
|
||||
prefix = root + '/branches/' + branch
|
||||
head = request(prefix)['commit']['sha']
|
||||
if repo in gitops.REPOSITORIES:
|
||||
if repo in specialists.DEFINITIONS:
|
||||
profile, _ = specialists.validate(repo, head, branch, request)
|
||||
elif repo in gitops.REPOSITORIES:
|
||||
gitops.validate(repo, head, branch, request, standard.load_yaml)
|
||||
profile = 'native-gitops'
|
||||
else:
|
||||
@@ -138,9 +147,13 @@ def inspect(repo, branch, version, request=api):
|
||||
rulesets, ruleset_strict = verified_rulesets(repo, rules, request, desired_gates) if rules else ([], False)
|
||||
before = request(prefix + '/protection')
|
||||
restrictions = (before or {}).get('restrictions')
|
||||
use_ruleset = (not rulesets and restrictions is not None
|
||||
missing_status_section = before is not None and before.get('required_status_checks') is None
|
||||
empty_push_allowlist = (restrictions is not None
|
||||
and not any(restrictions.get(kind) for kind in ('users', 'teams', 'apps'))
|
||||
and not (before or {}).get('enforce_admins', {}).get('enabled'))
|
||||
# GitHub cannot PATCH a missing status-check subresource. An additive ruleset
|
||||
# preserves the existing signing, review, history and access policies.
|
||||
use_ruleset = not rulesets and (missing_status_section or empty_push_allowlist)
|
||||
runs = []
|
||||
page = 1
|
||||
while True:
|
||||
|
||||
@@ -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'] in enforcement.specialists.PROFILES:
|
||||
enforcement.specialists.validate(repo, head, plan['branch'], remote.api)
|
||||
if plan['profile'] == 'native-gitops':
|
||||
enforcement.gitops.validate(repo, head, plan['branch'], remote.api, enforcement.standard.load_yaml)
|
||||
if plan['profile'] == 'frontend-next':
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
"""Recognize reviewed native consumers and their shared immutable orb workers."""
|
||||
import base64
|
||||
import importlib.util
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def module(name):
|
||||
spec = importlib.util.spec_from_file_location(name, ROOT / 'src/scripts' / (name + '.py'))
|
||||
result = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(result)
|
||||
return result
|
||||
|
||||
|
||||
auxiliary = module('generate_auxiliary_workflow')
|
||||
qctl = module('generate_qctl_workflow')
|
||||
standard = module('validate_standard')
|
||||
|
||||
|
||||
class WorkflowLoader(standard.UniqueLoader):
|
||||
# GitHub uses YAML 1.2: unquoted "on" is an event key, not a boolean.
|
||||
yaml_implicit_resolvers = {
|
||||
key: [(tag, pattern) for tag, pattern in values if tag != 'tag:yaml.org,2002:bool']
|
||||
for key, values in standard.UniqueLoader.yaml_implicit_resolvers.items()
|
||||
}
|
||||
|
||||
|
||||
WorkflowLoader.add_implicit_resolver('tag:yaml.org,2002:bool', re.compile(r'^(true|false)$', re.I), list('tTfF'))
|
||||
|
||||
|
||||
def load_workflow(raw):
|
||||
try:
|
||||
return yaml.load(raw, Loader=WorkflowLoader)
|
||||
except yaml.YAMLError as error:
|
||||
raise ValueError('Invalid native workflow YAML') from error
|
||||
|
||||
|
||||
# Only observed, mandatory verification gates; release-only jobs are not PR gates.
|
||||
DEFINITIONS = {
|
||||
'QRun-IO/qctl': ('qctl', ('main', 'develop'), ('qctl',),
|
||||
('native / test',)),
|
||||
'QRun-IO/.github': ('native-workflow-lint', ('main',), ('github-workflow-lint',),
|
||||
('actionlint / actionlint',)),
|
||||
'QRun-IO/qqq-business-platform': ('native-business', ('main',), ('business-db', 'business-e2e'),
|
||||
('validate / empty-database-migration', 'validate / Deployment gate / E2E passed')),
|
||||
'QRun-IO/qqq-mcp-rag': ('native-mcp', ('main',), ('mcp-rag',),
|
||||
('validate / Build and Test',)),
|
||||
'QRun-IO/qqq-app-developer-intellij-plugin': ('intellij-plugin', ('main',), ('intellij-plugin',),
|
||||
('plugin / build',)),
|
||||
}
|
||||
PROFILES = {definition[0] for definition in DEFINITIONS.values()}
|
||||
|
||||
|
||||
def gates(profile):
|
||||
names = next(definition[3] for definition in DEFINITIONS.values() if definition[0] == profile)
|
||||
return [{'context': name, 'app_id': 15368} for name in names]
|
||||
|
||||
|
||||
def caller(kind, pin):
|
||||
if kind == 'qctl':
|
||||
return '.github/workflows/build.yml', load_workflow(qctl.generate(pin))
|
||||
return auxiliary.BRIDGES[kind]['path'], auxiliary.canonical(kind, pin)
|
||||
|
||||
|
||||
def validate(repo, head, branch, request):
|
||||
if repo not in DEFINITIONS or branch not in DEFINITIONS[repo][1]:
|
||||
raise ValueError('Native recognition requires an approved repository and branch')
|
||||
profile, _, kinds, _ = DEFINITIONS[repo]
|
||||
|
||||
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')
|
||||
|
||||
paths, pins, verified = set(), {}, set()
|
||||
for kind in kinds:
|
||||
path, _ = caller(kind, '0' * 40)
|
||||
actual = load_workflow(content(repo, path, head))
|
||||
try:
|
||||
pin = next(iter(actual['jobs'].values()))['uses'].rsplit('@', 1)[1]
|
||||
_, expected = caller(kind, pin)
|
||||
except (KeyError, TypeError, IndexError, ValueError, AttributeError, StopIteration):
|
||||
raise ValueError('Native caller has no immutable orb pin') from None
|
||||
if actual != expected:
|
||||
raise ValueError('Native caller differs from the canonical shared bridge')
|
||||
if pin not in verified:
|
||||
commit = request('repos/QRun-IO/qqq-orb/commits/' + pin)
|
||||
if not commit['commit']['verification']['verified']:
|
||||
raise ValueError('Native worker commit is not verified')
|
||||
verified.add(pin)
|
||||
for job in expected['jobs'].values():
|
||||
worker = job['uses'].split('@')[0].removeprefix('QRun-IO/qqq-orb/')
|
||||
if content('QRun-IO/qqq-orb', worker, pin) != (ROOT / worker).read_text(encoding='utf-8'):
|
||||
raise ValueError('Pinned native worker differs from the supported contract')
|
||||
paths.add(path)
|
||||
pins[path] = pin
|
||||
tree = request(f'repos/{repo}/git/trees/{head}?recursive=1')
|
||||
if tree.get('truncated') is not False or not isinstance(tree.get('tree'), list):
|
||||
raise ValueError('Native recognition requires the complete source tree')
|
||||
entries = {entry['path']: entry for entry in tree['tree']}
|
||||
for path in paths:
|
||||
entry = entries.get(path, {})
|
||||
if entry.get('type') != 'blob' or entry.get('mode') not in ('100644', '100755'):
|
||||
raise ValueError('Native caller is missing or is not a regular source file')
|
||||
for entry in tree['tree']:
|
||||
path = entry['path']
|
||||
if path == '.circleci/config.yml' or (path.startswith('.github/workflows/')
|
||||
and path.endswith(('.yml', '.yaml')) and path not in paths):
|
||||
raise ValueError('Native repository has additional orchestration: ' + path)
|
||||
return profile, pins
|
||||
@@ -1,52 +1,4 @@
|
||||
{
|
||||
"QRun-IO/new-qqq-application-template": {
|
||||
"baseline_sha": "730a836a666535a361927d83f15720e91eb71541",
|
||||
"required_paths": [
|
||||
"README.md"
|
||||
],
|
||||
"forbidden_prefixes": [
|
||||
".circleci/",
|
||||
".github/workflows/"
|
||||
],
|
||||
"forbidden_paths": [
|
||||
".qqq-ci.yml",
|
||||
"Jenkinsfile",
|
||||
".gitlab-ci.yml"
|
||||
],
|
||||
"rationale": "Template source; core generated-consumer acceptance owns validation."
|
||||
},
|
||||
"QRun-IO/qqq-templates-hub": {
|
||||
"baseline_sha": "bd591168c7200ce40a3535f2052b8327056e82e0",
|
||||
"required_paths": [
|
||||
"templates.yaml"
|
||||
],
|
||||
"forbidden_prefixes": [
|
||||
".circleci/",
|
||||
".github/workflows/"
|
||||
],
|
||||
"forbidden_paths": [
|
||||
".qqq-ci.yml",
|
||||
"Jenkinsfile",
|
||||
".gitlab-ci.yml"
|
||||
],
|
||||
"rationale": "Template catalog, no standalone CI in approved snapshot."
|
||||
},
|
||||
"QRun-IO/qqq-meta-manager": {
|
||||
"baseline_sha": "da17eb306bf1587cbf98a1555499e9b27f4caa50",
|
||||
"required_paths": [
|
||||
"README.md"
|
||||
],
|
||||
"forbidden_prefixes": [
|
||||
".circleci/",
|
||||
".github/workflows/"
|
||||
],
|
||||
"forbidden_paths": [
|
||||
".qqq-ci.yml",
|
||||
"Jenkinsfile",
|
||||
".gitlab-ci.yml"
|
||||
],
|
||||
"rationale": "Metadata and automation knowledge repository; no registered CI entrypoint."
|
||||
},
|
||||
"QRun-IO/qqq-maven-registry": {
|
||||
"baseline_sha": "134576e4e701984635105f97c8f52aa1e27205b2",
|
||||
"required_paths": [
|
||||
@@ -79,22 +31,6 @@
|
||||
],
|
||||
"rationale": "Component placeholder documentation with no executable CI."
|
||||
},
|
||||
"QRun-IO/homebrew-qctl": {
|
||||
"baseline_sha": "8dc185d2172c9cbf14dd5b7f83caf350430a632b",
|
||||
"required_paths": [
|
||||
"README.md"
|
||||
],
|
||||
"forbidden_prefixes": [
|
||||
".circleci/",
|
||||
".github/workflows/"
|
||||
],
|
||||
"forbidden_paths": [
|
||||
".qqq-ci.yml",
|
||||
"Jenkinsfile",
|
||||
".gitlab-ci.yml"
|
||||
],
|
||||
"rationale": "Distribution tap; qctl publication owns formula updates, no local CI."
|
||||
},
|
||||
"QRun-IO/.github-private": {
|
||||
"baseline_sha": "3eb51cfc419398b2d4f1f6e5ebdeb17f3469ef8a",
|
||||
"required_paths": [
|
||||
|
||||
@@ -12,6 +12,7 @@ import tempfile
|
||||
|
||||
import enroll_consumers
|
||||
import native_gitops_gates as gitops
|
||||
import native_specialist_gates as specialists
|
||||
import yaml
|
||||
|
||||
PATHS = ('.circleci/config.yml', '.qqq-ci.yml')
|
||||
@@ -109,6 +110,10 @@ def inspect(target, version):
|
||||
if info['archived']:
|
||||
raise ValueError('Archived repository')
|
||||
head = api(f'repos/{repo}/branches/{branch}')['commit']['sha']
|
||||
if repo in specialists.DEFINITIONS:
|
||||
profile, pins = specialists.validate(repo, head, branch, api)
|
||||
return {**target, 'head': head, 'profile': profile, 'version': version,
|
||||
'changed': False, 'worker_pins': pins}
|
||||
if repo in gitops.REPOSITORIES:
|
||||
pin = gitops.validate(repo, head, branch, api, yaml.safe_load)
|
||||
return {**target, 'head': head, 'profile': 'native-gitops', 'version': version,
|
||||
|
||||
Reference in new issue
Block a user