Compare commits

..
45 Commits
Author SHA1 Message Date
james.maesandClaude Fable 5.1 53e9dfd7fc feat: publish qqq-core, the shared dist-tag and CLI platform lanes (#166)
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / gradle-0 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-1 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-2 (push) Skipped
QRun-IO/ci-policy: ci / node-3 (push) Skipped
QRun-IO/ci-policy: ci / node-4 (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: Shared source and config CI / verify (push) Successful in 15s
QRun-IO/ci-policy: Shared source and config CI / secrets (push) Successful in 15s
QRun-IO/ci-policy: Shared source and config CI / gate (push) Successful in 11s
QRun-IO/ci-policy: ci / source-config-5 (push) Successful in 23m13s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 6s
Promotes develop to main. The cli profile publishes @qrun-io/qqq-core, shares one npm dist-tag across the four qqq-cli packages (latest only when every version is final), accepts the opt-in platforms manifest key for macOS arm64 and Windows x64 lanes, runs npm run lint in verify, and moves the Node image to cimg/node:22.23; plus the 83 other develop commits since v0.8.32. The tree equals develop's; main's divergent squash history is reconciled by the merge in the release branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 04:25:58 -06:00
james.maesandCodex a7c3b2a662 fix: publish shared Voyage live GitOps integration (#158)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 13:36:27 -05:00
james.maesandCodex cabf224967 fix: publish Voyage digest and release validation (#156)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 13:06:03 -05:00
james.maesandCodex 5d86b7cca6 fix: publish Voyage configuration parsing correction (#154)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 12:48:57 -05:00
james.maesandCodex 58b1fd0f01 fix: publish Voyage CD and release target fixes (#152)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 12:33:52 -05:00
james.maesandCodex 6ab85cc65b fix: publish verified source-head and boolean fixes (#150)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 05:12:10 -05:00
james.maesandCodex 2056053ac0 perf: publish verified Maven analysis reuse (#147)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 04:36:45 -05:00
james.maesandCodex 8b138ce372 perf: publish lean Core dependency assembly (#145)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 03:31:02 -05:00
james.maesandCodex 4c52053ee0 fix: publish repository-wide cancellation eligibility (#143)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 02:05:04 -05:00
james.maesandCodex 9b150f769b fix: publish reliable coordinator tool installation (#141)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 01:42:12 -05:00
james.maesandCodex 48d648751b feat: publish central CircleCI cost settings (#139)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 01:30:50 -05:00
james.maesandCodex 266ee6db53 feat: publish shared native consumer recognition (#137)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 00:38:38 -05:00
james.maesandCodex 434be19c65 feat: publish shared template renderer working-directory fix (#135)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 00:15:49 -05:00
james.maesandCodex bf962c79d7 feat: publish shared application-template verification (#133)
Co-authored-by: Codex <noreply@openai.com>
2026-10-22 00:00:01 -05:00
james.maesandCodex c77891e63d feat: publish shared Homebrew validation (#131)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 23:35:27 -05:00
james.maesandCodex 98eb544670 feat: publish shared shell automation validation (#129)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 23:13:22 -05:00
james.maesandCodex f001c73cb0 feat: publish native GitOps enrollment support (#126)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 22:56:15 -05:00
james.maesandCodex 736ab0e985 feat: publish complete centralized marketing validation (#124)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 22:26:07 -05:00
james.maesandCodex ee3cc63cdd feat: publish the shared Voyage verification gate (#122)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 22:09:03 -05:00
james.maesandCodex d61e7ac070 fix: verify marketing branches and concrete Node images (#120)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 21:54:11 -05:00
james.maesandCodex c8221161d4 fix: remove fabricated marketing coverage jobs (#118)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 21:38:54 -05:00
james.maesandCodex 4677cf8d17 feat: publish shared Node artifacts and native gate recognition (#116)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 21:32:55 -05:00
james.maesandCodex bbca434b39 feat: enforce five additional shared pipeline profiles (#113)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 21:12:28 -05:00
james.maesandCodex 66b93dccce feat: support combined QBit hotfix and integration filter (#111)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 21:03:57 -05:00
james.maesandCodex a53af9ca33 fix: use compatible CLI for fleet reconciliation (#109)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 20:41:17 -05:00
james.maesandCodex 978d6939d7 feat: run central fleet reconciliation (#107)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 20:30:33 -05:00
james.maesandCodex 0131a1f415 feat: centralize consumer enrollment and enforcement (#103)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 20:02:39 -05:00
james.maesandCodex 5bdda2f8c9 fix: propagate Maven analysis failures (#96)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 19:10:29 -05:00
james.maesandCodex 7b1756818f fix: avoid package publication for frontend CI maintenance (#93)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 17:33:45 -05:00
james.maesandCodex 68f17d3b09 fix: promote core snapshot publication gate (#91)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 17:18:35 -05:00
james.maesandCodex 130bc35ab0 fix: promote maintenance branch verification (#88)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 16:49:21 -05:00
james.maesandCodex 9b7161c3c8 fix: promote frontend build reuse (#86)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 16:25:10 -05:00
james.maesandCodex 482d72ce21 fix: promote scoped browser bootstrap (#83)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 15:47:32 -05:00
james.maesandCodex 45a439796f feat: promote managed patch tracks [minor] (#81)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 15:12:16 -05:00
james.maesandCodex 02f0b93e41 fix: promote Ubuntu-only Java bootstrap (#79)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 14:31:55 -05:00
james.maesandCodex 5e433ec629 fix: refresh only the newly added Temurin repository (#77)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 13:59:00 -05:00
james.maesandCodex cec7a76f12 feat: promote central QBit publication and workflow contracts (#74)
* ci: promote shared QBit publication and maintenance

Co-Authored-By: Codex <noreply@openai.com>

* fix: include verified Maven publication coordinates

Co-Authored-By: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
2026-10-21 13:19:23 -05:00
james.maesandCodex 8717d3536e release: promote central CI maintenance verification (#69)
* release: promote central CI maintenance verification

Co-Authored-By: Codex <noreply@openai.com>

* release: include central RC caller maintenance

Co-Authored-By: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
2026-10-21 12:01:39 -05:00
james.maesandCodex 8229a66bc5 release: promote policy profiles and CI resilience (#67)
Promote the exact tested develop tree bd5ee3bec5.

Co-authored-by: Codex <noreply@openai.com>
2026-10-21 11:32:55 -05:00
james.maesandCodex 9687feb36c release: promote shared branch policies and source scanning (#64)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 10:00:33 -05:00
james.maesandCodex 0fefe6a064 release: promote stable verification gates and RC completion (#60)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 03:21:14 -05:00
james.maesandCodex 2956e3ffce release: promote Android continuation fix and GitOps validation (#52)
Promote the exact checked develop tree on linear main history.

Co-authored-by: Codex <noreply@openai.com>
2026-10-20 22:03:14 -05:00
james.maesandCodex 0afe2a231f release: promote tested Android package authentication (#49)
* release: promote tested Android publisher and All regression coverage

Promote the exact tested develop tree while preserving the existing linear main history after earlier squash promotions.

Co-Authored-By: Codex <noreply@openai.com>

* ci: trigger scans for newly protected release target

The original promotion PR was created before main protection, so default CodeQL did not run. Reopening did not register a scan. Trigger the documented push event without changing the tested source tree.

Co-Authored-By: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
2026-10-20 21:48:10 -05:00
james.maesandCodex 65265e48a4 release: promote public All smoke evidence (#45)
* fix: build marketing site before browser checks (#40)

Run lint and one production build in every shared marketing workflow before Playwright and Lighthouse. Preserve the delegated delivery contracts.

Co-authored-by: Codex <noreply@openai.com>

* fix: use shared Maven credentials for Android publication (#42)

Use the existing organization context and Gradle environment properties. Fail before publishing if either credential is absent and avoid writing secrets to gradle.properties.

Co-authored-by: Codex <noreply@openai.com>

* fix: verify public All smoke evidence without secret export (#44)

Allow unauthenticated Circle API reads for public projects, preserve optional authentication and all fail-closed provenance checks.

Co-authored-by: Codex <noreply@openai.com>

* fix: default All releases to shared Circle smoke evidence (#35)

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
2026-10-20 21:15:15 -05:00
james.maesandCodex 49399deb3d release: promote shared Android publisher (#43)
* fix: build marketing site before browser checks (#40)

Run lint and one production build in every shared marketing workflow before Playwright and Lighthouse. Preserve the delegated delivery contracts.

Co-authored-by: Codex <noreply@openai.com>

* fix: use shared Maven credentials for Android publication (#42)

Use the existing organization context and Gradle environment properties. Fail before publishing if either credential is absent and avoid writing secrets to gradle.properties.

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
2026-10-20 21:09:48 -05:00
126 changed files with 9007 additions and 740 deletions

No files matched your search

+34 -1
View File
@@ -4,6 +4,9 @@ parameters:
run_rc_finalize_sweep:
type: boolean
default: false
run_enrollment_reconcile:
type: boolean
default: false
orbs:
orb-tools: circleci/orb-tools@12.3
shellcheck: circleci/shellcheck@3.2
@@ -13,6 +16,23 @@ filters: &filters
only: /.*/
jobs:
enrollment-reconcile:
docker:
- image: cimg/python:3.12
resource_class: small
steps:
- checkout
- run:
name: Install reconciliation tools
command: |
bash tools/install_reconcile_gh.sh
python3 -m pip install --disable-pip-version-check PyYAML==6.0.3
- run:
name: Reconcile current QQQ branches
no_output_timeout: 21m
command: python3 tools/run_enrollment.py
- store_artifacts:
path: artifacts/enrollment
rc-finalize-sweep:
docker:
- image: cimg/python:3.12
@@ -28,7 +48,10 @@ jobs:
workflows:
lint-pack:
when:
not: << pipeline.parameters.run_rc_finalize_sweep >>
not:
or:
- << pipeline.parameters.run_rc_finalize_sweep >>
- << pipeline.parameters.run_enrollment_reconcile >>
jobs:
- orb-tools/lint:
filters: *filters
@@ -56,3 +79,13 @@ workflows:
only: main
tags:
ignore: /.*/
reconcile-enrollment:
when: << pipeline.parameters.run_enrollment_reconcile >>
jobs:
- enrollment-reconcile:
context: [qqq-maven-registry-credentials, orb-publishing]
filters:
branches:
only: main
tags:
ignore: /.*/
+27
View File
@@ -31,6 +31,9 @@ jobs:
- run:
name: Verify resolved multi-module publication POMs
command: python3 tests/test_maven_publication_poms.py
- run:
name: Verify calculated versions match installed Maven coordinates
command: python3 tests/test_effective_publication_version.py
pipeline-contract-test:
resource_class: small
docker:
@@ -44,15 +47,35 @@ jobs:
name: Verify pipeline selection and Maven compatibility contracts
command: |
python3 tests/test_generate_pipeline.py
python3 tests/test_marketing_link_check.py
python3 scripts/pack_pipeline.py --check
bash tests/test_cli_ci_behavior.sh
python3 tests/test_cli_ci_contract.py
python3 tests/test_maven_ci_contract.py
python3 tests/test_standardize_qbit.py
python3 tests/test_qbit_hotfix_profile.py
python3 tests/test_qbit_feature_profile.py
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_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
python3 tests/test_finish_enrollment.py
python3 tests/test_run_enrollment.py
python3 tests/test_install_reconcile_gh.py
python3 tests/test_circle_project_settings.py
python3 tests/test_static_analysis_exit.py
python3 tests/test_validate_standard.py
python3 tests/test_voyage_profile.py
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
python3 tests/test_business_e2e.py
@@ -60,6 +83,8 @@ jobs:
python3 -m unittest discover -s tests -p test_generate_qctl_workflow.py
python3 tests/test_rc_finalize_sweep.py
python3 tests/test_rc_guard.py
python3 -m unittest discover -s tests -p test_rc_timeout_recovery.py
python3 -m unittest discover -s tests -p test_rc_ref_lookup.py
python3 -m unittest discover -s tests -p test_generate_rc_workflow.py
python3 -m unittest discover -s tests -p test_audit_estate.py
python3 tests/test_all_profiles.py
@@ -74,6 +99,8 @@ jobs:
bash tests/test_maven_ci_cache.sh
bash tests/test_maven_test_results.sh
bash tests/test_maven_ci_install.sh
bash tests/test_browser_install.sh
bash tests/test_frontend_build_reuse.sh
bash tests/test_snapshot_refresh.sh
bash tests/test_maven_settings_output.sh
# Create jobs to test the commands of your orbs.
+1
View File
@@ -3,3 +3,4 @@
*.py text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.json text eol=lf
+38
View File
@@ -0,0 +1,38 @@
name: GitOps validation
'on':
workflow_call:
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Install verified Kustomize
shell: bash
run: |
set -euo pipefail
tool_dir="$RUNNER_TEMP/qqq-kustomize"
mkdir -p "$tool_dir"
curl --fail --silent --show-error --location --retry 2 --max-time 60 \
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.7.1/kustomize_v5.7.1_linux_amd64.tar.gz \
--output "$tool_dir/kustomize.tar.gz"
echo "ea375e7372f9aa029129d4b2d16c66b7750b7f1213c4f66f910d981c895818d8 $tool_dir/kustomize.tar.gz" | sha256sum --check --status
tar -xzf "$tool_dir/kustomize.tar.gz" -C "$tool_dir" kustomize
echo "$tool_dir" >> "$GITHUB_PATH"
- name: Render every Kustomization
shell: bash
run: |
set -euo pipefail
mapfile -d '' manifests < <(find . -path './.git' -prune -o -type f \( -name kustomization.yaml -o -name kustomization.yml -o -name Kustomization \) -print0)
if (( ${#manifests[@]} == 0 )); then
echo 'No Kustomization found' >&2
exit 1
fi
for manifest in "${manifests[@]}"; do
directory=$(dirname "$manifest")
# Rendered Secrets must never enter logs or uploaded artifacts.
kustomize build "$directory" >/dev/null
printf 'Validated %s\n' "$directory"
done
+58
View File
@@ -0,0 +1,58 @@
name: QBit CodeQL
'on':
workflow_call:
permissions:
contents: read
actions: read
security-events: write
packages: read
jobs:
analyze:
name: Analyze branch source
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Select languages present in this checkout
id: languages
run: |
python3 <<'PY'
import os
from pathlib import PurePosixPath
import subprocess
import sys
files = subprocess.check_output(['git', 'ls-files', '-z']).decode('utf-8').split('\0')
extensions = {PurePosixPath(name).suffix.lower() for name in files if name}
languages = []
if extensions & {'.java', '.kt', '.kts'}:
languages.append('java-kotlin')
if extensions & {'.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'}:
languages.append('javascript-typescript')
if '.py' in extensions:
languages.append('python')
if any((name.startswith('.github/workflows/') and PurePosixPath(name).suffix in {'.yml', '.yaml'})
or PurePosixPath(name).name in {'action.yml', 'action.yaml'} for name in files if name):
languages.append('actions')
if not languages:
sys.exit('No supported source in this branch; classify placeholders before enabling QBit scanning')
build_mode = 'autobuild' if extensions & {'.kt', '.kts'} else 'none'
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
output.write('languages=' + ','.join(languages) + '\n')
output.write('build-mode=' + build_mode + '\n')
PY
- uses: actions/setup-java@v4
if: steps.languages.outputs.build-mode == 'autobuild'
with:
distribution: temurin
java-version: '21'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ steps.languages.outputs.languages }}
build-mode: ${{ steps.languages.outputs.build-mode }}
- name: Build Kotlin sources
if: steps.languages.outputs.build-mode == 'autobuild'
uses: github/codeql-action/autobuild@v4
- name: Analyze source
uses: github/codeql-action/analyze@v4
+232 -12
View File
@@ -19,6 +19,14 @@ on:
description: Finalize an existing cut from repository_dispatch or an explicit retry
type: boolean
default: false
recover:
description: Verify an already-published upload after a Circle deployment timeout
type: boolean
default: false
circle_build:
description: Original Circle publisher build number (recovery only)
type: string
default: ''
merge_sha:
type: string
default: ''
@@ -32,6 +40,10 @@ on:
type: string
default: ''
secrets:
CENTRAL_USERNAME:
required: false
CENTRAL_PASSWORD:
required: false
QRUN_TAG_SIGNING_KEY:
description: SSH private key that signs release tags
required: false
@@ -48,7 +60,7 @@ concurrency:
jobs:
cut-rc:
if: ${{ !inputs.finalize }}
if: ${{ !inputs.finalize && !inputs.recover }}
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
@@ -123,7 +135,7 @@ jobs:
echo "merge_sha=$merge_sha"
echo "merged_at=$merged_at"
} >> "$GITHUB_OUTPUT"
echo "Pushed $branch; CircleCI publish_release_candidate cuts the RC." >> "$GITHUB_STEP_SUMMARY"
echo "Pushed $branch; the CircleCI publisher cuts the RC." >> "$GITHUB_STEP_SUMMARY"
echo "Release line: $branch. Waiting without a runner for qbit-rc-published." >> "$GITHUB_STEP_SUMMARY"
- name: Persist trusted release intent
if: steps.merge.outputs.merge_sha != ''
@@ -135,7 +147,7 @@ jobs:
retention-days: 90
tag-and-release:
if: inputs.finalize
if: inputs.finalize || inputs.recover
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
@@ -147,6 +159,12 @@ jobs:
MERGE_SHA: ${{ inputs.merge_sha }}
BUMP_SHA: ${{ inputs.bump_sha }}
VERSION: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}
RECOVER: ${{ inputs.recover }}
CIRCLE_BUILD: ${{ inputs.circle_build }}
RECOVERY_EVENT: ${{ github.event_name }}
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
SIGNING_KEY: ${{ secrets.QRUN_TAG_SIGNING_KEY }}
run: |
set -euo pipefail
@@ -156,6 +174,22 @@ jobs:
fi
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
# BEGIN RC REF LOOKUP
read_ref() {
local body sha
if body=$(gh api "repos/$REPO/git/ref/$1" 2>"$workdir/ref-error"); then
sha=$(jq -er '.object.sha' <<< "$body") || return 1
[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || return 1
printf '%s\n' "$sha"
elif jq -se 'length == 1 and .[0].status == "404"' >/dev/null 2>&1 <<< "$body"; then
# gh prints HTTP error JSON on stdout even when --jq was requested.
return 0
else
cat "$workdir/ref-error" >&2
return 1
fi
}
# END RC REF LOOKUP
# The evaluator is inline so a pinned reusable workflow cannot fetch mutable code.
cat > "$workdir/rc_guard.py" <<'PY'
# BEGIN RC GUARD
@@ -164,12 +198,12 @@ jobs:
class ReleaseFailure(ValueError):
pass
def evaluate(merge_sha, status, commit):
def evaluate(merge_sha, status, commit, recovered_version=""):
if status.get("sha") != merge_sha:
raise ReleaseFailure("Status response does not identify the exact release merge")
# Circle's workflow Check Run is stable even when job statuses receive -1/-2 suffixes.
publishers = [x for x in status.get("check_runs", [])
if x.get("name") == "publish_release_candidate" and x.get("app", {}).get("id") == 18001]
if x.get("name") in ("publish_release_candidate", "verify") and x.get("app", {}).get("id") == 18001]
if not publishers:
return ""
publisher = max(publishers, key=lambda x: x["id"])
@@ -177,7 +211,7 @@ jobs:
raise ReleaseFailure("Publisher Check Run identifies a different source")
if publisher.get("status") != "completed":
return ""
if publisher.get("conclusion") != "success":
if publisher.get("conclusion") != "success" and not recovered_version:
raise ReleaseFailure("CircleCI failed for release merge: " + str(publisher.get("conclusion")))
message = commit.get("commit", {}).get("message", "").split("\n")[0]
match = re.fullmatch(r"Bump version to (\d+\.\d+\.\d+-RC\.\d+) \[skip ci\]", message)
@@ -185,6 +219,8 @@ jobs:
return ""
if [x.get("sha") for x in commit.get("parents", [])] != [merge_sha]:
raise ReleaseFailure("RC bump is not the direct child of the published merge")
if recovered_version and recovered_version != match.group(1):
raise ReleaseFailure("Recovery receipt and bump version differ")
return match.group(1)
def validate_intent(run, intent, repo, merge, branch, run_id):
@@ -223,24 +259,168 @@ jobs:
raise ReleaseFailure("Central POM does not match the expected artifact/version")
if parsedate_to_datetime(modified).timestamp() <= datetime.fromisoformat(merged.replace("Z", "+00:00")).timestamp():
raise ReleaseFailure("Central artifact predates the exact release merge")
def validate_timeout(job, publisher, repo, merge, branch, build, merged_at):
from datetime import datetime
if (job.get('username') + '/' + job.get('reponame'), job.get('vcs_revision'),
job.get('branch'), str(job.get('build_num'))) != (repo, merge, branch, build):
raise ReleaseFailure('Timeout job does not identify the exact cut')
workflow = job.get('workflows', {})
if workflow.get('workflow_name') not in ('publish_release_candidate', 'verify') or workflow.get('job_name') != 'qqq-orb/mvn_publish':
raise ReleaseFailure('Unexpected Circle publication workflow/job')
if (publisher.get('head_sha') != merge or publisher.get('app', {}).get('id') != 18001
or publisher.get('name') != workflow.get('workflow_name')
or publisher.get('status') != 'completed' or publisher.get('conclusion') != 'failure'):
raise ReleaseFailure('Recovery requires the failed exact Circle publisher')
from urllib.parse import urlsplit
link = urlsplit(publisher.get('details_url', ''))
if link.scheme != 'https' or link.netloc != 'app.circleci.com' or link.path != '/workflow/' + workflow.get('workflow_id', ''):
raise ReleaseFailure('Circle check does not identify the timeout workflow')
if job.get('status') != 'failed' or job.get('outcome') != 'failed':
raise ReleaseFailure('Recovery requires a terminal failed job')
actions = [action for step in job.get('steps', []) for action in step.get('actions', [])]
if not actions or actions[-1].get('name') != 'Publish to Sonatype Central (releases and SNAPSHOTs)':
raise ReleaseFailure('Deployment must be the last executed action')
deploy = actions[-1]
if deploy.get('status') != 'timedout' or deploy.get('timedout') is not True:
raise ReleaseFailure('Only a deployment timeout can be recovered')
if any(action.get('status') != 'success' for action in actions[:-1]):
raise ReleaseFailure('Every pre-publication action must have passed')
if not any(action.get('name') == 'Run Maven Verify' for action in actions[:-1]):
raise ReleaseFailure('Successful Maven verification is missing')
if datetime.fromisoformat(job['start_time'].replace('Z', '+00:00')) < datetime.fromisoformat(merged_at.replace('Z', '+00:00')):
raise ReleaseFailure('Publisher predates the trusted cut')
if any(type(deploy.get(key)) is not int or deploy[key] < 0 for key in ('step', 'index')):
raise ReleaseFailure('Invalid deployment log coordinates')
return deploy['step'], deploy['index']
def upload_receipt(log, artifact, version):
# Only the successful-upload receipt and actual Central staging paths count.
deployments = re.findall(r'Uploaded bundle successfully,[^\n]*deploymentId: ([0-9a-f-]{36})\.', log)
if len(deployments) != 1 or not re.fullmatch(r'[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}', deployments[0]):
raise ReleaseFailure('Expected exactly one successful Central upload receipt')
paths = re.findall(r'/target/central-staging/(com/kingsrook/qbits)/(qbit-[a-z0-9-]+)/(\d+\.\d+\.\d+-RC\.\d+)/', log)
coordinates = {(group.replace('/', '.'), name, revision) for group, name, revision in paths}
if not coordinates or ('com.kingsrook.qbits', artifact, version) not in coordinates:
raise ReleaseFailure('Receipt does not include the expected root artifact')
if any(revision != version for _, _, revision in coordinates):
raise ReleaseFailure('Mixed candidate versions in the uploaded bundle')
return deployments[0], sorted('pkg:maven/' + group + '/' + name + '@' + revision for group, name, revision in coordinates)
def validate_deployment(deployment, deployment_id, purls):
if deployment.get('deploymentId') != deployment_id or deployment.get('deploymentState') != 'PUBLISHED':
raise ReleaseFailure('The original Central deployment is not PUBLISHED')
if sorted(deployment.get('purls', [])) != purls:
raise ReleaseFailure('Central deployment coordinates differ from the original upload')
def validate_recovery_bump(commit, source, actual, version, merge):
if [p.get('sha') for p in commit.get('parents', [])] != [merge]:
raise ReleaseFailure('Recovery bump must be a direct child of the cut')
files = commit.get('files', [])
if len(files) != 1 or files[0].get('filename') != 'pom.xml' or files[0].get('status') != 'modified':
raise ReleaseFailure('Recovery bump may change only the root POM')
revisions = re.findall(r'<revision>([^<]+)</revision>', source)
if len(revisions) != 1 or not re.fullmatch(re.escape(version.split('-RC.')[0]) + r'-(SNAPSHOT|RC\.\d+)', revisions[0]):
raise ReleaseFailure('Unexpected source POM revision')
expected = source.replace('<revision>' + revisions[0] + '</revision>', '<revision>' + version + '</revision>')
if actual != expected:
raise ReleaseFailure('Recovery bump changed content beyond the verified version')
def verify_recovery(directory, repo, merge, branch, build, version):
import base64, json, os, pathlib, urllib.request, xml.etree.ElementTree as ET
if not re.fullmatch(r'QRun-IO/qbit-[a-z0-9-]+', repo) or not re.fullmatch(r'[1-9][0-9]*', build):
raise ReleaseFailure('Invalid recovery repository or Circle build')
directory = pathlib.Path(directory)
status = json.loads((directory / 'status.json').read_text())
intent = json.loads((directory / 'intent.json').read_text())
publishers = [p for p in status['check_runs'] if p.get('name') in ('publish_release_candidate', 'verify') and p.get('app', {}).get('id') == 18001]
if status.get('sha') != merge or not publishers:
raise ReleaseFailure('Exact publisher evidence missing')
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, *args, **kwargs):
raise ReleaseFailure('Unexpected evidence redirect')
opener = urllib.request.build_opener(NoRedirect())
def request(url, token=None, post=False):
headers = {'Accept': 'application/json'}
if token:
headers['Authorization'] = 'Bearer ' + token
req = urllib.request.Request(url, headers=headers, data=b'' if post else None)
with opener.open(req, timeout=30) as response:
data = response.read(8_000_001)
if len(data) > 8_000_000:
raise ReleaseFailure('Oversized recovery evidence')
return data, response.headers
circle = 'https://circleci.com/api/v1.1/project/github/' + repo + '/' + build
job = json.loads(request(circle)[0])
step, index = validate_timeout(job, max(publishers, key=lambda p: p['id']), repo, merge, branch, build, intent['merged_at'])
log = request(circle + '/output/' + str(step) + '/' + str(index) + '?file=true')[0].decode()
# file=true can return either a raw log or JSON-encoded output.
try:
value = json.loads(log)
except json.JSONDecodeError:
value = log
log = value if isinstance(value, str) else ''.join(part['message'] for part in value)
token = os.environ.get('GH_TOKEN', '')
source = json.loads(request('https://api.github.com/repos/' + repo + '/contents/pom.xml?ref=' + merge, token)[0])
source_pom = base64.b64decode(source['content']).decode()
pom = ET.fromstring(source_pom)
ns = {'m': 'http://maven.apache.org/POM/4.0.0'}
artifact = pom.findtext('m:artifactId', namespaces=ns)
deployment_id, purls = upload_receipt(log, artifact, version)
username, password = os.environ.get('CENTRAL_USERNAME'), os.environ.get('CENTRAL_PASSWORD')
if not username or not password:
raise ReleaseFailure('Existing Central publisher credentials are required for receipt verification')
authorization = base64.b64encode((username + ':' + password).encode()).decode()
deployment = json.loads(request('https://central.sonatype.com/api/v1/publisher/status?id=' + deployment_id, authorization, post=True)[0])
validate_deployment(deployment, deployment_id, purls)
for purl in purls:
coordinate, revision = purl.removeprefix('pkg:maven/').split('@')
group, name = coordinate.split('/')
url = 'https://repo1.maven.org/maven2/' + group.replace('.', '/') + '/' + name + '/' + revision + '/' + name + '-' + revision + '.pom'
xml, headers = request(url)
validate_central(revision, name, xml, headers.get('Last-Modified', ''), intent['merged_at'])
(directory / 'source-pom.xml').write_text(source_pom)
# This receipt is written only after all remote evidence has been verified.
(directory / 'recovery.json').write_text(json.dumps({'merge_sha': merge, 'version': version,
'circle_build': build, 'deployment_id': deployment_id, 'purls': purls}))
# END RC GUARD
if __name__ == "__main__":
import json, sys
try:
if sys.argv[1] == "lock":
if sys.argv[1] == "recover":
verify_recovery(*sys.argv[2:])
elif sys.argv[1] == "lock":
validate_lock(sys.argv[2], sys.argv[3])
elif sys.argv[1] == "tag":
print(tag_action(sys.argv[2], sys.argv[3], sys.argv[4] == "true", sys.argv[5]))
elif sys.argv[1] == "central":
validate_central(*sys.argv[2:4], open(sys.argv[4]).read(), *sys.argv[5:7])
else:
print(evaluate(sys.argv[1], json.load(open(sys.argv[2])), json.load(open(sys.argv[3]))))
recovered = ""
if len(sys.argv) == 5:
receipt = json.load(open(sys.argv[4]))
if receipt["merge_sha"] != sys.argv[1]:
raise ReleaseFailure("Recovery receipt source mismatch")
recovered = receipt["version"]
import pathlib
directory = pathlib.Path(sys.argv[4]).parent
validate_recovery_bump(json.load(open(sys.argv[3])), (directory / 'source-pom.xml').read_text(),
(directory / 'bump-pom.xml').read_text(), recovered, sys.argv[1])
print(evaluate(sys.argv[1], json.load(open(sys.argv[2])), json.load(open(sys.argv[3])), recovered))
except (ValueError, KeyError) as error:
sys.exit(str(error))
PY
# Dispatch payload is only a hint. Bind it to immutable successful cut-run evidence.
[[ "$MERGE_SHA" =~ ^[0-9a-f]{40}$ && "$BUMP_SHA" =~ ^[0-9a-f]{40}$ ]]
[[ "$MERGE_SHA" =~ ^[0-9a-f]{40}$ ]]
if [[ "$RECOVER" == true ]]; then
[[ "$RECOVERY_EVENT" == workflow_dispatch && "$CIRCLE_BUILD" =~ ^[1-9][0-9]*$ ]]
else
[[ "$BUMP_SHA" =~ ^[0-9a-f]{40}$ ]]
fi
[[ "$BRANCH" =~ ^release/[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-RC\.[0-9]+$ ]]
artifact_name="qbit-rc-intent-$MERGE_SHA"
@@ -278,13 +458,53 @@ jobs:
PY
MERGED_AT=$(jq -er .merged_at "$workdir/intent.json")
lock=automation/qbit-rc-pending
current_lock=$(gh api "repos/$REPO/git/ref/heads/$lock" -q .object.sha 2>/dev/null || true)
current_lock=$(read_ref "heads/$lock")
# A duplicate after completed finalization is safe only after tag/source checks below.
[[ -z "$current_lock" || "$current_lock" == "$MERGE_SHA" ]] || { echo "::error::Different release owns pending lock"; exit 1; }
gh api "repos/$REPO/commits/$MERGE_SHA/check-runs?filter=latest&per_page=100" \
| jq --arg sha "$MERGE_SHA" '{sha:$sha,check_runs:.check_runs}' > "$workdir/status.json"
recovered_args=()
if [[ "$RECOVER" == true ]]; then
python3 "$workdir/rc_guard.py" lock "$current_lock" "$MERGE_SHA"
python3 "$workdir/rc_guard.py" recover "$workdir" "$REPO" "$MERGE_SHA" "$BRANCH" "$CIRCLE_BUILD" "$VERSION"
if [[ "$DRY_RUN" == true ]]; then
echo "Recovery evidence verified; dry run leaves branch, tag, release and lock unchanged." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
head=$(gh api "repos/$REPO/branches/$BRANCH" -q .commit.sha)
if [[ "$head" == "$MERGE_SHA" ]]; then
key="$workdir/recovery_key"
install -m 600 /dev/null "$key"
printf '%s\n' "$SIGNING_KEY" > "$key"
git init -q "$workdir/recovery-repo"
git -C "$workdir/recovery-repo" fetch -q --depth=1 "https://x-access-token:$GH_TOKEN@github.com/$REPO.git" "$MERGE_SHA"
git -C "$workdir/recovery-repo" checkout -q -b "$BRANCH" FETCH_HEAD
python3 - "$workdir/recovery-repo/pom.xml" "$VERSION" <<'PY'
import pathlib, re, sys
path, version = pathlib.Path(sys.argv[1]), sys.argv[2]
source = path.read_text()
revisions = re.findall(r'<revision>([^<]+)</revision>', source)
assert len(revisions) == 1 and re.fullmatch(re.escape(version.split('-RC.')[0]) + r'-(SNAPSHOT|RC\.\d+)', revisions[0]), 'Unexpected source revision'
path.write_text(source.replace('<revision>' + revisions[0] + '</revision>', '<revision>' + version + '</revision>'))
PY
git -C "$workdir/recovery-repo" add pom.xml
git -C "$workdir/recovery-repo" -c user.name="James Maes" -c user.email=james@kof22.com -c gpg.format=ssh -c user.signingkey="$key" commit -q -S -m "Bump version to $VERSION [skip ci]"
python3 "$workdir/rc_guard.py" lock "$(gh api "repos/$REPO/git/ref/heads/$lock" -q .object.sha)" "$MERGE_SHA"
# A normal fast-forward push refuses a competing release-branch change.
git -C "$workdir/recovery-repo" push -q "https://x-access-token:$GH_TOKEN@github.com/$REPO.git" "HEAD:$BRANCH"
BUMP_SHA=$(git -C "$workdir/recovery-repo" rev-parse HEAD)
rm -f "$key"
else
BUMP_SHA=$head
fi
recovered_args=("$workdir/recovery.json")
echo "Verified original Central upload after Circle timeout; no artifact was uploaded again." >> "$GITHUB_STEP_SUMMARY"
fi
gh api "repos/$REPO/commits/$BUMP_SHA" > "$workdir/commit.json"
version=$(python3 "$workdir/rc_guard.py" "$MERGE_SHA" "$workdir/status.json" "$workdir/commit.json")
if [[ "$RECOVER" == true ]]; then
gh api "repos/$REPO/contents/pom.xml?ref=$BUMP_SHA" -q .content | base64 -d > "$workdir/bump-pom.xml"
fi
version=$(python3 "$workdir/rc_guard.py" "$MERGE_SHA" "$workdir/status.json" "$workdir/commit.json" "${recovered_args[@]}")
[[ -n "$version" && "$version" == "$VERSION" ]] || { echo "::error::Publisher not successful or callback version mismatch"; exit 1; }
bump_sha=$BUMP_SHA
[[ "$(gh api "repos/$REPO/branches/$BRANCH" -q .commit.sha)" == "$bump_sha" ]] || { echo "::error::Release branch moved away from exact bump"; exit 1; }
@@ -316,7 +536,7 @@ jobs:
python3 "$workdir/rc_guard.py" central "$version" "$artifact" "$workdir/central.pom" "$last_modified" "$MERGED_AT"
# 3. Signed annotated tag on the exact bump; duplicate runs must not accept a different tag.
existing=$(gh api "repos/$REPO/git/ref/tags/v$version" --jq '.object.sha' 2>/dev/null || true)
existing=$(read_ref "tags/v$version")
target=""; release_exists=false
if [[ -n "$existing" ]]; then
target=$(gh api "repos/$REPO/git/tags/$existing" --jq '.object.sha')
+6 -3
View File
@@ -12,7 +12,7 @@ on:
required: true
type: string
smoke_evidence:
description: github (legacy default) or circle (requires consumer adapter and Circle credential)
description: github (legacy default) or circle (public API evidence; optional credential)
type: string
default: github
circle_workflow_id:
@@ -494,9 +494,12 @@ jobs:
def circle(path):
token = os.environ.get('CIRCLECI_TOKEN')
require(token, 'CIRCLECI_TOKEN is required for Circle evidence mode')
# Public projects expose these records without authentication.
headers = {'Accept': 'application/json'}
if token:
headers['Circle-Token'] = token
request = urllib.request.Request('https://circleci.com/api/v2/' + path,
headers={'Circle-Token': token, 'Accept': 'application/json'})
headers=headers)
with urllib.request.build_opener(NoRedirect).open(request, timeout=30) as response:
raw = response.read(2_000_001)
require(len(raw) <= 2_000_000, 'Evidence response exceeds bound')
+6
View File
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `cli` profile: publishes `@qrun-io/qqq-core` between the client and the conformance package on tag publishes, and refuses to publish when core's version differs from the CLI's or from the CLI's exact core dependency
- `cli` profile: one shared npm dist-tag for the four packages, `latest` when every version is final and `rc` when any has a prerelease part
- `cli` profile: optional `platforms: [macos-arm64, windows-x64]` manifest key that adds `cli_platform` lanes (new `cli_macos_arm64` and `cli_windows_x64` executors); a publishing tag's `cli_verify_publish` requires them. Off by default; other profiles reject the key
- `cli_verify.sh` runs `npm run lint` and diffs `packages/core/src/api/operations.ts` in the drift check; Node image `cimg/node:22.23`
### Fixed
- Maven compile, verify and frontend test steps pass `--update-snapshots`, so SNAPSHOT dependencies restored from the pom-checksum-keyed `~/.m2` cache are re-checked against the remote on every build instead of going stale
+12
View File
@@ -58,10 +58,21 @@ test-pipelines: pack
bash tests/test_cli_ci_behavior.sh
python3 tests/test_cli_ci_contract.py
python3 tests/test_standardize_qbit.py
python3 tests/test_qbit_hotfix_profile.py
python3 tests/test_ci_maintenance.py
python3 tests/test_rollout_version.py
python3 tests/test_enforce_orb_checks.py
python3 tests/test_enroll_consumers.py
python3 tests/test_reconcile_enrollment.py
python3 tests/test_discover_enrollment.py
python3 tests/test_finish_enrollment.py
python3 tests/test_static_analysis_exit.py
python3 tests/test_validate_standard.py
python3 tests/test_voyage_profile.py
python3 tests/test_next_native.py
python3 tests/test_auxiliary_workflows.py
python3 tests/test_qbit_codeql.py
python3 tests/test_repository_policy.py
python3 tests/test_intellij_plugin.py
python3 tests/test_workflow_lint.py
python3 tests/test_business_e2e.py
@@ -215,3 +226,4 @@ publish-release: check-clean check-branch lint clean dev test-all
# an isolated temporary repository. Never publishes or uses signing credentials.
test-publication-poms:
python3 tests/test_maven_publication_poms.py
python3 tests/test_effective_publication_version.py
+31
View File
@@ -4,6 +4,8 @@ CircleCI orb for QQQ framework projects.
For centralized pipeline ownership, see [standardized manifest-driven pipelines](docs/GENERATED-PIPELINES.md).
The initial QBit profile uses a small `.qqq-ci.yml` and a setup entry point; existing direct job callers remain supported.
For centrally managed patch adoption and exact-version rollback, see
[managed patch updates](docs/managed-patch-updates.md).
**For:** Teams using CircleCI to build, test, and publish QQQ applications
**Status:** Stable (v0.6.x)
@@ -87,6 +89,11 @@ real publication, not a dry run, verifies the trust relationship.
| `hotfix/1.5.1` | `1.5.1` |
| `feature/*` | `1.5.0-feature-abc1234-SNAPSHOT` |
The Maven version step verifies the effective `project.version`, not only the
`revision` property. For older POMs with a literal project version, it uses
Maven's version plugin to align project and reactor coordinates with the
calculated version. A mismatch after updating fails before publication.
### Java Version
Maven jobs run on Ubuntu machine executors with Temurin JDK. Default is Java 21. To use Java 17:
@@ -114,6 +121,21 @@ Maven jobs use machine executors with Docker pre-installed. Tests using Testcont
## Orb Publishing
### QBit CI maintenance
The QBit profile runs Maven verification without publishing when a single-parent
`ci: ...` or `ci(scope): ...` commit changes only `.qqq-ci.yml`,
`.circleci/config.yml`, `.github/workflows/codeql.yml`, or
`.github/workflows/release-rc.yml`. This applies on
main, develop, release, and hotfix branches. The normal test job still runs,
including on branches normally excluded from feature tests, and reports through
the required `verify` workflow.
Tags, merge commits (including release automation), application changes, other
files, empty diffs, and unavailable history retain normal publishing behavior.
This lets central configuration updates avoid unnecessary application versions
without introducing per-repository maintenance workflows.
The orb auto-publishes via CircleCI:
| Branch | Action |
@@ -124,6 +146,15 @@ The orb auto-publishes via CircleCI:
Version bumps on main default to patch. Include `[minor]` or `[major]` in a commit message to bump accordingly.
## Voyage quality checks
The Voyage profile requires no Sonar service, account or token. Its existing
`mvn clean verify` runs the application's Checkstyle, PMD, SpotBugs and JaCoCo
checks alongside unit and integration tests. The profile retains those failures
as build failures and publishes their XML reports and `target/site` as artifacts.
The separate secret, SAST, dependency and image scans remain unchanged, as do
the dependencies that gate image publication and production GitOps updates.
## Project Status
**Maturity:** Stable, used across all QQQ repositories
+76
View File
@@ -3,6 +3,18 @@
`tools/audit_estate.py` classifies repositories from explicit mappings and observed source.
It never changes consumers, branch rules or publication settings.
Source auditing reads the repository's current default branch unless
`--live --source-branch main` (or an explicit `release/...` or `hotfix/...` branch)
is supplied. Run separate audits for each maintained source branch: a clean
default-branch report does not establish conformity on main or release branches.
The selected branch is resolved to an immutable commit before any files are read.
Reports identify both `source_branch` and the repository's `default_branch`;
the manifest's `default_branch` must still match the repository default.
Unavailable selected branches remain unknown without falling back to default.
Explicit branch selection requires live lookup and cannot relabel an offline SHA.
Required-check policy still controls which branch settings are inspected;
`--source-branch` changes source selection, not that enforcement policy.
- Circle profiles include android, mcp-policy and marketing. Their manifest and canonical
setup caller remain mandatory; a missing configuration is a finding.
- MCP, business-platform and the organization `.github` repository use approved native
@@ -65,3 +77,67 @@ actionlint .github/workflows/workflow-lint.yml
Tests cover exact no-CI allowlists and drift, unknown repositories, missing configured
profiles/native bridges, retained legacy workflows, bootstrap dependency/gate removal,
required-check unknown states, and the lint image/tool/command/caller contract.
## Batch orb-version rollout
For a standard QBit without a manifest, start directly on the managed patch
track using `python tools/standardize_qbit.py /checkout --orb-version 0.8
--default-branch main`. Inspect the preview, then repeat with `--write`.
This preserves the inferred publication and branch-filter policy while writing
the same track to the manifest and setup caller. Use `rollout_version.py` below
for repositories that already have a manifest. Neither command configures
repository protection or automatically enrolls newly created repositories.
Upgrade existing canonical CircleCI consumers with one command:
```sh
python tools/rollout_version.py --orb-version 0.7.11 /checkouts/qbit-one /checkouts/qqq-cli
python tools/rollout_version.py --orb-version 0.7.11 --write /checkouts/qbit-one /checkouts/qqq-cli
```
The first command previews the batch. The second updates only `.qqq-ci.yml` and
`.circleci/config.yml`, after every supplied checkout passes the existing manifest
and canonical-caller validators. It preserves publication opt-outs, release filters,
credential context names and forwarded profile parameters. Already-current files
are unchanged. Duplicate checkouts, custom jobs, invalid options and mismatched
pins reject the batch before writing; resolve these in the central profile first.
Use isolated checkouts of the intended repository heads, inspect the resulting
patches, then commit and push through the normal automated gates. The tool does not
commit, push, publish packages, change GitHub rules or modify native/RC worker pins.
A version update does not prove a publication succeeded: retain exact-head hosted
verification and artifact evidence. The requested version must already be published.
```sh
python3 -m unittest discover -s tests -p test_rollout_version.py
```
## Live organization discovery
Use `--organization QRun-IO --live` instead of `--inventory inventory.json` to
include newly created repositories on each audit. Discovery uses the existing
`gh` authentication and all API pages, retaining archived entries for explicit
skip reporting. Unknown repositories receive no automatic exemption. Duplicate,
empty, malformed or failed discovery aborts instead of reusing a stale inventory.
```sh
python tools/audit_estate.py --organization QRun-IO --live --orb-version 0.8 \
--worker-sha <40SHA> --policy observed-checks.json --output audit.json
```
The organization mode has no fixed repository-count ceiling. Supply
`--expected-active N` for an independent count check when needed; saved-inventory
mode preserves its default of 68. Reports identify the inventory source and
credential visibility limit: inaccessible repositories cannot be certified.
This is discovery and audit, not automatic enrollment or branch-rule mutation.
For a qualified batch of canonical orb branches, use the shared
[branch-check enforcement command](branch-enforcement.md). It adds the observed
CircleCI setup/verify gates while preserving other protections. Source enrollment,
scanner transitions and scheduled reconciliation remain separate requirements.
Scheduling and authenticated onboarding still need to be configured centrally.
## Batch enrollment
Use [the shared enrollment command](consumer-enrollment.md) to convert recognized
legacy QBits and update existing canonical consumers in one validated batch.
+258 -224
View File
@@ -1,224 +1,258 @@
# Standardized QQQ pipelines
The orb owns workflow selection and job configuration. A consumer declares a
small manifest; it does not copy pipeline jobs. The initial supported profile is
`qbit`; `core` owns the framework's complete acceptance/release graph. Frontend
and CLI profiles described below retain their own publication contracts. Additional
profiles belong in reviewed `PROFILE_TEMPLATES` renderers in
`src/scripts/generate_pipeline.py`, with profile-specific schema and tests. There
is no arbitrary script or job-YAML passthrough.
Use the same **published** orb version in all three positions below. `0.7.0` is
an illustrative version, not a claim that this change is published. A development
orb version can be used for a controlled canary.
`.circleci/config.yml`:
```yaml
version: 2.1
setup: true
orbs:
qqq-orb: kingsrook/qqq-orb@0.7.0
workflows:
setup:
jobs:
- qqq-orb/generate_pipeline:
orb_version: "0.7.0"
filters:
branches:
ignore: automation/qbit-rc-pending
tags:
only: /.*/
```
`.qqq-ci.yml`:
```yaml
profile: qbit
orb_version: "0.7.0"
default_branch: develop
java_version: "21"
browsers: false
api_checks: false
docs_only: false
publish:
snapshot: true
release_candidate: true
release: true
asciidoc: false
```
Only `profile`, `orb_version` and `default_branch` are required. `default_branch`
must be `develop` or `main`; Java must be the string `17` or `21`. Browsers default
to **true** for compatibility: opt out only after verifying that the consumer has
no browser tests. API checks and docs-only default to false. Publication defaults
to true for snapshots, RCs and tagged releases; AsciiDoc publication defaults to
false. Unknown/duplicate keys, unexpected types, unsupported profiles and a setup
parameter/manifest version mismatch fail before continuation. The canonical-caller
validator also verifies the setup import, filters and profile-specific parameter
declarations; additional jobs, commands, workflows or orbs fail validation. The
parser is pinned to PyYAML 6.0.3 and uses its safe loader.
| Event | Workflow | Job contract |
| --- | --- | --- |
| develop | publish_snapshot | existing mvn_publish, snapshot |
| release/* | publish_release_candidate | existing mvn_publish, release_candidate |
| vX.Y.Z tag resolving to the checkout | publish_release | existing mvn_publish, release |
| main, feature/*, hotfix/*, other/unknown branch | test_only | existing mvn_test_only |
| Disabled publication or unrecognized/unproven tag | test_only | full verification, no publication |
The pipeline SHA must match the checkout when Circle supplies it. A tagged release
must resolve to that checkout; missing local tags are fetched individually. A main
push does **not** publish a release. Migrating a legacy main-publishing consumer
therefore requires explicit review of its release contract. Existing direct orb
callers remain supported.
The setup filter and generated jobs exclude `automation/qbit-rc-pending`, the
shared RC orchestrator's persistent release lock. Lock updates must not trigger
Maven test or publication work.
The shared jobs keep the `qqq-maven-registry-credentials` context, complete verify,
coverage and configured API checks. Publishing retains version management, signed
artifact deployment, Git operations and release handling. Generated calls disable
the redundant preliminary compile; they do not skip tests or verification. Existing
callers retain the compatibility defaults in the jobs.
## Core profile
QBit alone accepts `release_completion: true` (default false). It enables the
shared Maven RC job's `notify_rc_published` only for RC publication, including
fail-closed verification that the bumped version was pushed before dispatching
the completion event. Enable this on a consumer only after its default branch
contains the shared completion caller. Snapshot and GA jobs never receive this
opt-in; other profiles reject the key.
Use `profile: core` for the QQQ framework. The orb owns the complete baseline
acceptance, broker conformance, cold bootstrap, coverage, diagnostics, static
analysis and publication graph. Core scripts remain in the core source repository.
The independent baseline fixture pins job sets, dependency edges, contexts,
coverage requirements and actual verification commands across all six workflows.
Core additionally supports `publish.feature` and `publish.hotfix` (both true by
default), preserving `publish*` tag and hotfix branch publication. QBit does not
accept these keys. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix
publication still requires the complete source coverage gate. Cold bootstrap and
fresh consumer Maven repositories remain uncached. Shared installer policy replaces
local package preparation; preliminary compilation is disabled before clean
lifecycles and the dependency cache is saved after successful verification.
Lambda XML copies remain in sample coverage evidence. The sample JUnit collector
excludes those two copied reports because their original module directories are
already uploaded, avoiding duplicate test identities without dropping evidence.
External core API triggers require these declarations in the tiny **setup** config:
```yaml
parameters:
mongo_bind_diagnostics:
type: boolean
default: false
next_acceptance_bundle_url:
type: string
default: ""
next_acceptance_bundle_sha256:
type: string
default: ""
next_acceptance_receipt_sha256:
type: string
default: ""
```
Forward each value on `qqq-orb/generate_pipeline`, for example
`mongo_bind_diagnostics: << pipeline.parameters.mongo_bind_diagnostics >>`, and
likewise for the three bundle parameters. Requested values become defaults in the
continued configuration; the continuation POST deliberately omits `parameters` to
avoid CircleCI's setup/continuation/API parameter conflict. Verify both default and
explicit API-triggered parameter values in the hosted canary before migrating
triggering consumers. Other profiles reject non-default core parameters.
## Frontend profiles
`frontend-material` preserves the Maven frontend build/test/package/publication
jobs, Java21/Node20 defaults, registry context, feature-tag, RC, GA and hotfix
contracts. Declare setup pipeline parameter `run_playwright` (boolean, default
false) and forward `run_playwright: << pipeline.parameters.run_playwright >>` on
the generator job. Test/snapshot events select exactly one base or Playwright graph,
so enabling visual tests cannot publish twice. Visual testing retains the pinned
Playwright image, npm ci with legacy peer dependencies and report uploads; only
npm downloads (`~/.npm`) are cached, never node_modules.
`frontend-core` preserves Node24.21, npm trusted publishing and both existing
registry/build-sample contexts. Unlike QBit, its existing main-push **and v-tag**
release contract remains intentional. Both frontend profiles support explicit
numeric-string `node_version` and publication toggles including feature/hotfix.
Material also supports `java_version`. Browser/API/AsciiDoc flags are rejected
rather than silently ignored on these profiles. Existing direct jobs remain usable.
## CLI profile
`cli` owns npm install, generated-client drift, build, unit tests and the real
Prism smoke contract through `cli_verify_publish`. Publication is **disabled by
default**. To enable the existing v-tag publication, declare `publish.release:
true` plus `publish_context: VERIFIED_CONTEXT_NAME`, after verifying that an
existing trusted CircleCI context grants the required GitHub Packages permission.
No context name or credential availability is inferred from the former Actions
GITHUB_TOKEN. A tag must resolve to the current checkout; the job additionally
checks the client version before publishing its three fixed workspaces with the
existing rc dist-tag. Main pushes never publish. CLI docs-only is currently
rejected because generated-client verification remains mandatory.
## Conservative documentation routing
With `docs_only: true`, only feature/hotfix and main changes can take the light
route. Feature/hotfix branches fetch the declared default branch without tags and
compare its merge base with HEAD, covering the whole branch. Main compares its first
parent. Develop, release branches and all tags remain full. Shallow repositories,
missing ancestry, fetch/diff errors, empty diffs and unknown paths remain full.
Only root README.md, CHANGELOG.md, CONTRIBUTING.md and Markdown files below docs/
are eligible. Renames are treated as deletion plus addition, so moving code into
docs cannot hide it. The lightweight job checks whitespace over the proven diff;
manifest validation already ran in setup. It adds no new security scanner and
makes no security-scanning claim. Keep docs-only disabled if those paths are build
inputs or packaged application content.
The light route keeps workflow `test_only` and names its job
`qqq-orb/mvn_test_only`. Verify actual CircleCI/GitHub status contexts on the canary
before changing any protection rule; workflow/job identity alone is not proof of
the hosted context name. Current protections must not be removed speculatively.
## Implementation and verification
The setup job checks out source, installs the pinned parser, runs the embedded
Python resource and invokes CircleCI's native continuation API once. JSON output
is valid CircleCI configuration YAML; it is saved at
`/tmp/qqq-generated-config.json`. No external framework or per-consumer generator
installation is required. Readable templates live in src/scripts/templates. scripts/pack_pipeline.py embeds
them as base64 into packed_generate_pipeline.py before orb packing, preventing
CircleCI from interpolating template expressions during setup. The orb includes
the complete generated resource; no runtime source-tree template access is needed.
make pack regenerates it and CI rejects a stale generated resource.
Continuation credentials and response bodies are never printed.
Run `make test-pipelines` with CircleCI CLI, Python3/PyYAML and Bash available.
Tests use offline temporary Git repositories and a bare origin to cover selection,
whole-branch changes, tags, errors, defaults and source/packed parity. The hosted
pipeline-contract-test runs the source suite and shared Maven behavioral tests;
the full local target additionally extracts and executes the actual packed command.
## Android and MCP policy profiles
`android` and `mcp-policy` accept only profile, orb_version and default_branch.
Android retains the audited Android/GCP orb versions and every active unit,
emulator and Maven-publication step. The emulator now runs on main as well as
feature branches so main publication cannot omit its required instrumentation
gate. Dormant Firebase benchmark and release-build definitions referencing absent
app/macrobenchmark modules are not scheduled or copied into the profile.
MCP policy validation remains a small Python container validating all visible YAML
and required pattern fields. Its existing PyYAML dependency is pinned to 6.0.3.
Neither profile introduces Maven/JUnit stand-ins for its actual tests.
`tests/test_mobile_policy_profiles.py` protects Android steps and dependency edges
and executes the policy validator with valid, incomplete and malformed documents.
The generator suite verifies source/packed parity for both profiles.
# Standardized QQQ pipelines
The orb owns workflow selection and job configuration. A consumer declares a
small manifest; it does not copy pipeline jobs. The initial supported profile is
`qbit`; `core` owns the framework's complete acceptance/release graph. Frontend
and CLI profiles described below retain their own publication contracts. Additional
profiles belong in reviewed `PROFILE_TEMPLATES` renderers in
`src/scripts/generate_pipeline.py`, with profile-specific schema and tests. There
is no arbitrary script or job-YAML passthrough.
Use the same **published** orb version in all three positions below. `0.7.0` is
an illustrative version, not a claim that this change is published. A development
orb version can be used for a controlled canary.
`.circleci/config.yml`:
```yaml
version: 2.1
setup: true
orbs:
qqq-orb: kingsrook/qqq-orb@0.7.0
workflows:
setup:
jobs:
- qqq-orb/generate_pipeline:
orb_version: "0.7.0"
filters:
branches:
ignore: automation/qbit-rc-pending
tags:
only: /.*/
```
`.qqq-ci.yml`:
```yaml
profile: qbit
orb_version: "0.7.0"
default_branch: develop
java_version: "21"
browsers: false
api_checks: false
docs_only: false
publish:
snapshot: true
release_candidate: true
release: true
asciidoc: false
```
Only `profile`, `orb_version` and `default_branch` are required. `default_branch`
must be `develop` or `main`; Java must be the string `17` or `21`. Browsers default
to **true** for compatibility: opt out only after verifying that the consumer has
no browser tests. API checks and docs-only default to false. Publication defaults
to true for snapshots, RCs and tagged releases; AsciiDoc publication defaults to
false. Unknown/duplicate keys, unexpected types, unsupported profiles and a setup
parameter/manifest version mismatch fail before continuation. The canonical-caller
validator also verifies the setup import, filters and profile-specific parameter
declarations; additional jobs, commands, workflows or orbs fail validation. The
parser is pinned to PyYAML 6.0.3 and uses its safe loader.
| Event | Workflow | Job contract |
| --- | --- | --- |
| develop | verify | existing mvn_publish, snapshot |
| release/* | verify | existing mvn_publish, release_candidate |
| vX.Y.Z tag resolving to the checkout | verify | existing mvn_publish, release |
| main, feature/*, hotfix/*, other/unknown branch | verify | existing mvn_test_only |
| Disabled publication or unrecognized/unproven tag | verify | full verification, no publication |
Generated `qbit`, `core`, `frontend-core`, and `frontend-material` pipelines use
the stable workflow name `verify`. All selected jobs, dependencies and filters
remain intact; this adds no executor or duplicate build. Other profiles retain
their existing workflow names and native checks.
When upgrading from legacy workflow names, upgrade the immutable RC worker pin
alongside the orb so finalization recognizes both names. Confirm the CircleCI
app's successful `verify` check on the exact migration commit before replacing
legacy required contexts. Require `setup` and `verify` on managed branches,
preserving other required checks and controls. Human approval is not required;
automated checks authorize the migration.
The pipeline SHA must match the checkout when Circle supplies it. A tagged release
must resolve to that checkout; missing local tags are fetched individually. A main
push does **not** publish a release. Migrating a legacy main-publishing consumer
therefore requires explicit review of its release contract. Existing direct orb
callers remain supported.
The setup filter and generated jobs exclude `automation/qbit-rc-pending`, the
shared RC orchestrator's persistent release lock. Lock updates must not trigger
Maven test or publication work.
The shared jobs keep the `qqq-maven-registry-credentials` context, complete verify,
coverage and configured API checks. Publishing retains version management, signed
artifact deployment, Git operations and release handling. Generated calls disable
the redundant preliminary compile; they do not skip tests or verification. Existing
callers retain the compatibility defaults in the jobs.
## Core profile
QBit alone accepts `release_completion: true` (default false). It enables the
shared Maven RC job's `notify_rc_published` only for RC publication, including
fail-closed verification that the bumped version was pushed before dispatching
the completion event. Enable this on a consumer only after its default branch
contains the shared completion caller. Snapshot and GA jobs never receive this
opt-in; other profiles reject the key.
Use `profile: core` for the QQQ framework. The orb owns the complete baseline
acceptance, broker conformance, cold bootstrap, coverage, diagnostics, static
analysis and publication graph. Core scripts remain in the core source repository.
The independent baseline fixture pins job sets, dependency edges, contexts,
coverage requirements and actual verification commands across all six workflows.
Core additionally supports `publish.feature` and `publish.hotfix` (both true by
default), preserving `publish*` tag and hotfix branch publication. QBit supports
both keys as explicit opt-ins (false by default). QBit feature publishing requires
a `publish*` tag resolving to the checked-out commit; feature branch pushes remain
test-only. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix
publication still requires the complete source coverage gate. Cold bootstrap and
fresh consumer Maven repositories remain uncached. Shared installer policy replaces
local package preparation; preliminary compilation is disabled before clean
lifecycles and the dependency cache is saved after successful verification.
Lambda XML copies remain in sample coverage evidence. The sample JUnit collector
excludes those two copied reports because their original module directories are
already uploaded, avoiding duplicate test identities without dropping evidence.
External core API triggers require these declarations in the tiny **setup** config:
```yaml
parameters:
mongo_bind_diagnostics:
type: boolean
default: false
next_acceptance_bundle_url:
type: string
default: ""
next_acceptance_bundle_sha256:
type: string
default: ""
next_acceptance_receipt_sha256:
type: string
default: ""
```
Forward each value on `qqq-orb/generate_pipeline`, for example
`mongo_bind_diagnostics: << pipeline.parameters.mongo_bind_diagnostics >>`, and
likewise for the three bundle parameters. Requested values become defaults in the
continued configuration; the continuation POST deliberately omits `parameters` to
avoid CircleCI's setup/continuation/API parameter conflict. Verify both default and
explicit API-triggered parameter values in the hosted canary before migrating
triggering consumers. Other profiles reject non-default core parameters.
## Frontend profiles
`frontend-material` preserves the Maven frontend build/test/package/publication
jobs, Java21/Node20 defaults, registry context, feature-tag, RC, GA and hotfix
contracts. Declare setup pipeline parameter `run_playwright` (boolean, default
false) and forward `run_playwright: << pipeline.parameters.run_playwright >>` on
the generator job. Test/snapshot events select exactly one base or Playwright graph,
so enabling visual tests cannot publish twice. Visual testing retains the pinned
Playwright image, npm ci with legacy peer dependencies and report uploads; only
npm downloads (`~/.npm`) are cached, never node_modules.
`frontend-core` preserves Node24.21, npm trusted publishing and both existing
registry/build-sample contexts. Unlike QBit, its existing main-push **and v-tag**
release contract remains intentional. Both frontend profiles support explicit
numeric-string `node_version` and publication toggles including feature/hotfix.
Material also supports `java_version`. Browser/API/AsciiDoc flags are rejected
rather than silently ignored on these profiles. Existing direct jobs remain usable.
## CLI profile
`cli` owns npm install, generated-client and operations drift, build, unit tests,
lint and the real Prism smoke contract through `cli_verify_publish`. Publication is **disabled by
default**. To enable the existing v-tag publication, declare `publish.release:
true` plus `publish_context: VERIFIED_CONTEXT_NAME`, after verifying that an
existing trusted CircleCI context grants the required GitHub Packages permission.
No context name or credential availability is inferred from the former Actions
GITHUB_TOKEN. A tag must resolve to the current checkout; the job additionally
checks the client version, and that core shares the CLI version and matches the
CLI's exact core dependency, before publishing its four fixed workspaces (client,
core, conformance, CLI) under one dist-tag: `rc` if any of the four versions has
a prerelease part, otherwise `latest`. Main pushes never publish.
CLI docs-only is currently rejected because generated-client verification remains
mandatory.
Optional platform lanes are **off by default**. `platforms: [macos-arm64,
windows-x64]` (either or both) adds one `cli_platform` job per entry (`npm ci`,
build, tests and lint on Node 20 via the image's nvm), named `cli-macos-arm64` /
`cli-windows-x64`. On a publishing tag `cli_verify_publish` requires them. The
lanes use the `m4pro.medium` macOS and `windows.medium` resource classes, which
the CircleCI plan must include.
## Conservative documentation routing
With `docs_only: true`, only feature/hotfix and main changes can take the light
route. Feature/hotfix branches fetch the declared default branch without tags and
compare its merge base with HEAD, covering the whole branch. Main compares its first
parent. Develop, release branches and all tags remain full. Shallow repositories,
missing ancestry, fetch/diff errors, empty diffs and unknown paths remain full.
Only root README.md, CHANGELOG.md, CONTRIBUTING.md and Markdown files below docs/
are eligible. Renames are treated as deletion plus addition, so moving code into
docs cannot hide it. The lightweight job checks whitespace over the proven diff;
manifest validation already ran in setup. It adds no new security scanner and
makes no security-scanning claim. Keep docs-only disabled if those paths are build
inputs or packaged application content.
The light route keeps workflow `verify` and names its job
`qqq-orb/mvn_test_only`. Verify actual CircleCI/GitHub status contexts on the canary
before changing any protection rule; workflow/job identity alone is not proof of
the hosted context name. Current protections must not be removed speculatively.
## Implementation and verification
The setup job checks out source, installs the pinned parser, runs the embedded
Python resource and invokes CircleCI's native continuation API once. JSON output
is valid CircleCI configuration YAML; it is saved at
`/tmp/qqq-generated-config.json`. No external framework or per-consumer generator
installation is required. Readable templates live in src/scripts/templates. scripts/pack_pipeline.py embeds
them as base64 into packed_generate_pipeline.py before orb packing, preventing
CircleCI from interpolating template expressions during setup. The orb includes
the complete generated resource; no runtime source-tree template access is needed.
make pack regenerates it and CI rejects a stale generated resource.
Continuation credentials and response bodies are never printed.
Run `make test-pipelines` with CircleCI CLI, Python3/PyYAML and Bash available.
Tests use offline temporary Git repositories and a bare origin to cover selection,
whole-branch changes, tags, errors, defaults and source/packed parity. The hosted
pipeline-contract-test runs the source suite and shared Maven behavioral tests;
the full local target additionally extracts and executes the actual packed command.
## Node snapshot versions
The shared Node publisher calculates develop snapshots as
`MAJOR.MINOR.NEXT_PATCH-SNAPSHOT.CIRCLE_BUILD_NUM`. A positive CircleCI job number
is required, so independent publication jobs receive distinct npm coordinates.
The package version is changed only in the build workspace and published under
the `snapshot` dist-tag. No snapshot version commit is pushed: the branch remains
at the source revision whose required checks ran, avoiding unchecked `[skip ci]`
heads and recursive publication. Stable, RC and hotfix version policies are unchanged.
## Android and MCP policy profiles
`android` and `mcp-policy` accept only profile, orb_version and default_branch.
Android retains the audited Android/GCP orb versions and every active unit,
emulator and Maven-publication step. The emulator now runs on main as well as
feature branches so main publication cannot omit its required instrumentation
gate. Dormant Firebase benchmark and release-build definitions referencing absent
app/macrobenchmark modules are not scheduled or copied into the profile.
MCP policy validation remains a small Python container validating all visible YAML
and required pattern fields. Its existing PyYAML dependency is pinned to 6.0.3.
Neither profile introduces Maven/JUnit stand-ins for its actual tests.
`tests/test_mobile_policy_profiles.py` protects Android steps and dependency edges
and executes the policy validator with valid, incomplete and malformed documents.
The generator suite verifies source/packed parity for both profiles.
+22 -17
View File
@@ -6,17 +6,18 @@ orb version. The canonical QQQ setup produces one final continuation containing
jobs from the pinned `kof22/munitor@0.3.11` orb. It never invokes Munitor's setup
generator or creates another continuation.
The profile is the exact semantic graph rendered by Munitor 0.3.11 from
marketing-website commit `4eb5f63b9fbfac8e5529fcd638324870cea08ae2`, with its
manifest's floating `0.3` pin changed to `0.3.11` for the baseline render.
The checked-in fixture records that real render; the JSON resource contains the
same jobs, parameters, contexts, filters and dependency edges.
The baseline fixture records the original Munitor 0.3.11 render. The shared
profile selects one workflow for the current branch and exposes it as `verify`:
PR checks for feature/hotfix/automation branches, develop, staging, release
candidate, or production for main. Tags and the RC bookkeeping branch do not
run these jobs. Existing deployment dependencies and contexts are preserved.
There are five workflows and 33 job invocations: PR checks (7), develop (7),
staging (7), release candidate (8), and production (4). They preserve Node 22,
Chromium Playwright and Lighthouse, the existing scan and quality jobs, advisory
SAST, and the existing synthetic zero-threshold coverage command. That command
does not measure actual coverage.
The build job installs dependencies once, lints, builds, runs Chromium
Playwright tests, crawls local links and runs Lighthouse. The link crawl waits
at most 60 attempts for the app on port 3005, propagates failures, and stops its
server on exit. Playwright and Lighthouse reports are retained as artifacts,
including on failure. The old synthetic coverage job was removed because it
fabricated 100% rather than measuring coverage; actual tests and scans remain.
Production follows build → image build/Trivy/push/health → independent CD update
and GitHub release. Both final jobs depend on the image job; neither depends on
@@ -26,15 +27,19 @@ existing `github` context; image publication uses `ghcr`. Production-only means
no non-main deployment update, not no non-main artifacts: develop/staging image
publishing and release-candidate GitHub releases remain unchanged.
Keep `.munitor.yml` as declarative worker input when migrating the consumer.
Munitor's `generate_dockerfile` reads it from the attached workspace and requires
`pipeline: node-webapp` and `docker.use_repo_dockerfile: true` to preserve the
repository Dockerfile. The profile does not replace that file or validate all
of its values. Changes to worker input require review alongside the centralized
profile; arbitrary manifest job overrides are not supported. Health remains `/`
on port 3000; the repository Dockerfile remains responsible for the standalone
Consumers need only the QQQ caller and `.qqq-ci.yml`. Before tests, the shared
profile writes minimal `.munitor.yml` worker input into the build workspace:
`pipeline: node-webapp`, Node 22, and `docker.use_repo_dockerfile: true`.
Munitor's Docker worker still requires this file; the orb owns its contents.
This preserves the repository Dockerfile rather than generating a replacement.
Container health remains `/` on port 3000, distinct from the local test server
on port 3005. The repository Dockerfile remains responsible for the standalone
runtime without npm or npx.
The duplicate consumer GitHub test workflow can be removed only after these
central checks qualify. Application test settings and assertions remain in the
application repository; orchestration belongs here.
`MarketingContractTests` checks whole-graph equality and explicit release/test
contracts. The normal generator suite additionally checks source/packed parity.
These are configuration tests, not a claim of hosted delivery, credentials,
+12
View File
@@ -0,0 +1,12 @@
# Shared QBit source scanning
Generate the thin caller with `python3 src/scripts/generate_auxiliary_workflow.py qbit-codeql --ref <immutable-worker-sha>`.
The reusable worker selects supported languages from tracked files in the actual checked-out branch. Historical Java branches therefore do not request an absent Actions database. Java, JavaScript/TypeScript, Python and Actions share one job; Kotlin selects an actual build instead of silently omitting Kotlin from no-build Java analysis.
The caller scans pull requests, main/develop/release/hotfix pushes and weekly, cancels superseded PR scans, and contains no scan implementation. Set `codeql_worker_sha` in the estate enforcement policy to require the exact canonical caller independently of other native worker pins. Existing default-setup repositories remain unchanged until migrated.
Roll out to both active default and maintained branches. Verify the worker on representative branch contents and preserve existing query coverage before replacing GitHub default setup; do not run duplicate default and advanced scanners permanently. Default setup cannot select languages independently for historical branches. A branch with no supported application or workflow source is a placeholder to classify, not a passing application scan.
Local tests execute the embedded language-selection step against real git indexes, including absent Actions, untracked generated files, mixed source, Kotlin and placeholders. Hosted CodeQL database creation and SARIF upload must also pass before claiming rollout completion.
References: [GitHub setup types](https://docs.github.com/en/code-security/concepts/code-scanning/setup-types) and [CodeQL build modes](https://docs.github.com/en/code-security/reference/code-scanning/codeql/build-options-for-compiled-languages).
+24 -2
View File
@@ -8,11 +8,16 @@ recognized contracts:
|---|---|---|
| `release_on_main` | boolean, default false | Main pushes select the existing release job when release publishing is enabled. |
| `release_tag_policy` | `stable`, `v-prefix`, `none` | Stable `v1.2.3`, the existing broad `/v.*/` contract, or no tags. |
| `test_branch_policy` | `all`, `non-release`, `non-release-no-integration`, `feature`, `non-release-no-main` | Selects one of the five audited test branch exclusions. |
| `test_branch_policy` | `all`, `non-release`, `non-release-no-integration`, `feature`, `non-release-no-main`, `non-release-no-hotfix`, `non-release-no-main-hotfix`, `feature-no-hotfix` | Selects an audited test branch exclusion. |
| `publish.hotfix` | boolean, default false | Runs the existing Maven hotfix publisher for nonempty `hotfix/*` branch events only when explicitly enabled. |
`feature` preserves the original exclusion of develop, main, release branches,
and integration-prefixed branches; it is not a new feature-prefix-only rule.
All policies continue to exclude the RC coordination lock branch.
The three hotfix exclusions preserve the corresponding legacy policies while
the single shared publisher handles hotfix events. Existing manifests do not
enable hotfix publication implicitly; migration enables it only when the source
configuration contains the recognized hotfix publisher and branch filter.
No consumer-supplied regex, command, job, or arbitrary branch-publication rule
is accepted.
@@ -32,10 +37,27 @@ fail migration rather than silently changing release behavior.
Use `tools/standardize_qbit.py --write` for the two-file migration. API callers
must pass the inferred policy to
`canonical_caller(version, manifest["release_tag_policy"])`; the legacy one-argument
`canonical_caller(version, manifest["release_tag_policy"], manifest["publish"].get("feature", False))`; the legacy one-argument
form is only for manifests without an explicit policy.
`publish.feature` is false by default. Opting in enables the audited `publish*`
tag contract, with the tag required to resolve to the checked-out commit. The
canonical setup admits those tags alongside the declared release tag policy.
Feature branch pushes remain test-only. Migration accepts Workflows' exact legacy
literal `feature/.*` branch selector (not a regular expression); Git forbids `*`
in branch names, so that selector cannot publish a branch. Unknown feature
filters require a central profile change rather than silently broadening triggers.
Focused tests cover the immutable inventory, unknown-filter rejection, canonical
caller agreement, main opt-in, broad/stable tag selection, HEAD provenance,
publication opt-out and test exclusions. The packed generator suite also exercises
main, broad RC-shaped tags, and excluded integration branches.
Fifteen additional main-branch fixtures exercise 195 branch/tag cases,
checking both test and publication selection. Source and packed generator tests
also verify hotfix opt-in, its boolean validation, and unchanged main behavior.
CMS's original YAML is retained with its immutable source SHA: its unquoted
stable-tag regex is invalid YAML. The fixture repairs only that quoting. Both
audited spellings of the stable regex map to the same ASCII-digit tag policy;
arbitrary regexes remain rejected.
CI-only commits on publishing branches retain Maven verification without publishing when their changes are limited to the manifest, CircleCI caller, shared scanner caller, RC caller, or schema-drift caller. The commit must have one parent and a conventional ci title. Tags, application POMs, schema resources, tests, and other application inputs retain normal publication behavior. Canonical caller enforcement separately verifies the shared workflow definition and immutable worker pin.
+16
View File
@@ -0,0 +1,16 @@
# Application-free branch verification
Use `profile: repository-policy` only on a branch containing repository policies,
documentation, workflow configuration and optional unused Maven wrappers. It uses
the same canonical setup caller as other profiles and one small Python verification
job. It checks tracked YAML/JSON syntax and rejects application manifests, source
files, unknown file types and symlinks. It never builds or publishes an application.
The manifest accepts only `profile`, `orb_version` and `default_branch`. The latter
remains the repository's actual default branch. A future application promotion must
select its real build profile in the same change; adding source without doing so fails.
Estate policy can set `branch_profiles: {main: repository-policy}` without changing
the default branch's application profile. Require the CircleCI `setup` and `verify`
checks on the policy branch. This profile does not establish application release
readiness or replace the build/release checks on source-bearing branches.
+66
View File
@@ -0,0 +1,66 @@
# Shared orb check enforcement
`tools/enforce_orb_checks.py` replaces repository-specific scripts for the shared
CircleCI `setup` and `verify` branch gates. One invocation processes an explicit
batch of current `main` and `develop` branches using existing `gh` authentication.
Create a targets file:
```json
[
{"repository": "QRun-IO/qbit-example", "branch": "main"},
{"repository": "QRun-IO/qbit-example", "branch": "develop"}
]
```
Preview, then apply the same batch:
```sh
python tools/enforce_orb_checks.py --targets targets.json --orb-version 0.8 --output enforcement-plan.json
python tools/enforce_orb_checks.py --targets targets.json --orb-version 0.8 --output enforcement-result.json --apply
```
Every branch must already contain the exact canonical caller for its manifest and
have successful `setup` and `verify` checks from CircleCI app 18001 at its current
commit. Supported profiles are QBit, Core, frontend-core, frontend-material and repository-policy.
The complete batch is inspected before any mutation. Source/head/protection drift,
unavailable APIs and unknown profiles fail closed. Existing repository rulesets are verified as described below.
The tool appends the app-bound checks, enables strict checks and administrator
enforcement, and reads the result back. Existing required checks remain required.
For protected branches it uses the narrow status-check/admin endpoints, preserving
reviews, signatures, linear history, restrictions and other settings. For a
previously unprotected branch it creates protection without adding human reviews.
It never changes scanner configuration, repository visibility, billing, or source.
Output records the planned head and original protection, then verification as each
branch completes. A batch is not transactional: if an API call fails, inspect the
output and rerun; successful protections are retained rather than rolled back.
An already-correct branch needs no mutation.
This command covers the shared orb gate pair only. Continue to run the estate
audit for scanner/native-worker requirements and other policy. Automatic repository
discovery, source enrollment and scheduled reconciliation remain separate work.
GitHub API reference: [protected branches](https://docs.github.com/en/rest/branches/branch-protection).
```sh
python -m unittest discover -s tests -p test_enforce_orb_checks.py -v
```
## Existing rulesets
When effective branch rules come from repository rulesets, the tool can verify
existing enforcement without adding classic protection. Each contributing ruleset
must be active for branches, have no bypass actors and require both setup and
verify from CircleCI app18001. The current branch must also have successful gate
runs. The tool rechecks the branch, effective rules and full ruleset records before
reporting verified. Rule drift or an unbound/missing gate stops verification.
This path writes nothing. It preserves scanner requirements, conditions and the
existing up-to-date-branch policy, including a false strict setting that avoids
unnecessary rebuilds. Reports identify protection_mode=rulesets and the observed
strict value. Unsupported organization-level rulesets, bypass actors and missing
gates remain unresolved rather than being rewritten or ignored.
For classic protection with an empty push allowlist and admin enforcement disabled, the tool leaves the entire classic policy unchanged. After current-head gates pass, it creates a narrowly scoped active repository ruleset requiring app-bound setup and verify with no bypass actors. This enforces CI even for administrators without changing their existing branch access or locking all actors out. The ruleset retains the fleet freshness policy (strict=false); it does not weaken any existing classic policy. A same-named ruleset causes rejection rather than overwrite or duplication. Readback verifies the effective gates and unchanged classic protection; subsequent runs recognize the existing ruleset without writes.
+152
View File
@@ -0,0 +1,152 @@
# Batch consumer enrollment
Use one target file for canonical consumers of every supported Circle profile and
legacy QBits whose jobs and publication filters the shared converter recognizes:
```json
[
{"checkout": "/work/qbit-example", "default_branch": "main"},
{"checkout": "/work/qqq", "default_branch": "develop"}
]
```
The branch values must come from repository inventory. Run on clean isolated
checkouts of the branches being migrated.
```sh
python tools/enroll_consumers.py targets.json --orb-version 0.8
python tools/enroll_consumers.py targets.json --orb-version 0.8 --write
```
The command validates the entire batch before writing. Existing manifests keep
all publication and profile options; only the managed orb version changes.
Recognized legacy QBits receive the canonical caller and inferred publication
policy. An unknown job, filter, profile option, duplicate target, symlink, or
concurrent declaration edit rejects the batch. Repeating a completed enrollment
makes no changes. Filesystem errors during the write phase can leave a partial
batch; rerun after correcting the error. This is not a filesystem transaction.
Only `.circleci/config.yml` and `.qqq-ci.yml` are changed. The tool does not delete
other workflows, infer publication from repository names, or enroll unknown
custom pipelines. Their behavior must first be represented by a central profile.
After committing and qualifying the exact source, apply the shared
[branch enforcement tool](branch-enforcement.md) to supported gate profiles.
This command provides batch source conversion. Use the coordinator below for remote signed submissions. Local conversion alone does not prove fleet deployment or release success.
## Remote signed submissions
Supply observed current branches, without cloning each repository yourself:
```json
[
{"repository": "QRun-IO/qbit-example", "branch": "main"},
{"repository": "QRun-IO/qqq", "branch": "develop"}
]
```
```sh
python tools/reconcile_enrollment.py --targets remote-targets.json --orb-version 0.8 --output plan.json
python tools/reconcile_enrollment.py --targets remote-targets.json --orb-version 0.8 --output result.json --apply
```
Use existing `gh` authentication with repository write access. The coordinator
never installs credentials or changes authentication. Every target is inspected
at an immutable head and validated before any remote mutation. No repository
clone, SSH key or local signing key is required. A moved target stops submission;
refresh the plan instead of overwriting it.
An automation branch derives from the source commit and proposed declarations.
The coordinator creates the branch at the observed base and uses GitHub's
`createCommitOnBranch` API with `expectedHeadOid` for an atomic append. GitHub
signs the commit when supported by the authenticated identity; the coordinator
requires remote signature verification, exact parent, changed paths and
declaration bytes before opening a PR. It never force-updates a branch.
An interrupted branch creation, commit or PR creation can be resumed:
an existing branch still at the planned base receives the missing commit;
matching signed branches and PRs are reused. A mismatched branch is rejected.
Closed existing PRs are reported as existing; they are not silently reopened.
Reports include repository, branch, immutable head and submission URL, without
embedding declaration contents or credentials. Keep the report if a later target
fails; earlier valid submissions remain intact.
API permission, signature or commit-conflict failures stop the run. A timeout
can occur after GitHub accepted a mutation, so inspect remote state or repeat
the same invocation; do not create a different automation branch to retry.
See [GitHub commit API documentation](https://docs.github.com/en/graphql/reference/commits#createcommitonbranch).
This handles remote target lists and signed submissions. Organization discovery is described below. Qualification-aware merging and classic branch enforcement are described below; scheduling and ruleset reconciliation remain separate work. A submitted PR is not a completed migration. Unknown profiles and
native workflows require their own central conversion, not deletion by this tool.
## Organization discovery
The coordinator can select observed current branches directly from GitHub:
```sh
python tools/reconcile_enrollment.py --organization QRun-IO --orb-version 0.8 --output organization-plan.json
python tools/reconcile_enrollment.py --organization QRun-IO --orb-version 0.8 --output organization-result.json --apply
```
Repository and branch inventories are paginated. Only existing main/develop
branches are considered; historical release branches are excluded. Archived
repositories and the orb's own bootstrap repository are reported separately.
Each supported branch receives the same immutable preflight as explicit targets.
Unknown workflows, missing entrypoints, unsupported branch layouts and unavailable
APIs stay `unresolved` in the output. They are never counted as conforming or
silently converted. No-CI and native-only repositories may therefore appear as
unresolved here; use the estate auditor for their separate policy classification.
Discovery finishes before any submission. `--apply` processes qualified plans
and retains unresolved entries for follow-up; one unsupported repository does
not prevent independent valid submissions. An explicit `--targets` batch keeps
its stricter behavior: any preflight failure stops the whole batch. By default neither mode merges PRs or changes branch protections. Use the explicit completion flags below.
## Qualification and enforcement
```sh
python tools/reconcile_enrollment.py --targets remote-targets.json --orb-version 0.8 --output result.json --apply --merge-ready --enforce
```
Both flags require `--apply` and are optional. `--merge-ready` revalidates the
signed submission, exact parent/files/content and current base, requires successful
CircleCI-app `setup` and `verify` checks and every advertised latest check/status,
then requests a normal exact-head squash merge. It never uses admin override or
force pushes. The resulting signed merge must have the qualified source tree.
Pending/failed checks and changed bases are reported without merging. Repeated
runs can advance the same PR once checks complete; there is no polling loop that
holds a CI executor open.
`--enforce` independently checks the actual current target branch, which must
pass its own orb gates before shared classic protection enforcement. Existing
protections and other required checks are preserved. Supported gate profiles are
QBit, Core, frontend-core, frontend-material and repository-policy. Other profiles
remain explicitly unsupported for completion even when source enrollment works.
Existing active repository rulesets with app-bound gates and no bypass actors are verified without writes. Unsupported or incomplete rulesets remain unresolved; none are rewritten or layered with classic protection. API/plan restrictions remain visible.
A merged source update and an enforced branch are separate reported outcomes.
Neither proves artifact publication or deployment. Scheduling and ruleset
reconciliation remain outstanding.
## Central hosted pass
The orb owner's CircleCI config accepts `run_enrollment_reconcile: true` on
`main`. This selects one small Python container instead of the normal orb
build/publication workflow. It uses the existing
`qqq-maven-registry-credentials` context's GitHub token through `gh`.
No consumer-specific runner configuration or local signing key is needed.
`tools/run_enrollment.py` verifies the owner repository and main branch, runs
organization discovery, signed enrollment, qualified merging and enforcement,
then exits. The pass has a 20-minute execution limit. Pending checks are reported
for the next pass rather than polled while a paid executor waits. Incremental
results and execution status are retained under `artifacts/enrollment`, including
when execution fails or times out. A completed pass does not mean every repository
conforms: unresolved and waiting entries remain explicit follow-up work.
Create a single daily CircleCI schedule for the owner project only after a manual
main-branch pass verifies its hosted credentials and results. Set `branch: main`
and `run_enrollment_reconcile: true` in the schedule parameters. Scheduling is
an external project setting; merging this config does not itself enable a schedule.
Keep the existing RC-finalization parameter false for these runs. A timed-out
GitHub request may already have succeeded remotely; the next pass resumes from
the deterministic branch and verified source rather than forcing updates.
+70
View File
@@ -0,0 +1,70 @@
# 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.
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.
The same daily pass manages CircleCI's native `autocancel-builds` setting for
canonical `repository-policy`, `homebrew-tap`, `application-template`, and
`marketing` consumers. Marketing must retain `main` as its default branch;
environment deployment remains main-only. CircleCI excludes default-branch,
scheduled and rerun workflows from automatic cancellation. This avoids a custom
cancellation job and does not add executions to consumer pipelines.
The pass uses the existing orb-publishing context on the trusted orb main branch.
It changes only the cancellation flag, checks for source movement before writing,
and verifies preservation of all other flags. Its separate
`result.circle-settings.json` artifact records missing credentials/API access,
unconverted sources and profiles needing cancellation-policy review explicitly.
Publication-heavy profiles are not changed until their non-default release
semantics are reviewed; a successful reconciliation pass does not certify them.
Because cancellation is project-wide, eligibility requires every discovered current main/develop branch to be canonical and use a reviewed profile. An unresolved branch or an unreviewed publishing profile prevents enabling the flag, regardless of branch order. The report lists all observed profiles.
+37
View File
@@ -0,0 +1,37 @@
# Managed patch updates
The canonical caller and manifest accept either an exact stable version such as
`0.8.0` or a quoted minor track such as `"0.8"`. CircleCI resolves a minor track
to its latest published patch. A major-only version, `latest`, `volatile`, and
wildcards are rejected. The caller import, setup parameter, and manifest must
still agree exactly.
Use a minor track after qualifying that release line. Future patch fixes then
arrive on the repository's next pipeline without a version-bump PR or an extra
fleet-wide build. Existing exact pins remain supported and are not changed by
publishing this capability. YAML minor versions must be quoted to remain strings.
The central batch tool applies the same update to all supplied checkouts:
```sh
python3 tools/rollout_version.py --orb-version 0.8 --write /path/to/repo1 /path/to/repo2
```
This changes only the two canonical CI declarations. Publication policies,
contexts, branch/tag filters, and profile options stay unchanged. Normal source
and publication checks still run when a pipeline is triggered; this setting does
not skip tests. GitHub reusable-worker commit pins are separate and unchanged.
Automatic patch adoption trades exact-version reproducibility for centrally
managed fixes. Keep patch releases backward compatible, qualify central changes
before production publication, and use an exact stable pin for a canary or
rollback. For example, the same tool can move a consumer from `0.8` back to
`0.8.0`. Historical pipeline reruns can resolve a newer patch; choose an exact
pin when reproducing an earlier run. Setup and continuation each resolve their
orb imports, so patch compatibility also matters when publication overlaps a run.
Changing minor tracks is an explicit migration. Do not use this feature to push
breaking changes into a patch release or to bypass repository checks.
Reference: [CircleCI orb semantic versioning](https://circleci.com/docs/orbs/use/orb-concepts/).
+39 -1
View File
@@ -26,7 +26,8 @@ https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-t
- Finalization retrieves the unique unexpired intent artifact and verifies its
originating successful `release-rc.yml` run, repository, trigger and attempt.
Callback fields must match that immutable intent.
- The exact merge SHA must have a successful `publish_release_candidate` Check Run
- The exact merge SHA must have a successful `verify` (or legacy
`publish_release_candidate`) Check Run
from CircleCI app ID `18001`; unrelated job statuses cannot authorize release.
Terminal publisher failure stops finalization immediately. Pending/absent publication cannot authorize a tag.
The RC bump must have exactly that one parent and the release branch must still
@@ -80,3 +81,40 @@ release-captain reconciliation; the sweep does not invent provenance.
syntax. Full actionlint with Windows native ShellCheck hung locally and was
stopped; Linux actionlint/ShellCheck and end-to-end credential/callback rollout
verification remain required. The orb has separate sweep/dispatch fixture tests.
### Published upload timeout recovery
A Circle deployment step can time out after Central has accepted and published its
bundle. Use the canonical caller's explicit manual `recover` input with the existing
`merge_sha`, `branch`, `version` and original `circle_build`. Run with `dry_run: true`
first to verify evidence without changing the branch, tag, release or pending lock.
This mode never builds, uploads, cuts a new candidate, or changes the failed Circle check.
The pinned orb worker requires the original successful cut intent and unchanged lock,
the exact failed Circle workflow/check, a final deployment timeout after all preceding
actions (including Maven Verify) succeeded, exactly one successful upload receipt,
and an authenticated Central `PUBLISHED` response matching every staged coordinate.
It also checks public POM coordinates and publication timestamps after the cut.
Existing organization `CENTRAL_USERNAME` and `CENTRAL_PASSWORD` secrets authenticate
only the Central status request; Circle evidence uses its public API. Redirects are
rejected and credentials are never included in the recovery receipt.
After verification, recovery creates only the missing signed version bump as a direct
child of the original release merge, using a normal fast-forward push. An existing
bump must pass the same parent/version checks. The existing signed-tag/prerelease
finalizer then completes the candidate and compares lock ownership before cleanup.
A later explicit recovery retry verifies the original receipt again. Once the lock
is gone, the completed release needs no recovery dispatch. Ordinary callbacks and
scheduled reconciliation retain the requirement for a successful Circle publisher.
Central status API: https://central.sonatype.org/publish/publish-portal-api/
### Auditing independent worker revisions
The estate audit accepts `rc_worker_sha` in a profile or repository policy. For
example, set `profiles.qbit.rc_worker_sha` to the approved immutable RC worker
commit and keep `--worker-sha` at the approved revision for unchanged native
workers. The audit still compares every caller to its exact canonical template
and rejects mutable or mismatched pins. This avoids a fleet-wide native caller
update when only RC release behavior changes. Required-check policy is separate;
omitting it continues to report enforcement as unknown.
+3 -2
View File
@@ -12,8 +12,9 @@ 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"), ("MARKETING_TEMPLATE", "marketing")):
payload = base64.b64encode(zlib.compress((source.parent / "templates" / (name + ".json")).read_bytes(), level=9)).decode("ascii")
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}")))')
packed = text[:start] + "\n".join(embedded) + text[end:]
if len(packed.encode("utf-8")) > 100_000:
+8 -1
View File
@@ -10,6 +10,11 @@ description: >
- Collects JUnit XML test results
- Stores test results and screenshots
- Saves Maven cache for future builds
parameters:
build_before_test:
type: boolean
default: true
description: "Build the React app first; combined jobs already build it with frontend_build"
steps:
# Ensure no stale Chrome/Driver is shadowing the PATH (your base image had Chrome 109)
- run:
@@ -17,7 +22,7 @@ steps:
command: <<include(scripts/frontend_test_cleanup.sh)>>
# Install current Chrome; DO NOT install chromedriver (let Selenium 4 auto-manage it)
- browser-tools/install-chrome
- install_chrome
# System libs Chrome needs in headless CI
- run:
@@ -52,6 +57,8 @@ steps:
# GPG signing will happen later in mvn_jar_deploy when deploying to Maven Central.
- run:
name: Build app, start server, run tests
environment:
PARAM_BUILD_BEFORE_TEST: << parameters.build_before_test >>
command: <<include(scripts/frontend_test_run.sh)>>
# Always collect and publish test results & screenshots
+5
View File
@@ -0,0 +1,5 @@
description: Install stable Chrome using only its signed repository and existing Ubuntu dependency indexes.
steps:
- run:
name: Install Google Chrome
command: <<include(scripts/install_chrome.sh)>>
+1 -1
View File
@@ -21,7 +21,7 @@ steps:
- when:
condition: << parameters.install_browsers >>
steps:
- browser-tools/install-chrome
- install_chrome
- browser-tools/install-chromedriver
- when:
condition: << parameters.compile_before_verify >>
+8
View File
@@ -5,6 +5,12 @@ description: >
- Deploys signed artifacts and waits for confirmed Central release publication
- Saves Maven cache for future builds
parameters:
skip_verified_analysis:
type: boolean
default: false
description: "Skip repeated SpotBugs and PMD only after this job has completed mvn_verify"
steps:
- run:
name: Setup Maven Settings
@@ -17,6 +23,8 @@ steps:
# Central's native publication wait can be silent for its 30-minute limit.
# Let Maven return its real result before CircleCI's inactivity watchdog.
no_output_timeout: 35m
environment:
QQQ_SKIP_VERIFIED_ANALYSIS: << parameters.skip_verified_analysis >>
command: <<include(scripts/mvn_jar_deploy.sh)>>
- save_cache:
paths:
+1 -1
View File
@@ -3,7 +3,7 @@ description: >
- Adds SSH keys for Git operations
- Sets up Git identity for version commits
- Synchronizes NPM version
- Commits version changes if modified (skipped for feature branches)
- Commits version changes if modified (skipped for feature and snapshot builds)
parameters:
branch_type:
+6
View File
@@ -0,0 +1,6 @@
description: >
macOS arm64 executor for the opt-in CLI platform lane.
Requires the CircleCI plan to include the m4pro.medium resource class.
macos:
xcode: 16.4.0
resource_class: m4pro.medium
+7
View File
@@ -0,0 +1,7 @@
description: >
Windows x64 executor for the opt-in CLI platform lane. Steps run in Git Bash.
Requires the CircleCI plan to include the windows.medium resource class.
machine:
image: windows-server-2022-gui:current
resource_class: windows.medium
shell: bash.exe
+25
View File
@@ -0,0 +1,25 @@
description: >
Opt-in CLI platform lane: install, build, unit tests and lint on a non-Linux
executor. Rendered by the cli profile only for manifest platforms entries.
executor: << parameters.executor >>
parameters:
executor:
type: executor
description: "qqq-orb/cli_macos_arm64 or qqq-orb/cli_windows_x64"
node_version:
type: string
default: "20.20.2"
description: "Exact Node.js version installed with the image's nvm (the packages' engines floor)"
steps:
- checkout
- run:
name: Install Node.js << parameters.node_version >>
environment:
PARAM_NODE_VERSION: << parameters.node_version >>
command: <<include(scripts/cli_platform_node.sh)>>
- run:
name: Install locked CLI dependencies
command: npm ci
- run:
name: Build, tests and lint
command: npm run build && npm test && npm run lint
+3 -3
View File
@@ -1,13 +1,13 @@
description: >
Authoritative QQQ CLI validation, with optional tagged GitHub Packages publication.
Preserves generated-schema drift, build, tests and Prism smoke before publishing.
Preserves generated-schema drift, build, tests, lint and Prism smoke before publishing.
docker:
- image: cimg/node:22.12
- image: cimg/node:22.23
parameters:
publish:
type: boolean
default: false
description: "Publish three workspaces with rc dist-tag; requires matching version tag and GITHUB_TOKEN"
description: "Publish four workspaces (dist-tag rc for prereleases, latest for final versions); requires matching version tag and GITHUB_TOKEN"
steps:
- checkout
- restore_cache:
+2 -1
View File
@@ -27,7 +27,8 @@ steps:
- git_full_checkout
- mvn_manage_version
- frontend_build
- frontend_test
- frontend_test:
build_before_test: false
- frontend_package
- mvn_jar_deploy
- git_operations:
+2 -1
View File
@@ -23,4 +23,5 @@ steps:
node_version: << parameters.node_version >>
- git_full_checkout
- frontend_build
- frontend_test
- frontend_test:
build_before_test: false
+2 -1
View File
@@ -57,7 +57,8 @@ steps:
steps:
- check_middleware_api_versions
- mvn_jar_deploy
- mvn_jar_deploy:
skip_verified_analysis: true
- when:
condition:
+24 -1
View File
@@ -161,7 +161,7 @@ set_version() {
##############################################
## Use Maven versions plugin to set version ##
##############################################
mvn versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
mvn -f "$POM_FILE" versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
#######################
## Verify the change ##
@@ -175,6 +175,26 @@ set_version() {
fi
}
ensure_project_version() {
local expected=$1 actual
# A revision property can exist without being used by project.version.
# Ask Maven for the effective coordinate, including inherited configuration.
actual=$(mvn -f "$POM_FILE" -q -Dstyle.color=never \
org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate \
-Dexpression=project.version -DforceStdout)
if [[ "$actual" != "$expected" ]]; then
mvn -f "$POM_FILE" -B versions:set -DnewVersion="$expected" -DgenerateBackupPoms=false
actual=$(mvn -f "$POM_FILE" -q -Dstyle.color=never \
org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate \
-Dexpression=project.version -DforceStdout)
fi
if [[ "$actual" != "$expected" ]]; then
echo "ERROR: Effective project version is $actual; expected $expected" >&2
exit 1
fi
echo "Verified effective project version: $actual"
}
#############################################
## Branch Detection and Routing Functions ##
#############################################
@@ -434,6 +454,9 @@ main() {
fi
echo ""
if [[ "$DRY_RUN" != "true" ]]; then
ensure_project_version "$NEW_VERSION"
fi
echo "=== Version calculation complete ==="
}
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# nvm is a shell function on macOS and not nounset-safe, so no -u here.
set -eo pipefail
# Install the exact Node.js version with the image's nvm (macOS login shell, nvm-windows in Git Bash).
nvm install "$PARAM_NODE_VERSION"
if [[ "$OSTYPE" == darwin* ]]; then
# Later steps start new login shells: make the version their default.
nvm alias default "$PARAM_NODE_VERSION"
else
# nvm-windows switches the global symlink, which later steps inherit.
nvm use "$PARAM_NODE_VERSION"
fi
node --version
npm --version
+18 -4
View File
@@ -2,10 +2,12 @@
set -euo pipefail
# Validate tag and fixed package destinations before asking for credentials.
node --input-type=commonjs - <<'NODE'
# Prints the npm dist-tag shared by all four packages.
dist_tag=$(node --input-type=commonjs - <<'NODE'
const fs = require('node:fs');
const packages = [
['packages/ui-api-client/package.json', '@qrun-io/qqq-ui-api-client'],
['packages/core/package.json', '@qrun-io/qqq-core'],
['packages/conformance/package.json', '@qrun-io/qqq-ui-api-conformance'],
['packages/cli/package.json', '@qrun-io/qqq-cli'],
];
@@ -19,7 +21,18 @@ const client = JSON.parse(fs.readFileSync(packages[0][0], 'utf8'));
if (!process.env.CIRCLE_TAG || process.env.CIRCLE_TAG !== 'v' + client.version) {
throw new Error('Version tag must match the client package version');
}
// The CLI pins core exactly and shares its version: publish only that pair.
const core = JSON.parse(fs.readFileSync(packages[1][0], 'utf8'));
const cli = JSON.parse(fs.readFileSync(packages[3][0], 'utf8'));
if (core.version !== cli.version || cli.dependencies?.['@qrun-io/qqq-core'] !== core.version) {
throw new Error('Core package version must match the CLI version and its exact core dependency');
}
// Final releases become latest; any prerelease part (e.g. -rc.1, -beta.2) in
// any of the four keeps every package on rc, so latest never points at an rc.
const versions = packages.map(([path]) => JSON.parse(fs.readFileSync(path, 'utf8')).version);
console.log(versions.some((version) => version.includes('-')) ? 'rc' : 'latest');
NODE
)
: "${GITHUB_TOKEN:?GitHub Packages write credential GITHUB_TOKEN is required}"
export NODE_AUTH_TOKEN="$GITHUB_TOKEN"
# Store only an environment substitution, never the token itself.
@@ -35,6 +48,7 @@ export NPM_CONFIG_USERCONFIG="$npm_config"
# Authentication alone is not proof of package write permission; hosted publish
# migration remains gated on verifying the actual context's package access.
npm whoami --registry https://npm.pkg.github.com >/dev/null
npm publish -w @qrun-io/qqq-ui-api-client --registry https://npm.pkg.github.com --tag rc
npm publish -w @qrun-io/qqq-ui-api-conformance --registry https://npm.pkg.github.com --tag rc
npm publish -w @qrun-io/qqq-cli --registry https://npm.pkg.github.com --tag rc
npm publish -w @qrun-io/qqq-ui-api-client --registry https://npm.pkg.github.com --tag "$dist_tag"
npm publish -w @qrun-io/qqq-core --registry https://npm.pkg.github.com --tag "$dist_tag"
npm publish -w @qrun-io/qqq-ui-api-conformance --registry https://npm.pkg.github.com --tag "$dist_tag"
npm publish -w @qrun-io/qqq-cli --registry https://npm.pkg.github.com --tag "$dist_tag"
+2 -1
View File
@@ -2,9 +2,10 @@
set -euo pipefail
npm run generate
git diff --exit-code -- packages/ui-api-client/src/schema.ts
git diff --exit-code -- packages/ui-api-client/src/schema.ts packages/core/src/api/operations.ts
npm run build
npm test
npm run lint
# Use the locked local executable; never download an unpinned npx fallback.
./node_modules/.bin/prism mock --port 4010 packages/ui-api-client/openapi/qqq-v1.json > prism.log 2>&1 &
+12 -2
View File
@@ -11,10 +11,20 @@
## Output: Installs required system libraries
############################################################################
set -e
set -euo pipefail
echo "Installing browser dependencies"
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
ubuntu_sources=/etc/apt/sources.list
if [[ ! -s "$ubuntu_sources" ]]; then
ubuntu_sources=/etc/apt/sources.list.d/ubuntu.sources
fi
if [[ ! -s "$ubuntu_sources" ]]; then
echo 'Cannot locate Ubuntu package sources' >&2
exit 1
fi
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update \
-o "Dir::Etc::sourcelist=$ubuntu_sources" \
-o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev
+3 -1
View File
@@ -15,7 +15,9 @@ set -e
echo "Building app, starting server, running tests"
echo "HTTPS=true" >> ./.env
npm run build
if [[ "${PARAM_BUILD_BEFORE_TEST:-true}" == true ]]; then
npm run build
fi
export REACT_APP_PROXY_LOCALHOST_PORT=8001
export PORT=3001
npm run start &
+181 -21
View File
@@ -23,7 +23,10 @@ ALL_TEMPLATE = json.loads((_TEMPLATE_DIR / "all.json").read_text(encoding="utf-8
STARTER_TEMPLATE = json.loads((_TEMPLATE_DIR / "app-starter.json").read_text(encoding="utf-8"))
ANDROID_TEMPLATE = json.loads((_TEMPLATE_DIR / "android.json").read_text(encoding="utf-8"))
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
@@ -61,6 +64,10 @@ def boolean(data, key, default):
return value
# Opt-in CLI platform lanes: manifest entry -> orb executor.
CLI_PLATFORMS = {"macos-arm64": "qqq-orb/cli_macos_arm64", "windows-x64": "qqq-orb/cli_windows_x64"}
def load_manifest(path, setup_version):
raw = Path(path).read_text(encoding="utf-8")
if len(raw) > 65536:
@@ -69,16 +76,20 @@ 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", "marketing"):
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "node-artifact", "homebrew-tap", "application-template"):
raise ManifestError("Unsupported profile")
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
if profile in ("qbit", "core"):
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")
if profile == "qbit":
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", "marketing"):
allowed += ("publish_context", "platforms")
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")
@@ -86,10 +97,12 @@ 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):
raise ManifestError("orb_version must be an explicit stable or development version")
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
raise ManifestError("orb_version must be a quoted minor track, exact stable pin, or development version")
if version != setup_version:
raise ManifestError("Manifest orb_version must match the setup job orb_version")
default_branch = data.get("default_branch")
@@ -97,12 +110,38 @@ 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")
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",)
@@ -110,6 +149,8 @@ def load_manifest(path, setup_version):
publish_keys = ("release",)
if profile in ("qbit", "core"):
publish_keys += ("asciidoc",)
if profile == "qbit":
publish_keys += ("hotfix", "feature")
if profile not in ("qbit", "cli", "all", "app-starter", "voyage", "frontend-next"):
publish_keys += ("feature", "hotfix")
publishing = mapping(data.get("publish", {}), publish_keys, "publish")
@@ -122,21 +163,27 @@ def load_manifest(path, setup_version):
raise ManifestError("CLI publication requires an explicitly verified context")
if profile == "cli" and boolean(data, "docs_only", False):
raise ManifestError("CLI currently requires full generated-client verification")
platforms = data.get("platforms", [])
if not isinstance(platforms, list) or any(not isinstance(x, str) or x not in CLI_PLATFORMS for x in platforms) or len(platforms) != len(set(platforms)):
raise ManifestError("platforms must be distinct entries of " + ", ".join(CLI_PLATFORMS))
tag_policy = data.get("release_tag_policy", "stable")
if tag_policy not in ("stable", "v-prefix", "none"):
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"):
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"):
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),
"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"))
"publish_context": publish_context, "platforms": platforms,
"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}}
@@ -171,9 +218,28 @@ def proven_docs_only(config, branch, tag):
return base.decode().strip() if eligible else False
def proven_ci_maintenance(branch, tag):
"""Keep application tests, but do not publish for isolated CI declarations."""
if tag or not (branch == "main" or branch == "develop" or branch.startswith(("release/", "hotfix/"))):
return False
subject = git("log", "-1", "--format=%s")
if not subject or not re.match(rb"ci(?:\([^\r\n()]+\))?: ", subject):
return False
parents = git("rev-list", "--parents", "-n", "1", "HEAD")
if not parents or not re.fullmatch(rb"[0-9a-f]{40} [0-9a-f]{40}\n", parents):
return False
base = parents.split()[1].decode("ascii")
changed = git("diff", "--no-ext-diff", "--no-renames", "--name-only", "-z", base, "HEAD")
if not changed:
return False
allowed = {b".qqq-ci.yml", b".circleci/config.yml", b".github/workflows/codeql.yml",
b".github/workflows/release-rc.yml", b".github/workflows/schema-drift.yml"}
return all(path in allowed for path in changed.rstrip(b"\0").split(b"\0"))
def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
if tag:
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag):
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag, flags=re.ASCII):
return "test"
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
@@ -191,21 +257,36 @@ def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
def qbit_template(config, branch, tag):
"""Profile-owned template; add future profiles as reviewed renderers, not raw YAML."""
kind = event_kind(branch, tag, config.get("release_on_main", False), config.get("release_tag_policy", "stable"))
if tag.startswith("publish") and config["publish"].get("feature", False):
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if tagged and tagged == git("rev-parse", "HEAD"):
kind = "feature"
if not tag and re.fullmatch(r"hotfix/.+", branch) and config["publish"].get("hotfix", False):
kind = "hotfix"
if kind != "test" and not config["publish"][kind]:
kind = "test"
maintenance = proven_ci_maintenance(branch, tag)
if maintenance:
kind = "test"
workflow = "test_only" if kind == "test" else "publish_" + kind
result = {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]}}
filters = ({"branches": {"ignore": "/.*/"}, "tags": {"only": "/.*/"}} if tag else
{"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}})
if kind == "test" and not tag:
if kind == "test" and not tag and not maintenance:
ignores = {"all": None, "non-release": "/(develop|release/.*)/",
"non-release-no-integration": "/(develop|release/.*|integration.*)/",
"feature": "/(develop|main|release/.*|integration.*)/",
"non-release-no-main": "/(develop|main|release/.*)/"}
"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")]
if ignored:
filters["branches"]["ignore"] = ["automation/qbit-rc-pending", ignored]
docs_base = proven_docs_only(config, branch, tag) if kind == "test" else False
docs_base = proven_docs_only(config, branch, tag) if kind == "test" and not maintenance else False
if docs_base:
# Keep the existing workflow/result identity even when Maven is not needed.
result["jobs"] = {"docs_only": {"resource_class": "small", "docker": [{"image": "cimg/base:2026.03"}],
@@ -304,7 +385,10 @@ def frontend_template(config, branch, tag):
kind = "release"
if kind != "test" and not config["publish"][kind]:
kind = "test"
if kind == "test" and proven_docs_only(config, branch, tag):
maintenance = proven_ci_maintenance(branch, tag)
if maintenance:
kind = "test"
if kind == "test" and not maintenance and proven_docs_only(config, branch, tag):
result = qbit_template(config, branch, tag)
result["workflows"]["test_only"]["jobs"][0]["docs_only"]["name"] = (
"qqq-orb/mvn_frontend_test_only" if material else "qqq-orb/node_test_only")
@@ -359,15 +443,31 @@ def cli_template(config, branch, tag):
options = {"publish": publish, "filters": filters}
if publish:
options["context"] = [config["publish_context"]]
platforms = config.get("platforms", [])
jobs = [{"qqq-orb/cli_platform": {"name": "cli-" + p, "executor": CLI_PLATFORMS[p], "filters": copy.deepcopy(filters)}}
for p in platforms]
if publish and platforms:
# Every opted-in platform must pass before packages are published.
options["requires"] = ["cli-" + p for p in platforms]
jobs.append({"qqq-orb/cli_verify_publish": options})
# CLI docs are still verified until its generated-client inputs get a dedicated policy.
return {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]},
"workflows": {"publish_release" if publish else "test_only": {"jobs": [{"qqq-orb/cli_verify_publish": options}]}}}
"workflows": {"publish_release" if publish else "test_only": {"jobs": jobs}}}
def marketing_template(config, branch, tag):
del config, branch, tag
# One final continuation; Munitor supplies jobs, never another setup pipeline.
return copy.deepcopy(MARKETING_TEMPLATE)
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
def android_template(config, branch, tag):
@@ -403,15 +503,69 @@ def next_template(config, branch, tag):
def voyage_template(config, branch, tag):
del branch, tag # This profile's reviewed static filters own its three workflows.
return json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
del tag # Existing job filters retain tag exclusion and main-only release actions.
selected = "develop" if branch == "develop" else (
"release" if branch == "main" or branch.startswith("release/") else "pull-request")
result = json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
result["workflows"] = {"verify": result["workflows"][selected]}
return result
PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
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(APPLICATION_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}
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"):
@@ -441,6 +595,12 @@ def main():
if expected and (not re.fullmatch(r"[0-9a-fA-F]{40}", expected) or git("rev-parse", "HEAD") != (expected + "\n").encode()):
raise ManifestError("Checkout does not match the pipeline commit")
output = PROFILE_TEMPLATES[config["profile"]](config, os.environ.get("CIRCLE_BRANCH", ""), os.environ.get("CIRCLE_TAG", ""))
if config["profile"] in ("qbit", "core", "frontend-core", "frontend-material"):
# One whole-workflow check follows the same commit from feature to release.
# Keep every selected job, dependency and filter; add no runner or duplicate build.
if len(output["workflows"]) != 1:
raise ManifestError("Stable verification requires exactly one selected workflow")
output["workflows"] = {"verify": next(iter(output["workflows"].values()))}
parameters = continuation_parameters(config["profile"])
if config["profile"] == "core":
output["parameters"] = copy.deepcopy(CORE_TEMPLATE["parameters"])
+4
View File
@@ -17,12 +17,16 @@ def canonical(worker_sha):
"dry_run": {"description": "Plan a cut without changing release state", "type": "boolean", "default": False},
"finalize": {"description": "Retry finalization of an existing cut; do not cut another RC", "type": "boolean", "default": False},
}
inputs['recover'] = {'description': 'Recover the same published RC after a deployment timeout; never reupload', 'type': 'boolean', 'default': False}
inputs['circle_build'] = {'description': 'Original Circle publisher build number (recovery only)', 'type': 'string', 'default': ''}
for field in ("merge_sha", "bump_sha", "branch", "version"):
inputs[field] = {"description": "Existing cut " + field + " (finalize retry only)", "type": "string", "default": ""}
forwarded = {
"dry_run": "${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || false }}",
"finalize": "${{ github.event_name == 'repository_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.finalize) }}",
}
forwarded['recover'] = "${{ github.event_name == 'workflow_dispatch' && inputs.recover || false }}"
forwarded['circle_build'] = "${{ github.event_name == 'workflow_dispatch' && inputs.circle_build || '' }}"
for field in ("merge_sha", "bump_sha", "branch", "version"):
forwarded[field] = "${{ github.event_name == 'repository_dispatch' && github.event.client_payload." + field + " || inputs." + field + " || '' }}"
return {
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail
# Machine executors are Ubuntu amd64. Preserve an existing browser for Maven
# consumers; frontend_test deliberately removes its stale browser beforehand.
if command -v google-chrome >/dev/null 2>&1; then
google-chrome --version
exit 0
fi
architecture=$(dpkg --print-architecture)
if [[ "$architecture" != amd64 ]]; then
echo "Google Chrome requires an amd64 machine executor" >&2
exit 1
fi
curl --fail --silent --show-error --location https://dl.google.com/linux/linux_signing_key.pub \
| sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/qqq-google-chrome.gpg
printf '%s\n' 'deb [arch=amd64 signed-by=/usr/share/keyrings/qqq-google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main' \
| sudo tee /etc/apt/sources.list.d/qqq-google-chrome.list >/dev/null
# Ubuntu dependency indexes were refreshed by install_java. Only the newly added
# signed Google repository needs refreshing; image PPAs are unrelated to Chrome.
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update \
-o Dir::Etc::sourcelist=/etc/apt/sources.list.d/qqq-google-chrome.list \
-o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y google-chrome-stable
google-chrome --version
+26 -4
View File
@@ -20,13 +20,30 @@ sudo install -d /etc/needrestart/conf.d
# shellcheck disable=SC2016
printf '%s\n' '$nrconf{restart} = "l";' | sudo tee /etc/needrestart/conf.d/99-qqq-ci.conf >/dev/null
# Retry transient repository downloads within APT, including NodeSource's child process.
# Exhausted downloads retain APT's nonzero exit status and fail this build step.
printf '%s\n' 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-qqq-download-retries >/dev/null
# Ubuntu archive carries the same signed security suite; avoid the flaky HTTP mirror.
if [[ -f /etc/apt/sources.list ]]; then
sudo sed -i 's|http://security.ubuntu.com/ubuntu|https://archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list
fi
# Add Eclipse Temurin repository
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq
# Base tools come from Ubuntu, not the unrelated PPAs bundled in machine images.
# Support both the 22.04 list and the newer deb822 Ubuntu source file. Preserve
# other indexes for later jobs without contacting their repositories here.
ubuntu_sources=/etc/apt/sources.list
if [[ ! -s "$ubuntu_sources" ]]; then
ubuntu_sources=/etc/apt/sources.list.d/ubuntu.sources
fi
if [[ ! -s "$ubuntu_sources" ]]; then
echo 'Cannot locate Ubuntu package sources' >&2
exit 1
fi
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq \
-o "Dir::Etc::sourcelist=$ubuntu_sources" \
-o Dir::Etc::sourceparts=- \
-o APT::Get::List-Cleanup=0
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y -qq wget apt-transport-https gpg maven curl
# Add Temurin GPG key
@@ -35,8 +52,13 @@ wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo g
# Add repository
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
# Install Java
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq
# Refresh only the repository just added. Re-fetching unrelated image PPAs here
# caused otherwise successful setup to fail on Launchpad 503 responses. Keep
# Ubuntu indexes from the first refresh so Java dependencies remain resolvable.
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq \
-o Dir::Etc::sourcelist=/etc/apt/sources.list.d/adoptium.list \
-o Dir::Etc::sourceparts=- \
-o APT::Get::List-Cleanup=0
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y -qq "temurin-${JAVA_VERSION}-jdk"
# Set JAVA_HOME
+8
View File
@@ -22,6 +22,13 @@
set -e
# The shared publish job already ran these checks in its verify lifecycle.
# Standalone command callers retain analysis unless explicitly opted in.
analysis_args=()
if [[ "${QQQ_SKIP_VERIFIED_ANALYSIS:-false}" == "true" || "${QQQ_SKIP_VERIFIED_ANALYSIS:-false}" == "1" ]]; then
analysis_args=(-Dspotbugs.skip=true -Dpmd.skip=true)
fi
##############################################
## Deploy signed artifacts to Maven Central ##
##############################################
@@ -30,6 +37,7 @@ set -e
# Central 0.8.x: this completion flag overrides inherited literal waitUntil=uploaded.
# Do not report a release as successful until Central confirms publication.
mvn -s /tmp/circleci/mvn-settings.xml -P release -B -DskipTests \
"${analysis_args[@]}" \
-Dgpg.keyname="$GPG_KEYNAME" -Dgpg.passphrase="$GPG_PASSPHRASE" \
-DwaitForPublishCompletion=true \
-Dflatten.mode=resolveCiFriendliesOnly -DupdatePomFile=true \
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -eo pipefail
echo "Running PMD static analysis..."
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -eo pipefail
echo "Running SpotBugs static analysis..."
+1 -1
View File
@@ -64,7 +64,7 @@ echo "Publishing version: $VERSION"
if [[ "$VERSION" =~ -RC\.[0-9]+$ ]]; then
NPM_TAG="rc"
echo "Detected RC version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -SNAPSHOT$ ]]; then
elif [[ "$VERSION" =~ -SNAPSHOT(\.[1-9][0-9]*)?$ ]]; then
NPM_TAG="snapshot"
echo "Detected SNAPSHOT version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -(alpha|beta) ]]; then
+5 -5
View File
@@ -9,7 +9,7 @@
## It also pushes the changes back to the current branch.
##
## Process:
## 1. Skips for feature branches (ephemeral versions)
## 1. Skips for feature and snapshot builds (ephemeral versions)
## 2. Checks if package.json has been modified
## 3. Extracts the new version from package.json
## 4. Commits the changes with skip ci flag
@@ -22,12 +22,12 @@
set -e
################################################################
## Skip version commit for feature branches ##
## Feature versions are ephemeral and don't need to be ##
## Skip version commit for feature and snapshot builds ##
## These versions are ephemeral and don't need to be ##
## persisted back to the repository ##
################################################################
if [[ "$BRANCH_TYPE" == "feature" ]]; then
echo "Skipping version commit for feature branch (ephemeral versions)"
if [[ "$BRANCH_TYPE" == "feature" || "$BRANCH_TYPE" == "snapshot" ]]; then
echo "Skipping version commit for $BRANCH_TYPE build (ephemeral version)"
exit 0
fi
+185 -25
View File
@@ -16,15 +16,18 @@ import yaml
# Generated by scripts/pack_pipeline.py; edit source/resources, then regenerate.
import base64
import zlib
CORE_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtPdl22ziy7/0VuOrM2M6IpPclifvcxHbfeCar48z0nChXByJBiW1uJig7Oonn26cKACmKIiVSluUlTr/IJFAo1F6FAvv7L4Q0LljEncBvPCPr+loTn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aq4tSjdxv1bgld+M9Wbk+spcqOe8wHk41yrtpbhdRmWlwzXk7UMYmL93HeXn76+CZPOj/oAEPDQdyJHY8hb2G99RWvWVaVSixagb0ni94pXrLine truncated
MATERIAL_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNq1lMtugzAQRfd8heV1TNRKlar8QXdVt02EXDMhDthGfqRBiH/vQAmPvKRU6g7PjH3PXI+pI0IoHEEEb6yjK1JjAENlwatvK7OdH2IYTY3IwWLks4+QIdflpeIZYJoqYWMlhTXObH0sjFqOB64OT/HLa/zM9lypig77m/5rE51WzaKl25uvq2CJB+fdFO/UR0swaWBxyjsPpZvRU7EDkZswFp11ZFHDWEgEx8qJVp/OoZof2Md1qViKYqyuSSfhgiJrWnKRo0OsQB/jvTN6TUnTTLTPt9NZZjNZNaNvt9CDvgTWXHUX9Kad50VBUAV0ClpIcGccFK9NcZ225QhEhCSMFZBxUbESwHaE9CEkxw/3rOyV/uwcVvnd9fswKSTKpKEA92+efgRN3oexIwfpAi+IhQyHyEmjye/A3nP5SMa57cof9LebVW693HIxexsTg+avg1kojfXLc6wUxaXmHrmvbvgLWNtQgmaE4h5bW8X6quUNmctfRdREPykCLqM=")))
VOYAGE_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtW+tz2zYS/56/AqPJXJKeSUqqHzndqBNbdm1NGzsnObneVDkNREISLBKgAVCWYuv+9lvwpQepV2K1TpoPsUhggV38drEPgLl/hlBhSISknBUqqGyW9nTLDe9IeL2HZ3jrBNR1DMwcQxGp0nbo8bDdp4zMNEEj9XBPNxWCTsBUYJTLxf2KHQhBmCrEZJO9ZApBJA+ETdq2i6VmWnCxgPEpAWFDKjjz9Og5Pm+PP5xdtq/eXTf1KOM3bwSMXntZFlIRX8/8+3Ss3Sf2gAcqZYNmZob+29tbg4uORZlU2HXbN3iI57iHVLq1PUWvUC4VZggm6fNkyiWd2Ruytg3wkTYgoLggy0QRActyZtgLIf5ABO2OEfZ9l9pYgRx7iDJFeiJ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abCcM1uHcHhJZel6sRGJhx68w6SAykIB1nwu6qH/f+V/9p+KsYvQ8+jt9FUb/1cRwML5rDyafu/nuvacD+2Hc2nT/snNGl")))
ALL_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNq1T7EOgjAU3PmKpjNIdHQyJg4ukmDiYkwDUkxt4UkLEkP4dwsSUojootu7u/fu7lUWQvhOpWKQ4iVazOZ2w4AMlYaVnjXKsszRjCYwZ+lFSQDuduSKEM9fk8PG32+9HSFYn9StRwmSxwJKw0gHsfjhBGnkqAQ47RWtXaGNPHYY9YpZwQ2EIC8X47bbSYOkccRhwUTUhuRU5dhYqvu5rfglZ1xxFHMGSbE91G4SYiYmZUmzgkk6/LPTplsjdPrXD3EhxIcf3sk//sEy1QbVVm09Ad15mhY=")))
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("eNrtV21v2jAQ/s6vsKJ92KomdFSbptKhIoGqfugL0K6aRoWMY4LbxE5tp4BQ9tt3TgJJeGtXbVI17Vty57t77rmXOPMKQtYTlYoJbh2hmvNx30iEHCp4ncMzvGHuSsFcEFiESeJTwqqZ7KTmfHIOrP30oEdCm/isdDCTnRw6Nadmwbk4iXAvihEizrStqdJLEQjplJJIC1mQgZTjgJoAGYAFEDvAZMw4zaAkRzX2zEmXjnDkaytTxIsTltI0NCB+5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6PBrVHwu9HbZK1UAWXq04W0JdayHXBsG13CWV2KP3xDtqAyJwhcAwZrsOCQHNuRD+tgvaT+TCdTuKKbN3T20NMDh8vXCe/gn7rVJqvDMvCv+mxRsJ0QMjzbeNbNR3aNw4vtaOHz5OW1GDuXzd4O1tTM3z++4l7cdGxp6V/7hT0yV60oSkTTBGz3ReCAodqilZl+7TTz/Zp83uOLn95Mn3ybQ9y94r/1nnT3faZ+xI4LidpqJNtx5vEMcL/fMjsLHeSVLEAMMszFigQ9R2qZKD8d/QoALm5ENn0HAVrubD5YsTliVTsISzf09SHaH/j2tSs9HdvSevb/th5G/vnRhptMDqKb5zhH3Ud+6w4a76sYyoGEoIQWv7Nm/Hihfjq5rxwL715e74t/dn9s/8DqAZZ8g==")))
class ManifestError(ValueError):
@@ -61,6 +64,10 @@ def boolean(data, key, default):
return value
# Opt-in CLI platform lanes: manifest entry -> orb executor.
CLI_PLATFORMS = {"macos-arm64": "qqq-orb/cli_macos_arm64", "windows-x64": "qqq-orb/cli_windows_x64"}
def load_manifest(path, setup_version):
raw = Path(path).read_text(encoding="utf-8")
if len(raw) > 65536:
@@ -69,16 +76,20 @@ 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", "marketing"):
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing", "node-artifact", "homebrew-tap", "application-template"):
raise ManifestError("Unsupported profile")
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
if profile in ("qbit", "core"):
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")
if profile == "qbit":
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", "marketing"):
allowed += ("publish_context", "platforms")
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")
@@ -86,10 +97,12 @@ 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):
raise ManifestError("orb_version must be an explicit stable or development version")
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
raise ManifestError("orb_version must be a quoted minor track, exact stable pin, or development version")
if version != setup_version:
raise ManifestError("Manifest orb_version must match the setup job orb_version")
default_branch = data.get("default_branch")
@@ -97,12 +110,38 @@ 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")
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",)
@@ -110,6 +149,8 @@ def load_manifest(path, setup_version):
publish_keys = ("release",)
if profile in ("qbit", "core"):
publish_keys += ("asciidoc",)
if profile == "qbit":
publish_keys += ("hotfix", "feature")
if profile not in ("qbit", "cli", "all", "app-starter", "voyage", "frontend-next"):
publish_keys += ("feature", "hotfix")
publishing = mapping(data.get("publish", {}), publish_keys, "publish")
@@ -122,21 +163,27 @@ def load_manifest(path, setup_version):
raise ManifestError("CLI publication requires an explicitly verified context")
if profile == "cli" and boolean(data, "docs_only", False):
raise ManifestError("CLI currently requires full generated-client verification")
platforms = data.get("platforms", [])
if not isinstance(platforms, list) or any(not isinstance(x, str) or x not in CLI_PLATFORMS for x in platforms) or len(platforms) != len(set(platforms)):
raise ManifestError("platforms must be distinct entries of " + ", ".join(CLI_PLATFORMS))
tag_policy = data.get("release_tag_policy", "stable")
if tag_policy not in ("stable", "v-prefix", "none"):
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"):
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"):
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),
"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"))
"publish_context": publish_context, "platforms": platforms,
"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}}
@@ -171,9 +218,28 @@ def proven_docs_only(config, branch, tag):
return base.decode().strip() if eligible else False
def proven_ci_maintenance(branch, tag):
"""Keep application tests, but do not publish for isolated CI declarations."""
if tag or not (branch == "main" or branch == "develop" or branch.startswith(("release/", "hotfix/"))):
return False
subject = git("log", "-1", "--format=%s")
if not subject or not re.match(rb"ci(?:\([^\r\n()]+\))?: ", subject):
return False
parents = git("rev-list", "--parents", "-n", "1", "HEAD")
if not parents or not re.fullmatch(rb"[0-9a-f]{40} [0-9a-f]{40}\n", parents):
return False
base = parents.split()[1].decode("ascii")
changed = git("diff", "--no-ext-diff", "--no-renames", "--name-only", "-z", base, "HEAD")
if not changed:
return False
allowed = {b".qqq-ci.yml", b".circleci/config.yml", b".github/workflows/codeql.yml",
b".github/workflows/release-rc.yml", b".github/workflows/schema-drift.yml"}
return all(path in allowed for path in changed.rstrip(b"\0").split(b"\0"))
def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
if tag:
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag):
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag, flags=re.ASCII):
return "test"
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
@@ -191,21 +257,36 @@ def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
def qbit_template(config, branch, tag):
"""Profile-owned template; add future profiles as reviewed renderers, not raw YAML."""
kind = event_kind(branch, tag, config.get("release_on_main", False), config.get("release_tag_policy", "stable"))
if tag.startswith("publish") and config["publish"].get("feature", False):
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
if tagged and tagged == git("rev-parse", "HEAD"):
kind = "feature"
if not tag and re.fullmatch(r"hotfix/.+", branch) and config["publish"].get("hotfix", False):
kind = "hotfix"
if kind != "test" and not config["publish"][kind]:
kind = "test"
maintenance = proven_ci_maintenance(branch, tag)
if maintenance:
kind = "test"
workflow = "test_only" if kind == "test" else "publish_" + kind
result = {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]}}
filters = ({"branches": {"ignore": "/.*/"}, "tags": {"only": "/.*/"}} if tag else
{"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}})
if kind == "test" and not tag:
if kind == "test" and not tag and not maintenance:
ignores = {"all": None, "non-release": "/(develop|release/.*)/",
"non-release-no-integration": "/(develop|release/.*|integration.*)/",
"feature": "/(develop|main|release/.*|integration.*)/",
"non-release-no-main": "/(develop|main|release/.*)/"}
"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")]
if ignored:
filters["branches"]["ignore"] = ["automation/qbit-rc-pending", ignored]
docs_base = proven_docs_only(config, branch, tag) if kind == "test" else False
docs_base = proven_docs_only(config, branch, tag) if kind == "test" and not maintenance else False
if docs_base:
# Keep the existing workflow/result identity even when Maven is not needed.
result["jobs"] = {"docs_only": {"resource_class": "small", "docker": [{"image": "cimg/base:2026.03"}],
@@ -304,7 +385,10 @@ def frontend_template(config, branch, tag):
kind = "release"
if kind != "test" and not config["publish"][kind]:
kind = "test"
if kind == "test" and proven_docs_only(config, branch, tag):
maintenance = proven_ci_maintenance(branch, tag)
if maintenance:
kind = "test"
if kind == "test" and not maintenance and proven_docs_only(config, branch, tag):
result = qbit_template(config, branch, tag)
result["workflows"]["test_only"]["jobs"][0]["docs_only"]["name"] = (
"qqq-orb/mvn_frontend_test_only" if material else "qqq-orb/node_test_only")
@@ -359,15 +443,31 @@ def cli_template(config, branch, tag):
options = {"publish": publish, "filters": filters}
if publish:
options["context"] = [config["publish_context"]]
platforms = config.get("platforms", [])
jobs = [{"qqq-orb/cli_platform": {"name": "cli-" + p, "executor": CLI_PLATFORMS[p], "filters": copy.deepcopy(filters)}}
for p in platforms]
if publish and platforms:
# Every opted-in platform must pass before packages are published.
options["requires"] = ["cli-" + p for p in platforms]
jobs.append({"qqq-orb/cli_verify_publish": options})
# CLI docs are still verified until its generated-client inputs get a dedicated policy.
return {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]},
"workflows": {"publish_release" if publish else "test_only": {"jobs": [{"qqq-orb/cli_verify_publish": options}]}}}
"workflows": {"publish_release" if publish else "test_only": {"jobs": jobs}}}
def marketing_template(config, branch, tag):
del config, branch, tag
# One final continuation; Munitor supplies jobs, never another setup pipeline.
return copy.deepcopy(MARKETING_TEMPLATE)
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
def android_template(config, branch, tag):
@@ -403,15 +503,69 @@ def next_template(config, branch, tag):
def voyage_template(config, branch, tag):
del branch, tag # This profile's reviewed static filters own its three workflows.
return json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
del tag # Existing job filters retain tag exclusion and main-only release actions.
selected = "develop" if branch == "develop" else (
"release" if branch == "main" or branch.startswith("release/") else "pull-request")
result = json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
result["workflows"] = {"verify": result["workflows"][selected]}
return result
PROFILE_TEMPLATES = {"qbit": qbit_template, "core": core_template,
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(APPLICATION_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}
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"):
@@ -441,6 +595,12 @@ def main():
if expected and (not re.fullmatch(r"[0-9a-fA-F]{40}", expected) or git("rev-parse", "HEAD") != (expected + "\n").encode()):
raise ManifestError("Checkout does not match the pipeline commit")
output = PROFILE_TEMPLATES[config["profile"]](config, os.environ.get("CIRCLE_BRANCH", ""), os.environ.get("CIRCLE_TAG", ""))
if config["profile"] in ("qbit", "core", "frontend-core", "frontend-material"):
# One whole-workflow check follows the same commit from feature to release.
# Keep every selected job, dependency and filter; add no runner or duplicate build.
if len(output["workflows"]) != 1:
raise ManifestError("Stable verification requires exactly one selected workflow")
output["workflows"] = {"verify": next(iter(output["workflows"].values()))}
parameters = continuation_parameters(config["profile"])
if config["profile"] == "core":
output["parameters"] = copy.deepcopy(CORE_TEMPLATE["parameters"])
+1 -1
View File
@@ -116,7 +116,7 @@ def reconcile(api, repo):
validate_run(run, intent, repo, merge, run_id)
checks = api.request(prefix + 'commits/' + merge + '/check-runs?filter=latest&per_page=100')
publishers = [c for c in checks.get('check_runs', [])
if c.get('name') == 'publish_release_candidate' and c.get('app', {}).get('id') == 18001]
if c.get('name') in ('publish_release_candidate', 'verify') and c.get('app', {}).get('id') == 18001]
if not publishers:
return 'publisher-running'
publisher = max(publishers, key=lambda c: c['id'])
+7 -3
View File
@@ -28,13 +28,17 @@ if [[ "$CURRENT_BRANCH" == "main" ]]; then
TARGET_VERSION="$MAJOR_MINOR.0"
echo "Main branch detected - targeting release version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == "develop" ]]; then
# Develop branch - should be a snapshot version (e.g., 1.0.127-SNAPSHOT)
# Increment patch version for develop
# Snapshot coordinates are unique per CI job without pushing a version commit.
# The source head stays the head whose required checks are being reported.
if [[ ! "${CIRCLE_BUILD_NUM:-}" =~ ^[1-9][0-9]*$ ]]; then
echo "ERROR: Snapshot publication requires a positive CIRCLE_BUILD_NUM" >&2
exit 1
fi
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
PATCH="${MAJOR_MINOR_PATCH##*.}"
NEW_PATCH=$((PATCH + 1))
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT"
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT.$CIRCLE_BUILD_NUM"
echo "Develop branch detected - targeting snapshot version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == release/* ]]; then
# Release branch - should be a release candidate (e.g., 1.0.0-RC.1, 1.0.0-RC.2, etc.)
+6 -9
View File
@@ -86,14 +86,8 @@
"android/restore-gradle-cache",
{
"run": {
"name": "Write credentials to gradle.properties",
"command": "echo \"\" >> gradle.properties\necho \"githubQqqMavenRegistryUsername=${QQQ_ANDROID_MAVEN_REGISTRY_USERNAME}\" >> gradle.properties\necho \"githubQqqMavenRegistryPassword=${QQQ_ANDROID_MAVEN_REGISTRY_PASSWORD}\" >> gradle.properties\n"
}
},
{
"run": {
"name": "Publish (Deploy) to Maven",
"command": "./gradlew publishMavenPublicationToGithubQqqMavenRegistryRepository\n"
"name": "Publish with shared Maven credentials",
"command": "set -euo pipefail\n: \"${GITHUB_TOKEN:?GitHub Packages write credential is required}\"\n# Authenticate before compiling; repository access is necessary, not proof of package write access.\nregistry_user=$(python3 \\<<'PYTHON'\nimport json\nimport os\nimport urllib.request\n\nclass NoRedirect(urllib.request.HTTPRedirectHandler):\n def redirect_request(self, req, fp, code, msg, headers, newurl):\n raise RuntimeError(\"GitHub authentication redirect refused\")\n\ntry:\n opener = urllib.request.build_opener(NoRedirect)\n def get(path):\n request = urllib.request.Request(\"https://api.github.com/\" + path,\n headers={\"Authorization\": \"Bearer \" + os.environ[\"GITHUB_TOKEN\"],\n \"Accept\": \"application/vnd.github+json\"})\n with opener.open(request, timeout=30) as response:\n return json.load(response)\n user = get(\"user\").get(\"login\")\n if not isinstance(user, str) or not user or not get(\"repos/QRun-IO/qqq-maven-registry\").get(\"permissions\", {}).get(\"push\"):\n raise ValueError(\"Missing registry access\")\n print(user)\nexcept Exception:\n raise SystemExit(\"GitHub Packages credential cannot access the Maven registry\") from None\nPYTHON\n)\nexport ORG_GRADLE_PROJECT_githubQqqMavenRegistryUsername=\"$registry_user\"\nexport ORG_GRADLE_PROJECT_githubQqqMavenRegistryPassword=\"$GITHUB_TOKEN\"\n./gradlew --console=plain publishMavenPublicationToGithubQqqMavenRegistryRepository\n"
}
}
]
@@ -116,7 +110,10 @@
"branches": {
"only": "main"
}
}
},
"context": [
"qqq-maven-registry-credentials"
]
}
}
]
@@ -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"
]
}
}
}
+81 -18
View File
@@ -198,20 +198,10 @@
"caller": {
"name": "Database migrations",
"on": {
"pull_request": {
"paths": [
"db/**",
"pom.xml",
".github/workflows/db-migrations.yml"
]
},
"pull_request": {},
"push": {
"branches": [
"main"
],
"paths": [
"db/**",
"pom.xml"
]
}
},
@@ -222,6 +212,10 @@
"validate": {
"uses": "QRun-IO/qqq-orb/.github/workflows/business-db.yml@WORKER_SHA"
}
},
"concurrency": {
"group": "business-db-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}",
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
}
}
},
@@ -262,11 +256,6 @@
"main"
]
},
"schedule": [
{
"cron": "17 6 * * *"
}
],
"workflow_dispatch": null
},
"permissions": {
@@ -274,7 +263,7 @@
},
"concurrency": {
"group": "e2e-${{ github.ref }}",
"cancel-in-progress": true
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
},
"jobs": {
"validate": {
@@ -318,7 +307,7 @@
"smoke_evidence": {
"description": "Evidence provider; github preserves the original Smoke workflow validation",
"type": "choice",
"default": "github",
"default": "circle",
"options": [
"github",
"circle"
@@ -407,5 +396,79 @@
}
}
}
},
"gitops": {
"repository": "QRun-IO/marketing-website-cd",
"path": ".github/workflows/validate.yml",
"caller": {
"name": "GitOps validation",
"on": {
"push": {
"branches": [
"main"
]
},
"pull_request": {
"branches": [
"main"
]
}
},
"permissions": {
"contents": "read"
},
"concurrency": {
"group": "gitops-${{ github.ref }}",
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
},
"jobs": {
"gitops": {
"uses": "QRun-IO/qqq-orb/.github/workflows/gitops.yml@WORKER_SHA"
}
}
},
"additional_repositories": [
"QRun-IO/voyage-cd"
]
},
"qbit-codeql": {
"repository": null,
"profile": "qbit",
"path": ".github/workflows/codeql.yml",
"caller": {
"name": "CodeQL",
"on": {
"push": {
"branches": [
"main",
"develop",
"release/**",
"hotfix/**"
]
},
"pull_request": {},
"schedule": [
{
"cron": "41 16 * * 0"
}
],
"workflow_dispatch": {}
},
"permissions": {
"contents": "read",
"actions": "read",
"security-events": "write",
"packages": "read"
},
"concurrency": {
"group": "codeql-${{ github.event.pull_request.number || github.ref }}",
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
},
"jobs": {
"analyze": {
"uses": "QRun-IO/qqq-orb/.github/workflows/qbit-codeql.yml@WORKER_SHA"
}
}
}
}
}
+6 -4
View File
@@ -238,7 +238,7 @@
{
"run": {
"name": "Build framework dependencies for the sample",
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-acceptance -DskipTests clean install"
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-acceptance -DskipTests -Dspotbugs.skip=true -Dpmd.skip=true clean install"
}
},
{
@@ -308,7 +308,7 @@
{
"run": {
"name": "Build framework dependencies for the sample",
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-multinode -DskipTests clean install"
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-multinode -DskipTests -Dspotbugs.skip=true -Dpmd.skip=true clean install"
}
},
{
@@ -336,7 +336,7 @@
{
"run": {
"name": "Build framework dependencies for the consumers",
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-acceptance -DskipTests clean install"
"command": "mvn -B -s /tmp/circleci/mvn-settings.xml -Drevision=0.0.0-sample-acceptance -DskipTests -Dspotbugs.skip=true -Dpmd.skip=true clean install"
}
},
{
@@ -649,7 +649,9 @@
"qqq-orb/mvn_publish": {
"requires": [
"sample_bootstrap_source",
"snapshot_esb_broker_conformance"
"snapshot_esb_broker_conformance",
"snapshot_sample_coverage_gate",
"qqq-orb/static_analysis"
],
"pre-steps": [
"configure-package-install"
+36
View File
@@ -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"
]
}
}
}
+80 -94
View File
@@ -11,7 +11,7 @@
"name": "build-and-test",
"node_version": "22",
"package_manager": "npm",
"test_commands": "[\"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"npm run lighthouse\"]",
"test_commands": "[\"#!/usr/bin/env bash\\nprintf '%s\\\\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml\", \"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"#!/usr/bin/env bash\\nset -euo pipefail\\nnpm run start > /tmp/qqq-link-server.log 2>&1 &\\nserver_pid=$!\\ntrap 'kill \\\"$server_pid\\\" 2>/dev/null || true; wait \\\"$server_pid\\\" 2>/dev/null || true' EXIT\\nready=false\\nfor _attempt in {1..60}; do\\n if ! kill -0 \\\"$server_pid\\\" 2>/dev/null; then\\n cat /tmp/qqq-link-server.log\\n exit 1\\n fi\\n if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then\\n ready=true\\n break\\n fi\\n sleep 1\\ndone\\nif [ \\\"$ready\\\" != true ]; then\\n cat /tmp/qqq-link-server.log\\n echo 'Marketing server did not become ready on port 3005' >&2\\n exit 1\\nfi\\nnpm run check-links\", \"npm run lighthouse\"]",
"context": [
"github"
],
@@ -22,7 +22,21 @@
"/hotfix\\/.*/"
]
}
}
},
"post-steps": [
{
"store_artifacts": {
"path": "playwright-report",
"destination": "playwright-report"
}
},
{
"store_artifacts": {
"path": ".lighthouseci",
"destination": "lighthouse-report"
}
}
]
}
},
{
@@ -88,28 +102,6 @@
}
}
},
{
"munitor/node_coverage": {
"name": "coverage",
"node_version": "22",
"package_manager": "npm",
"min_coverage": "0",
"coverage_tool": "jest",
"coverage_summary_path": "coverage/coverage-summary.json",
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": [
"/feature\\/.*/",
"/hotfix\\/.*/"
]
}
}
}
},
{
"munitor/node_security_scan": {
"name": "security-scan",
@@ -137,7 +129,7 @@
"name": "build-and-test",
"node_version": "22",
"package_manager": "npm",
"test_commands": "[\"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"npm run lighthouse\"]",
"test_commands": "[\"#!/usr/bin/env bash\\nprintf '%s\\\\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml\", \"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"#!/usr/bin/env bash\\nset -euo pipefail\\nnpm run start > /tmp/qqq-link-server.log 2>&1 &\\nserver_pid=$!\\ntrap 'kill \\\"$server_pid\\\" 2>/dev/null || true; wait \\\"$server_pid\\\" 2>/dev/null || true' EXIT\\nready=false\\nfor _attempt in {1..60}; do\\n if ! kill -0 \\\"$server_pid\\\" 2>/dev/null; then\\n cat /tmp/qqq-link-server.log\\n exit 1\\n fi\\n if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then\\n ready=true\\n break\\n fi\\n sleep 1\\ndone\\nif [ \\\"$ready\\\" != true ]; then\\n cat /tmp/qqq-link-server.log\\n echo 'Marketing server did not become ready on port 3005' >&2\\n exit 1\\nfi\\nnpm run check-links\", \"npm run lighthouse\"]",
"context": [
"github"
],
@@ -145,7 +137,21 @@
"branches": {
"only": "develop"
}
}
},
"post-steps": [
{
"store_artifacts": {
"path": "playwright-report",
"destination": "playwright-report"
}
},
{
"store_artifacts": {
"path": ".lighthouseci",
"destination": "lighthouse-report"
}
}
]
}
},
{
@@ -184,25 +190,6 @@
}
}
},
{
"munitor/node_coverage": {
"name": "coverage",
"node_version": "22",
"package_manager": "npm",
"min_coverage": "0",
"coverage_tool": "jest",
"coverage_summary_path": "coverage/coverage-summary.json",
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": "develop"
}
}
}
},
{
"munitor/node_security_scan": {
"name": "security-scan",
@@ -228,7 +215,6 @@
"health_db": "false",
"requires": [
"code-quality",
"coverage",
"secrets-scan",
"sast-scan",
"security-scan"
@@ -252,7 +238,7 @@
"name": "build-and-test",
"node_version": "22",
"package_manager": "npm",
"test_commands": "[\"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"npm run lighthouse\"]",
"test_commands": "[\"#!/usr/bin/env bash\\nprintf '%s\\\\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml\", \"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"#!/usr/bin/env bash\\nset -euo pipefail\\nnpm run start > /tmp/qqq-link-server.log 2>&1 &\\nserver_pid=$!\\ntrap 'kill \\\"$server_pid\\\" 2>/dev/null || true; wait \\\"$server_pid\\\" 2>/dev/null || true' EXIT\\nready=false\\nfor _attempt in {1..60}; do\\n if ! kill -0 \\\"$server_pid\\\" 2>/dev/null; then\\n cat /tmp/qqq-link-server.log\\n exit 1\\n fi\\n if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then\\n ready=true\\n break\\n fi\\n sleep 1\\ndone\\nif [ \\\"$ready\\\" != true ]; then\\n cat /tmp/qqq-link-server.log\\n echo 'Marketing server did not become ready on port 3005' >&2\\n exit 1\\nfi\\nnpm run check-links\", \"npm run lighthouse\"]",
"context": [
"github"
],
@@ -260,7 +246,21 @@
"branches": {
"only": "staging"
}
}
},
"post-steps": [
{
"store_artifacts": {
"path": "playwright-report",
"destination": "playwright-report"
}
},
{
"store_artifacts": {
"path": ".lighthouseci",
"destination": "lighthouse-report"
}
}
]
}
},
{
@@ -299,25 +299,6 @@
}
}
},
{
"munitor/node_coverage": {
"name": "coverage",
"node_version": "22",
"package_manager": "npm",
"min_coverage": "0",
"coverage_tool": "jest",
"coverage_summary_path": "coverage/coverage-summary.json",
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": "staging"
}
}
}
},
{
"munitor/node_security_scan": {
"name": "security-scan",
@@ -343,7 +324,6 @@
"health_db": "false",
"requires": [
"code-quality",
"coverage",
"secrets-scan",
"sast-scan",
"security-scan"
@@ -367,7 +347,7 @@
"name": "build-and-test",
"node_version": "22",
"package_manager": "npm",
"test_commands": "[\"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"npm run lighthouse\"]",
"test_commands": "[\"#!/usr/bin/env bash\\nprintf '%s\\\\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml\", \"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"#!/usr/bin/env bash\\nset -euo pipefail\\nnpm run start > /tmp/qqq-link-server.log 2>&1 &\\nserver_pid=$!\\ntrap 'kill \\\"$server_pid\\\" 2>/dev/null || true; wait \\\"$server_pid\\\" 2>/dev/null || true' EXIT\\nready=false\\nfor _attempt in {1..60}; do\\n if ! kill -0 \\\"$server_pid\\\" 2>/dev/null; then\\n cat /tmp/qqq-link-server.log\\n exit 1\\n fi\\n if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then\\n ready=true\\n break\\n fi\\n sleep 1\\ndone\\nif [ \\\"$ready\\\" != true ]; then\\n cat /tmp/qqq-link-server.log\\n echo 'Marketing server did not become ready on port 3005' >&2\\n exit 1\\nfi\\nnpm run check-links\", \"npm run lighthouse\"]",
"context": [
"github"
],
@@ -377,7 +357,21 @@
"/release\\/.*/"
]
}
}
},
"post-steps": [
{
"store_artifacts": {
"path": "playwright-report",
"destination": "playwright-report"
}
},
{
"store_artifacts": {
"path": ".lighthouseci",
"destination": "lighthouse-report"
}
}
]
}
},
{
@@ -422,27 +416,6 @@
}
}
},
{
"munitor/node_coverage": {
"name": "coverage",
"node_version": "22",
"package_manager": "npm",
"min_coverage": "0",
"coverage_tool": "jest",
"coverage_summary_path": "coverage/coverage-summary.json",
"coverage_command": "mkdir -p coverage && echo '{\"total\":{\"lines\":{\"pct\":100}}}' > coverage/coverage-summary.json",
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": [
"/release\\/.*/"
]
}
}
}
},
{
"munitor/node_security_scan": {
"name": "security-scan",
@@ -470,7 +443,6 @@
"health_db": "false",
"requires": [
"code-quality",
"coverage",
"secrets-scan",
"sast-scan",
"security-scan"
@@ -514,7 +486,7 @@
"name": "build-and-test",
"node_version": "22",
"package_manager": "npm",
"test_commands": "[\"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"npm run lighthouse\"]",
"test_commands": "[\"#!/usr/bin/env bash\\nprintf '%s\\\\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml\", \"npm run lint\", \"npm run build\", \"npx playwright install chromium --with-deps\", \"npm run test:chromium\", \"#!/usr/bin/env bash\\nset -euo pipefail\\nnpm run start > /tmp/qqq-link-server.log 2>&1 &\\nserver_pid=$!\\ntrap 'kill \\\"$server_pid\\\" 2>/dev/null || true; wait \\\"$server_pid\\\" 2>/dev/null || true' EXIT\\nready=false\\nfor _attempt in {1..60}; do\\n if ! kill -0 \\\"$server_pid\\\" 2>/dev/null; then\\n cat /tmp/qqq-link-server.log\\n exit 1\\n fi\\n if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then\\n ready=true\\n break\\n fi\\n sleep 1\\ndone\\nif [ \\\"$ready\\\" != true ]; then\\n cat /tmp/qqq-link-server.log\\n echo 'Marketing server did not become ready on port 3005' >&2\\n exit 1\\nfi\\nnpm run check-links\", \"npm run lighthouse\"]",
"context": [
"github"
],
@@ -522,7 +494,21 @@
"branches": {
"only": "main"
}
}
},
"post-steps": [
{
"store_artifacts": {
"path": "playwright-report",
"destination": "playwright-report"
}
},
{
"store_artifacts": {
"path": ".lighthouseci",
"destination": "lighthouse-report"
}
}
]
}
},
{
@@ -0,0 +1,35 @@
{
"version": 2.1,
"jobs": {
"validate-policy": {
"docker": [
{
"image": "cimg/python:3.12"
}
],
"resource_class": "small",
"steps": [
"checkout",
{
"run": {
"name": "Install the YAML parser",
"command": "python3 -m pip install --disable-pip-version-check PyYAML==6.0.3"
}
},
{
"run": {
"name": "Validate the application-free branch",
"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"
}
}
]
}
},
"workflows": {
"verify": {
"jobs": [
"validate-policy"
]
}
}
}
+39 -92
View File
@@ -46,6 +46,24 @@
"destination": "quality-and-coverage"
}
},
{
"store_artifacts": {
"path": "target/checkstyle-result.xml",
"destination": "quality-and-coverage/checkstyle-result.xml"
}
},
{
"store_artifacts": {
"path": "target/spotbugsXml.xml",
"destination": "quality-and-coverage/spotbugsXml.xml"
}
},
{
"store_artifacts": {
"path": "target/pmd.xml",
"destination": "quality-and-coverage/pmd.xml"
}
},
{
"persist_to_workspace": {
"root": ".",
@@ -59,8 +77,7 @@
"Dockerfile",
"pom.xml",
"src",
".config",
"sonar-project.properties"
".config"
]
}
}
@@ -159,32 +176,6 @@
}
]
},
"sonar-scan": {
"machine": {
"image": "ubuntu-2204:current"
},
"resource_class": "medium",
"steps": [
"checkout",
{
"attach_workspace": {
"at": "."
}
},
{
"qqq-orb/install_java": {
"java_version": "21"
}
},
"qqq-orb/mvn_cache_restore",
{
"run": {
"name": "SonarCloud Analysis",
"command": "mvn -B sonar:sonar \\\n -Dsonar.projectKey=qrun-io_voyage \\\n -Dsonar.organization=qrun-io \\\n -Dsonar.host.url=https://sonarcloud.io \\\n -Dsonar.token=${SONAR_TOKEN} \\\n -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \\\n -Dsonar.scm.disabled=true\n"
}
}
]
},
"docker-build": {
"machine": {
"image": "ubuntu-2204:current"
@@ -241,27 +232,6 @@
}
]
},
"update-cd-repo": {
"docker": [
{
"image": "cimg/base:current"
}
],
"resource_class": "small",
"steps": [
{
"setup_remote_docker": {
"version": "default"
}
},
{
"run": {
"name": "Update CD repo with new image digest",
"command": "echo \"${GHCR_TOKEN}\" | docker login ghcr.io -u \"${GHCR_USERNAME}\" --password-stdin\n\nIMAGE_DIGEST=$(docker manifest inspect ghcr.io/qrun-io/voyage:${CIRCLE_SHA1:0:7} --verbose 2>/dev/null | jq -r '.Descriptor.digest // empty' || true)\n\nif [ -z \"${IMAGE_DIGEST}\" ]; then\n docker pull ghcr.io/qrun-io/voyage:${CIRCLE_SHA1:0:7}\n IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/qrun-io/voyage:${CIRCLE_SHA1:0:7} | cut -d@ -f2)\nfi\n\necho \"Image digest: ${IMAGE_DIGEST}\"\n\nif [ -z \"${IMAGE_DIGEST}\" ]; then\n echo \"ERROR: Could not determine image digest\"\n exit 1\nfi\n\ngit clone --branch main https://${GITHUB_TOKEN}@github.com/QRun-IO/Voyage-CD-Pipeline.git\ncd Voyage-CD-Pipeline\n\nsed -i \"s|digest: sha256:.*|digest: ${IMAGE_DIGEST}|\" overlays/production/kustomization.yaml\n\nif git diff --quiet overlays/production/kustomization.yaml; then\n echo \"No changes to commit - digest already up to date\"\n exit 0\nfi\n\ngit config user.name \"CircleCI\"\ngit config user.email \"ci@qrun.io\"\ngit add overlays/production/kustomization.yaml\ngit commit -m \"chore(production): update voyage image to ${CIRCLE_SHA1:0:7}\"\ngit push origin main\n\necho \"Successfully updated CD repo with new image digest\"\n"
}
}
]
},
"release-please": {
"docker": [
{
@@ -274,7 +244,7 @@
{
"run": {
"name": "Run release-please",
"command": "npx release-please github-release \\\n --token=${GITHUB_TOKEN} \\\n --repo-url=QRun-IO/voyage \\\n --release-type=maven \\\n --package-name=voyage\nnpx release-please release-pr \\\n --token=${GITHUB_TOKEN} \\\n --repo-url=QRun-IO/voyage \\\n --release-type=maven \\\n --package-name=voyage\n"
"command": "set -euo pipefail\nnpx release-please github-release \\\n --token=${GITHUB_TOKEN} \\\n --target-branch=main \\\n --repo-url=QRun-IO/voyage \\\n --release-type=maven \\\n --package-name=voyage\nnpx release-please release-pr \\\n --token=${GITHUB_TOKEN} \\\n --target-branch=main \\\n --repo-url=QRun-IO/voyage \\\n --release-type=maven \\\n --package-name=voyage\n"
}
}
]
@@ -290,7 +260,6 @@
"ignore": [
"main",
"develop",
"/^release-please--.*/",
"/^release\\/.*/"
]
}
@@ -304,7 +273,6 @@
"ignore": [
"main",
"develop",
"/^release-please--.*/",
"/^release\\/.*/"
]
}
@@ -318,7 +286,6 @@
"ignore": [
"main",
"develop",
"/^release-please--.*/",
"/^release\\/.*/"
]
}
@@ -335,7 +302,6 @@
"ignore": [
"main",
"develop",
"/^release-please--.*/",
"/^release\\/.*/"
]
}
@@ -385,21 +351,6 @@
}
}
},
{
"sonar-scan": {
"context": [
"sonarcloud"
],
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": "develop"
}
}
}
},
{
"sbom": {
"context": [
@@ -488,24 +439,6 @@
}
}
},
{
"sonar-scan": {
"context": [
"sonarcloud"
],
"requires": [
"build-and-test"
],
"filters": {
"branches": {
"only": [
"main",
"/^release\\/.*/"
]
}
}
}
},
{
"sbom": {
"context": [
@@ -546,10 +479,9 @@
}
},
{
"update-cd-repo": {
"munitor/update_cd_repo": {
"context": [
"github",
"ghcr"
"github"
],
"requires": [
"docker-build"
@@ -558,7 +490,21 @@
"branches": {
"only": "main"
}
}
},
"name": "update-cd-repo",
"cd_repo": "KofTwentyTwo/cluster-gitops",
"environment": "prod",
"cd_format": "kustomize",
"cd_image_name": "ghcr.io/qrun-io/voyage",
"cd_path": "tenants/voyage/kustomization.yaml",
"pre-steps": [
{
"run": {
"name": "Use the image published for this commit",
"command": "set -euo pipefail\n[[ \"$CIRCLE_SHA1\" =~ ^[0-9a-f]{40}$ ]]\nprintf \"export PROJECT_VERSION='%s'\\n\" \"${CIRCLE_SHA1:0:7}\" >> \"$BASH_ENV\"\n"
}
}
]
}
},
{
@@ -580,6 +526,7 @@
}
},
"orbs": {
"qqq-orb": "kingsrook/qqq-orb@__ORB_VERSION__"
"qqq-orb": "kingsrook/qqq-orb@__ORB_VERSION__",
"munitor": "kof22/munitor@0.3.11"
}
}
+17 -5
View File
@@ -45,7 +45,11 @@ PROFILE_PARAMETERS = {
"app-starter": {},
"android": {},
"mcp-policy": {},
"repository-policy": {},
"marketing": {},
"node-artifact": {},
"homebrew-tap": {},
"application-template": {},
}
@@ -58,13 +62,15 @@ def load_yaml(raw):
raise StandardError("Invalid YAML declaration") from error
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None):
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None, publish_feature=False):
if not isinstance(profile, str) or profile not in PROFILE_PARAMETERS:
raise StandardError("Unsupported CI profile")
options = {
"orb_version": version,
"filters": {"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"only": "/.*/"}},
}
if profile in ("node-artifact", "homebrew-tap", "application-template"):
options["filters"]["tags"] = {"ignore": "/.*/"}
if profile == "frontend-next":
options["filters"]["branches"] = {"ignore": "/.*/"}
if profile == "qbit" and release_tag_policy is not None:
@@ -72,6 +78,9 @@ def canonical_caller(profile, version, explicit_manifest=False, release_tag_poli
if release_tag_policy not in tag_filters:
raise StandardError("Unsupported QBit release tag policy")
options["filters"]["tags"] = tag_filters[release_tag_policy]
if publish_feature:
options["filters"]["tags"] = {"only": ([tag_filters[release_tag_policy]["only"]]
if release_tag_policy != "none" else []) + ["/publish.*/"]}
if explicit_manifest:
options["manifest"] = ".qqq-ci.yml"
parameters = PROFILE_PARAMETERS[profile]
@@ -105,12 +114,15 @@ def validate(config_raw, manifest_raw, setup_version):
if not isinstance(manifest, dict):
raise StandardError("Manifest must be a mapping")
version = manifest.get("orb_version")
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+\.\d+|dev:[A-Za-z0-9_-]+)", version):
raise StandardError("Manifest must pin an explicit orb version")
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
raise StandardError("Manifest must select a quoted minor track, exact stable pin, or development version")
if version != setup_version:
raise StandardError("Manifest and running setup orb versions differ")
expected = canonical_caller(manifest.get("profile"), version, release_tag_policy=manifest.get("release_tag_policy"))
explicit = canonical_caller(manifest.get("profile"), version, explicit_manifest=True, release_tag_policy=manifest.get("release_tag_policy"))
publishing = manifest.get("publish", {})
if not isinstance(publishing, dict) or type(publishing.get("feature", False)) is not bool:
raise StandardError("Feature publication must be an explicit boolean")
expected = canonical_caller(manifest.get("profile"), version, release_tag_policy=manifest.get("release_tag_policy"), publish_feature=publishing.get("feature", False))
explicit = canonical_caller(manifest.get("profile"), version, explicit_manifest=True, release_tag_policy=manifest.get("release_tag_policy"), publish_feature=publishing.get("feature", False))
if not exact(config, expected) and not exact(config, explicit):
raise StandardError("Consumer config must be the canonical setup caller with only its profile's declared and forwarded parameters")
+5 -2
View File
@@ -86,9 +86,12 @@ class NoRedirect(urllib.request.HTTPRedirectHandler):
def circle(path):
token = os.environ.get('CIRCLECI_TOKEN')
require(token, 'CIRCLECI_TOKEN is required for Circle evidence mode')
# Public projects expose these records without authentication.
headers = {'Accept': 'application/json'}
if token:
headers['Circle-Token'] = token
request = urllib.request.Request('https://circleci.com/api/v2/' + path,
headers={'Circle-Token': token, 'Accept': 'application/json'})
headers=headers)
with urllib.request.build_opener(NoRedirect).open(request, timeout=30) as response:
raw = response.read(2_000_001)
require(len(raw) <= 2_000_000, 'Evidence response exceeds bound')
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
npm run start > /tmp/qqq-link-server.log 2>&1 &
server_pid=$!
trap 'kill "$server_pid" 2>/dev/null || true; wait "$server_pid" 2>/dev/null || true' EXIT
ready=false
for _attempt in {1..60}; do
if ! kill -0 "$server_pid" 2>/dev/null; then
cat /tmp/qqq-link-server.log
exit 1
fi
if curl --fail --silent --output /dev/null --max-time 2 http://localhost:3005/; then
ready=true
break
fi
sleep 1
done
if [ "$ready" != true ]; then
cat /tmp/qqq-link-server.log
echo 'Marketing server did not become ready on port 3005' >&2
exit 1
fi
npm run check-links
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
printf '%s\n' 'pipeline: node-webapp' 'node_version: 22' 'docker:' ' use_repo_dockerfile: true' > .munitor.yml
+90
View File
@@ -0,0 +1,90 @@
version: 2.1
orbs:
qqq-orb: kingsrook/qqq-orb@0.6.8
commands:
configure-package-install:
steps:
- run:
name: Keep package installation unattended
command: |
# These build machines are discarded after the job.
sudo install -d /etc/needrestart/conf.d
printf '%s\n' '$nrconf{restart} = "l";' | sudo tee /etc/needrestart/conf.d/99-qqq-ci.conf >/dev/null
workflows:
test_only:
jobs:
- qqq-orb/mvn_test_only:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
filters:
branches:
ignore: /(develop|main|release/.*|hotfix/.*|integration.*)/
tags:
only: []
publish_snapshot:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: snapshot
filters:
branches:
only:
- develop
publish_feature:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: feature
filters:
branches:
only:
- feature/.*
tags:
only: [/publish.*/]
publish_release_candidate:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: release_candidate
filters:
branches:
only:
- /release\/.*/
publish_release:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: release
filters:
branches:
ignore: /.*/
tags:
only: [/^v\d+\.\d+\.\d+$/]
publish_hotfix_release:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: hotfix
filters:
branches:
only:
- /hotfix\/.*/
File diff suppressed because it is too large. Load diff
+257 -5
View File
@@ -1,4 +1,6 @@
import importlib.util
import json
import io
import pathlib
import unittest
from unittest.mock import patch
@@ -25,7 +27,197 @@ class Snapshot:
return self.required
class InventoryTests(unittest.TestCase):
def repo(self, name, archived=False):
return {'name': name, 'full_name': 'QRun-IO/' + name,
'archived': archived, 'default_branch': 'main'}
def test_all_pages_include_new_private_and_archived_repositories(self):
new = dict(self.repo('new-product'), private=True)
pages = [[self.repo('qbit-existing')], [new, self.repo('retired', True)]]
with patch.object(audit, 'command', return_value=json.dumps(pages)) as command:
entries = audit.discover_inventory('QRun-IO')
self.assertEqual([e['name'] for e in entries], ['new-product', 'qbit-existing', 'retired'])
self.assertTrue(entries[-1]['isArchived'])
self.assertEqual(command.call_args.args[0], ['gh', 'api', '--method', 'GET',
'--paginate', '--slurp', 'orgs/QRun-IO/repos?type=all&per_page=100'])
def test_empty_duplicate_foreign_and_malformed_inventories_fail_closed(self):
repo = self.repo('qbit-example')
for pages in ([], [[]], {}, [repo], [[repo], [repo]],
[[dict(repo, full_name='Other/qbit-example')]],
[[dict(repo, archived='false')]], [[dict(repo, default_branch=None)]]):
with self.subTest(pages=pages), patch.object(audit, 'command', return_value=json.dumps(pages)):
with self.assertRaises(audit.ReadError):
audit.discover_inventory('QRun-IO')
with patch.object(audit, 'command') as command:
with self.assertRaises(audit.ReadError):
audit.discover_inventory('QRun-IO/../../other')
command.assert_not_called()
def test_live_cli_count_is_dynamic_but_explicit_expectation_is_enforced(self):
for expected, status in ((None, 0), ('1', 0), ('68', 1)):
args = ['audit', '--organization', 'QRun-IO', '--live', '--orb-version', '0.8']
if expected:
args += ['--expected-active', expected]
report = {'active_count': 1, 'unique_repository_count': 1,
'inventory_count': 1, 'results': [{'status': 'pass'}]}
output = io.StringIO()
with patch.object(audit.sys, 'argv', args), patch.object(audit.sys, 'stdout', output), \
patch.object(audit, 'discover_inventory', return_value=[ENTRY]), \
patch.object(audit, 'run', return_value=report):
self.assertEqual(audit.main(), status)
self.assertEqual(json.loads(output.getvalue())['inventory_source'], 'organization-api')
def test_discovery_api_failure_never_falls_back_to_old_inventory(self):
with patch.object(audit, 'command', side_effect=audit.ReadError('unavailable')):
with self.assertRaises(audit.ReadError):
audit.discover_inventory('QRun-IO')
class AuditTests(unittest.TestCase):
def test_all_scanner_and_release_requirements_follow_branch_profile(self):
entry = dict(ENTRY, name='qqq-all', nameWithOwner='QRun-IO/qqq-all')
scanner = '.github/workflows/codeql.yml'
release = audit.auxiliary.BRIDGES['all-release']['path']
for profile in ('all', 'repository-policy'):
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': profile, 'orb_version': VERSION, 'default_branch': 'develop'}),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller(profile, VERSION))}
policy = dict(POLICY, profile=profile, codeql_worker_sha=SHA)
report = audit.audit(entry, Snapshot(files), VERSION, SHA, policy)
missing = {f.get('path') for f in report['findings'] if f['code'] == 'missing_native_maintenance_bridge'}
self.assertIn(scanner, missing)
self.assertEqual(profile == 'all', release in missing)
files[scanner] = audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-codeql', SHA), sort_keys=False)
if profile == 'all':
files[release] = audit.generator.yaml.safe_dump(audit.auxiliary.canonical('all-release', SHA), sort_keys=False)
self.assertEqual([], audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings'])
files[scanner] = files[scanner].replace(SHA, 'b' * 40)
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings']])
files[release] = 'jobs: {}'
self.assertTrue(any(f['code'] == 'native_maintenance_bridge_drift' and f.get('path') == release for f in audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings']))
def test_schema_drift_bridge_tracks_branch_source_without_exempting_default(self):
entry = dict(ENTRY, name='qbit-authentik', nameWithOwner='QRun-IO/qbit-authentik')
path = '.github/workflows/schema-drift.yml'
cases = [
('main', {}, False),
('main', {'src/test/java/example/SchemaDriftTest.java': 'class SchemaDriftTest {}'}, True),
('develop', {}, True),
]
for branch, files, required in cases:
with self.subTest(branch=branch, files=files):
snapshot = Snapshot(files)
snapshot.branch, snapshot.default_branch = branch, 'develop'
report = audit.audit(entry, snapshot, VERSION, SHA, POLICY)
missing = any(f['code'] == 'missing_native_maintenance_bridge' and f.get('path') == path for f in report['findings'])
self.assertEqual(required, missing)
snapshot = Snapshot({path: 'jobs: {}'})
snapshot.branch, snapshot.default_branch = 'main', 'develop'
report = audit.audit(entry, snapshot, VERSION, SHA, POLICY)
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in report['findings']])
def test_placeholder_can_retain_canonical_release_and_scanner_bridges(self):
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': 'repository-policy', 'orb_version': VERSION, 'default_branch': 'develop'}),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('repository-policy', VERSION)),
audit.rc_worker.CALLER_PATH: audit.rc_worker.generate(SHA),
'.github/workflows/codeql.yml': audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-codeql', SHA), sort_keys=False)}
snapshot = Snapshot(files)
snapshot.branch = 'main'
snapshot.default_branch = 'develop'
policy = dict(POLICY, branch_profiles={'main': 'repository-policy'}, rc_worker_sha=SHA, codeql_worker_sha=SHA)
self.assertEqual([], audit.audit(entry, snapshot, VERSION, SHA, policy)['findings'])
files['.github/workflows/codeql.yml'] = files['.github/workflows/codeql.yml'].replace(SHA, 'b' * 40)
self.assertTrue(any(f['code'] == 'native_maintenance_bridge_drift' for f in audit.audit(entry, snapshot, VERSION, SHA, policy)['findings']))
def test_placeholder_profile_is_scoped_to_selected_branch(self):
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': 'repository-policy', 'orb_version': VERSION, 'default_branch': 'develop'}),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('repository-policy', VERSION))}
snapshot = Snapshot(files)
snapshot.branch = 'main'
snapshot.default_branch = 'develop'
policy = dict(POLICY, branch_profiles={'main': 'repository-policy'})
self.assertEqual([], audit.audit(entry, snapshot, VERSION, SHA, policy)['findings'])
snapshot.branch = 'develop'
report = audit.audit(entry, snapshot, VERSION, SHA, policy)
self.assertEqual('qbit', report['profile'])
self.assertTrue(any(f['code'] == 'profile_mismatch' for f in report['findings']))
def test_qbit_scanner_policy_requires_exact_canonical_worker(self):
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
manifest = {'profile': 'qbit', 'orb_version': VERSION, 'default_branch': 'develop',
'publish': {'snapshot': False, 'release_candidate': False, 'release': False}}
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump(manifest),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('qbit', VERSION))}
policy = dict(POLICY, codeql_worker_sha='b' * 40)
report = audit.audit(entry, Snapshot(files), VERSION, SHA, policy)
self.assertTrue(any(f['code'] == 'missing_native_maintenance_bridge' for f in report['findings']))
files['.github/workflows/codeql.yml'] = audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-codeql', 'b' * 40), sort_keys=False)
self.assertEqual([], audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings'])
files['.github/workflows/codeql.yml'] = files['.github/workflows/codeql.yml'].replace('b' * 40, 'a' * 40)
report = audit.audit(entry, Snapshot(files), VERSION, SHA, policy)
self.assertTrue(any(f['code'] == 'native_maintenance_bridge_drift' for f in report['findings']))
def test_live_snapshot_reads_requested_branch_and_keeps_default_identity(self):
entry = dict(ENTRY, sourceBranch='release/1.2')
replies = [{'default_branch': 'develop', 'archived': False}, {'sha': SHA},
{'truncated': False, 'tree': []}]
with patch.object(audit, 'gh', side_effect=replies) as gh:
snapshot = audit.Snapshot(entry, live=True)
self.assertEqual('develop', snapshot.default_branch)
self.assertEqual('release/1.2', snapshot.branch)
self.assertEqual('repos/QRun-IO/qctl/commits/release%2F1.2', gh.call_args_list[1].args[0])
def test_other_source_branch_does_not_change_manifest_default_branch(self):
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
manifest = {'profile': 'qbit', 'orb_version': VERSION, 'default_branch': 'develop',
'publish': {'snapshot': False, 'release_candidate': False, 'release': False}}
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump(manifest),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('qbit', VERSION))}
snapshot = Snapshot(files)
snapshot.branch = 'main'
snapshot.default_branch = 'develop'
report = audit.audit(entry, snapshot, VERSION, SHA, POLICY)
self.assertEqual([], report['findings'])
self.assertEqual('main', report['source_branch'])
self.assertEqual('develop', report['default_branch'])
def test_selected_branch_read_failure_is_unknown_not_default_fallback(self):
captured = []
def factory(entry, live):
captured.append(entry)
raise audit.ReadError('branch unavailable')
report = audit.run([ENTRY], VERSION, SHA, {}, live=True,
snapshot_factory=factory, source_branch='main')
self.assertEqual('main', captured[0]['sourceBranch'])
self.assertEqual('unknown', report['results'][0]['status'])
self.assertEqual('main', report['results'][0]['source_branch'])
self.assertNotIn('sourceBranch', ENTRY)
def test_omitted_source_branch_still_reads_repository_default(self):
replies = [{'default_branch': 'develop', 'archived': False}, {'sha': SHA},
{'truncated': False, 'tree': []}]
with patch.object(audit, 'gh', side_effect=replies) as gh:
snapshot = audit.Snapshot(ENTRY, live=True)
self.assertEqual('develop', snapshot.branch)
self.assertEqual('develop', snapshot.default_branch)
self.assertEqual('repos/QRun-IO/qctl/commits/develop', gh.call_args_list[1].args[0])
def test_explicit_source_branch_cannot_relabel_offline_snapshot(self):
with self.assertRaises(ValueError):
audit.run([ENTRY], VERSION, SHA, {}, source_branch='main')
with self.assertRaises(audit.ReadError):
audit.Snapshot(dict(ENTRY, sourceBranch='main'), live=False)
def test_invalid_source_branch_is_rejected_before_api_calls(self):
for branch in ('', 'main?ref=develop', 'main\n', 123):
with self.subTest(branch=branch), patch.object(audit, 'gh') as gh:
with self.assertRaises(audit.ReadError):
audit.Snapshot(dict(ENTRY, sourceBranch=branch), live=True)
gh.assert_not_called()
def native(self, files=None, checks=None, policy=POLICY):
files = files if files is not None else {'.github/workflows/build.yml': audit.qctl.generate(SHA)}
return audit.audit(ENTRY, Snapshot(files, checks), VERSION, SHA, policy)
@@ -74,6 +266,25 @@ class AuditTests(unittest.TestCase):
report = audit.audit(entry, Snapshot({'.qqq-ci.yml': audit.generator.yaml.safe_dump(manifest)}), VERSION, SHA, POLICY)
self.assertIn('missing_rc_bridge', [f['code'] for f in report['findings']])
def test_rc_pin_policy_does_not_force_unchanged_auxiliary_worker_updates(self):
entry = dict(ENTRY, name='qbit-authentik', nameWithOwner='QRun-IO/qbit-authentik')
rc_sha = 'b' * 40
definition = audit.auxiliary.BRIDGES['qbit-schema-drift']
manifest = {'profile': 'qbit', 'orb_version': VERSION, 'default_branch': 'develop', 'release_completion': True}
files = {audit.rc_worker.CALLER_PATH: audit.rc_worker.generate(rc_sha),
definition['path']: audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-schema-drift', SHA), sort_keys=False),
'.qqq-ci.yml': audit.generator.yaml.safe_dump(manifest),
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('qbit', VERSION))}
policy = dict(POLICY, rc_worker_sha=rc_sha)
self.assertEqual('pass', audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['status'])
for pin in (SHA, 'main', ''):
with self.subTest(pin=pin):
report = audit.audit(entry, Snapshot(files), VERSION, SHA, dict(POLICY, rc_worker_sha=pin))
self.assertTrue(report['findings'])
files[definition['path']] = files[definition['path']].replace(SHA, rc_sha)
report = audit.audit(entry, Snapshot(files), VERSION, SHA, policy)
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in report['findings']])
def test_qbit_rc_bridge_missing_drift_pin_and_duplicate(self):
entry = dict(ENTRY, name='qbit-test', nameWithOwner='QRun-IO/qbit-test')
path = audit.rc_worker.CALLER_PATH
@@ -113,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)
@@ -129,7 +359,8 @@ 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(8, 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)
files = {path: 'identity fixture' for path in policy['required_paths']}
@@ -151,13 +382,13 @@ class AuditTests(unittest.TestCase):
self.assertIn('profile_not_assigned', [f['code'] for f in report['findings']])
def test_native_specialists_require_bridges_and_report_remaining_workflows(self):
for name, kind in [('qqq-mcp-rag', 'mcp-rag'), ('qqq-business-platform', 'business-db'), ('.github', 'github-workflow-lint')]:
for name, kind in [('qqq-mcp-rag', 'mcp-rag'), ('qqq-business-platform', 'business-db'), ('.github', 'github-workflow-lint'), ('marketing-website-cd', 'gitops'), ('voyage-cd', 'gitops')]:
entry = dict(ENTRY, name=name, nameWithOwner='QRun-IO/' + name)
definition = audit.auxiliary.BRIDGES[kind]
missing = audit.audit(entry, Snapshot({}), VERSION, SHA, {})
self.assertIn('missing_native_maintenance_bridge', [f['code'] for f in missing['findings']])
files = {item['path']: audit.generator.yaml.safe_dump(audit.auxiliary.canonical(key, SHA), sort_keys=False)
for key, item in audit.auxiliary.BRIDGES.items() if item['repository'] == entry['nameWithOwner']}
for key, item in audit.auxiliary.BRIDGES.items() if item['repository'] == entry['nameWithOwner'] or entry['nameWithOwner'] in item.get('additional_repositories', [])}
report = audit.audit(entry, Snapshot(files), VERSION, SHA, {})
self.assertEqual([], report['findings'])
self.assertEqual('unknown', report['status'])
@@ -226,10 +457,31 @@ class AuditTests(unittest.TestCase):
audit.audit(other, Snapshot({}, checks=[]), VERSION, SHA, policy)
def test_invalid_managed_branches_cannot_bypass_policy(self):
for managed in [[], ['main', 'main'], ['feature'], 'main', None, [True]]:
for managed in [[], ['main', 'main'], ['feature'], 'main', None, [True],
['release/*'], ['release/1.2/extra'], ['hotfix/1..2'],
['release/1.2', 'release/1.2']]:
with self.subTest(managed=managed), self.assertRaises(audit.ReadError):
self.native(policy={'managed_branches': managed, 'required_checks': {}})
def test_release_and_hotfix_enforcement_requires_actual_checks(self):
files = {'.github/workflows/build.yml': audit.qctl.generate(SHA)}
for branch in ['release/0.1', 'release/4.1.0', 'hotfix/4.0.1']:
with self.subTest(branch=branch):
snapshot = Snapshot(files)
snapshot.branch = branch
policy = {'managed_branches': [branch],
'required_checks': {branch: ['native / test']}}
with patch.object(snapshot, 'checks', wraps=snapshot.checks) as read:
report = audit.audit(ENTRY, snapshot, VERSION, SHA, policy)
self.assertEqual('pass', report['status'])
read.assert_called_once_with(branch)
snapshot.required = []
report = audit.audit(ENTRY, snapshot, VERSION, SHA, policy)
self.assertEqual('missing', report['required_checks'][branch]['state'])
self.assertEqual('findings', report['status'])
policy['required_checks'] = {}
self.assertEqual('unknown', audit.audit(ENTRY, snapshot, VERSION, SHA, policy)['status'])
def test_gh_is_explicit_get_and_never_changes_settings(self):
with patch.object(audit, 'command', return_value='{}') as command:
audit.gh('repos/QRun-IO/example')
+41 -2
View File
@@ -1,4 +1,7 @@
import copy
import os
import subprocess
import tempfile
import importlib.util
import json
from pathlib import Path
@@ -14,6 +17,40 @@ ORIGINALS = json.loads((ROOT / 'tests/fixtures/auxiliary-original-workflows.json
SHA = 'a' * 40
class GitOpsTests(unittest.TestCase):
def test_render_all_directories_and_fail_on_invalid_or_missing_configuration(self):
worker = yaml.safe_load((ROOT / '.github/workflows/gitops.yml').read_text())
command = worker['jobs']['validate']['steps'][-1]['run']
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
binary = root / 'bin'
binary.mkdir()
tool = binary / 'kustomize'
tool.write_text("#!/bin/bash\n[[ $1 == build ]] || exit 2\n[[ ! -f \"$2/invalid\" ]] || exit 1\necho sensitive-rendered-fixture\n")
tool.chmod(0o755)
env = {**os.environ, 'PATH': str(binary) + os.pathsep + os.environ['PATH']}
def run():
return subprocess.run(['bash', '-c', command], cwd=root, env=env, text=True, capture_output=True)
self.assertNotEqual(0, run().returncode)
for name in ('base', 'overlays/dev', 'overlays/with space', 'proxy'):
folder = root / name
folder.mkdir(parents=True)
(folder / 'kustomization.yaml').write_text('resources: []')
result = run()
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual(4, result.stdout.count('Validated '))
self.assertNotIn('sensitive-rendered-fixture', result.stdout)
(root / 'proxy/invalid').touch()
self.assertNotEqual(0, run().returncode)
def test_gitops_caller_is_read_only_and_has_no_duplicate_feature_push_build(self):
caller = bridge.canonical('gitops', SHA)
self.assertEqual({'contents': 'read'}, caller['permissions'])
self.assertEqual(['main'], caller['on']['push']['branches'])
self.assertNotIn('paths', caller['on']['pull_request'])
self.assertNotIn('secrets', caller['jobs']['gitops'])
class SpecialistNativeTests(unittest.TestCase):
def setUp(self):
self.originals = json.loads((ROOT / 'tests/fixtures/specialist-native-originals.json').read_text(encoding='utf-8'))
@@ -21,12 +58,14 @@ class SpecialistNativeTests(unittest.TestCase):
def worker(self, kind):
return yaml.safe_load((ROOT / '.github/workflows' / (kind + '.yml')).read_text(encoding='utf-8'))
def test_business_database_job_and_path_filters_are_unchanged(self):
def test_business_database_gate_reports_for_every_pr_and_preserves_validation(self):
original = self.originals['business-db']
worker = self.worker('business-db')
self.assertEqual(worker['jobs'], original['workflow']['jobs'])
caller = bridge.canonical('business-db', SHA)
self.assertEqual(caller['on'], original['events'])
self.assertEqual(caller['on'], {'pull_request': {}, 'push': {'branches': ['main']}})
self.assertEqual(caller['concurrency']['cancel-in-progress'], "${{ github.event_name == 'pull_request' }}")
self.assertIn('github.event.pull_request.number || github.ref', caller['concurrency']['group'])
self.assertEqual(set(worker['jobs']), {'empty-database-migration'})
self.assertNotIn('secrets', caller['jobs']['validate'])
self.assertNotIn('schedule', caller['on'])
+69
View File
@@ -0,0 +1,69 @@
#!/bin/bash
# Exercise real browser scripts without sudo, package installation or network.
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
mkdir "$scratch/bin"
export INSTALL_LOG="$scratch/install.log"
cat > "$scratch/bin/sudo" <<'STUB'
#!/bin/bash
printf '%s\n' "$*" >> "$INSTALL_LOG"
if [[ "$*" == *'apt-get update'* ]]; then
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || { echo 'unrelated image PPA: 503' >&2; exit 100; }
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 91
[[ ${REQUIRED_REPO_FAIL:-0} == 0 ]] || exit 100
fi
if [[ "$1" == tee ]]; then cat >> "$INSTALL_LOG"; fi
if [[ "$1" == gpg ]]; then cat >/dev/null; fi
STUB
chmod +x "$scratch/bin/sudo"
export PATH="$scratch/bin:$PATH"
bash "$root/src/scripts/frontend_test_dependencies.sh"
echo 'PASS: browser dependencies ignore unavailable image PPAs'
# Model Chrome presence without depending on the host's installed browsers.
export CHROME_MARKER="$scratch/chrome-installed"
export BASH_ENV="$scratch/shell-env"
cat > "$BASH_ENV" <<'STUB'
command() {
if [[ "$*" == '-v google-chrome' ]]; then [[ -f "$CHROME_MARKER" ]]; else builtin command "$@"; fi
}
google-chrome() { [[ -f "$CHROME_MARKER" ]] && echo 'Google Chrome test'; }
STUB
cat > "$scratch/bin/curl" <<'STUB'
#!/bin/bash
printf '%s\n' "$*" >> "$INSTALL_LOG"
[[ ${KEY_FAIL:-0} == 0 ]] || exit 22
printf 'signing-key\n'
STUB
cat > "$scratch/bin/dpkg" <<'STUB'
#!/bin/bash
echo amd64
STUB
# Successful installation makes Chrome available to the final version check.
# shellcheck disable=SC2016
sed -i '/if \[\[ "$1" == tee/i if [[ "$*" == *"apt-get install -y google-chrome-stable"* ]]; then touch "$CHROME_MARKER"; fi' "$scratch/bin/sudo"
chmod +x "$scratch/bin/"*
: > "$INSTALL_LOG"
bash "$root/src/scripts/install_chrome.sh" >/dev/null
grep -q 'Dir::Etc::sourcelist=/etc/apt/sources.list.d/qqq-google-chrome.list' "$INSTALL_LOG"
grep -q 'gpg --batch --yes --dearmor -o /usr/share/keyrings/qqq-google-chrome.gpg' "$INSTALL_LOG"
grep -q 'signed-by=/usr/share/keyrings/qqq-google-chrome.gpg] https://dl.google.com/linux/chrome/deb/' "$INSTALL_LOG"
grep -q 'apt-get install -y google-chrome-stable' "$INSTALL_LOG"
: > "$INSTALL_LOG"
bash "$root/src/scripts/install_chrome.sh" >/dev/null
[[ ! -s "$INSTALL_LOG" ]] # Existing Chrome needs no network/package work.
rm "$CHROME_MARKER"
for script in install_chrome frontend_test_dependencies; do
: > "$INSTALL_LOG"
if REQUIRED_REPO_FAIL=1 bash "$root/src/scripts/$script.sh" >/dev/null 2>&1; then
echo "Required repository outage accepted: $script" >&2; exit 1
fi
if grep -q 'apt-get install' "$INSTALL_LOG"; then exit 1; fi
done
: > "$INSTALL_LOG"
if KEY_FAIL=1 bash "$root/src/scripts/install_chrome.sh" >/dev/null 2>&1; then
echo 'Signing key failure accepted' >&2; exit 1
fi
if grep -q 'apt-get' "$INSTALL_LOG"; then exit 1; fi
echo 'PASS: Chrome ignores unrelated PPAs; required repositories and signing key fail closed; existing browser reused'
+6 -3
View File
@@ -29,11 +29,14 @@ class BusinessE2ETests(unittest.TestCase):
self.assertEqual('always()', self.worker['jobs']['e2e']['steps'][-1]['if'])
self.assertEqual('docker compose -f deploy/compose/docker-compose.yml down -v', self.worker['jobs']['e2e']['steps'][-1]['run'])
def test_events_permissions_path_and_single_concurrency_owner_preserved(self):
self.assertEqual(self.original['events'], self.caller['on'])
def test_code_changes_and_manual_runs_keep_full_gate_without_nightly_duplicates(self):
expected_events = copy.deepcopy(self.original['events'])
del expected_events['schedule']
self.assertEqual(expected_events, self.caller['on'])
self.assertEqual(self.original['workflow']['permissions'], self.caller['permissions'])
self.assertEqual(self.caller['permissions'], self.worker['permissions'])
self.assertEqual(self.original['workflow']['concurrency'], self.caller['concurrency'])
self.assertEqual(self.original['workflow']['concurrency']['group'], self.caller['concurrency']['group'])
self.assertEqual("${{ github.event_name == 'pull_request' }}", self.caller['concurrency']['cancel-in-progress'])
self.assertNotIn('concurrency', self.worker)
self.assertEqual('.github/workflows/e2e.yml', aux.BRIDGES['business-e2e']['path'])
self.assertEqual({'workflow_call': {'secrets': {'E2E_ALERT_WEBHOOK_URL': {'required': False}}}}, self.worker['on'])
+109
View File
@@ -0,0 +1,109 @@
"""CI maintenance retains Maven verification and never becomes a release request."""
import importlib.util
from pathlib import Path
import unittest
from unittest import mock
import yaml
ROOT = Path(__file__).resolve().parents[1]
spec = importlib.util.spec_from_file_location('pipeline', ROOT/'src/scripts/generate_pipeline.py')
pipeline = importlib.util.module_from_spec(spec)
spec.loader.exec_module(pipeline)
class MaintenanceTests(unittest.TestCase):
def git_result(self, *args):
return {'log': self.subject, 'rev-list': self.parents, 'diff': self.paths}.get(args[0])
def setUp(self):
self.subject = b'ci: use central pipeline\n'
self.parents = b'a'*40 + b' ' + b'b'*40 + b'\n'
self.paths = b'.qqq-ci.yml\0.circleci/config.yml\0.github/workflows/codeql.yml\0.github/workflows/release-rc.yml\0'
def test_publishing_branches_keep_unfiltered_maven_tests(self):
manifest = {'profile': 'qbit', 'orb_version': '0.7.14', 'default_branch': 'develop',
'release_on_main': True, 'test_branch_policy': 'feature-no-hotfix',
'publish': {'hotfix': True}}
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
config = pipeline.load_manifest('unused', '0.7.14')
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
for branch in ('main', 'develop', 'release/0.1', 'hotfix/1.2.3'):
with self.subTest(branch=branch):
result = pipeline.qbit_template(config, branch, '')
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/mvn_test_only']
self.assertEqual(job['filters']['branches'], {'ignore': 'automation/qbit-rc-pending'})
self.assertNotIn('branch_type', job)
def test_nonpublishing_branches_verify_maintenance_but_keep_application_policy(self):
manifest = {'profile': 'qbit', 'orb_version': '0.8', 'default_branch': 'main',
'release_on_main': False, 'test_branch_policy': 'feature-no-hotfix',
'publish': {'snapshot': False, 'release_candidate': False, 'hotfix': False}}
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
config = pipeline.load_manifest('unused', '0.8')
maintenance_paths = self.paths
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
for branch in ('main', 'develop', 'release/0.1', 'hotfix/1.2.3'):
for maintenance in (True, False):
with self.subTest(branch=branch, maintenance=maintenance):
self.paths = maintenance_paths if maintenance else b'src/Main.java\0'
result = pipeline.qbit_template(config, branch, '')
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/mvn_test_only']
ignored = job['filters']['branches']['ignore']
if maintenance:
self.assertEqual(ignored, 'automation/qbit-rc-pending')
else:
self.assertEqual(ignored, ['automation/qbit-rc-pending',
'/(develop|main|release/.*|hotfix/.*|integration.*)/'])
self.assertNotIn('branch_type', job)
def test_frontend_maintenance_verifies_without_publishing(self):
for profile, prefix in (('frontend-core', 'node_'), ('frontend-material', 'mvn_frontend_')):
manifest = {'profile': profile, 'orb_version': '0.8', 'default_branch': 'develop'}
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
config = pipeline.load_manifest('unused', '0.8')
for branch in ('main', 'develop', 'release/1.0', 'hotfix/1.0.1'):
with self.subTest(profile=profile, branch=branch), mock.patch.object(pipeline, 'git', side_effect=self.git_result):
result = pipeline.frontend_template(config, branch, '')
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/' + prefix + 'test_only']
self.assertNotIn('branch_type', job)
self.assertEqual(job['filters']['branches'], {'ignore': 'automation/qbit-rc-pending'})
self.paths = b'package.json\0'
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
result = pipeline.frontend_template(config, 'develop', '')
self.assertIn('qqq-orb/' + prefix + 'publish', result['workflows']['publish_snapshot']['jobs'][0])
self.paths = b'.qqq-ci.yml\0'
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
result = pipeline.frontend_template(config, 'main', 'v1.2.3')
job = result['workflows']['publish_release']['jobs'][0]['qqq-orb/' + prefix + 'publish']
self.assertEqual(job['branch_type'], 'release')
def test_application_changes_and_unknown_files_publish_normally(self):
for paths in (b'pom.xml\0', b'.qqq-ci.yml\0src/Main.java\0', b'.github/workflows/custom-release.yml\0', b'', None):
self.paths = paths
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
def test_schema_caller_migration_is_maintenance_but_schema_inputs_are_not(self):
self.paths = b'.github/workflows/schema-drift.yml\0'
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
self.assertTrue(pipeline.proven_ci_maintenance('release/0.1', ''))
for path in (b'pom.xml\0', b'src/test/resources/schema.yml\0', b'src/test/java/SchemaDriftTest.java\0'):
self.paths = b'.github/workflows/schema-drift.yml\0' + path
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
def test_merge_root_and_unavailable_history_do_not_suppress_release(self):
for parents in (None, b'a'*40+b'\n', self.parents.rstrip()+b' '+b'c'*40+b'\n'):
self.parents = parents
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
def test_tags_and_release_requests_do_not_suppress_release(self):
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
self.assertFalse(pipeline.proven_ci_maintenance('main', 'v1.2.3'))
for subject in (b'Merge develop for next RC\n', b'fix: application\n', None):
self.subject = subject
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
if __name__ == '__main__':
unittest.main()
+105
View File
@@ -0,0 +1,105 @@
"""Cost settings preserve source qualification and unrelated project controls."""
from pathlib import Path
import sys
import unittest
from unittest.mock import Mock
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
import circle_project_settings as settings
class SettingsTests(unittest.TestCase):
def setUp(self):
self.plan = {'repository': 'QRun-IO/marketing-website', 'profile': 'marketing',
'branch': 'main', 'head': 'a' * 40, 'changed': False}
self.before = {'autocancel-builds': False, 'setup-workflows': True,
'build-fork-prs': False, 'drop-all-build-requests': False}
self.source = Mock(side_effect=[{'archived': False, 'default_branch': 'main'},
{'commit': {'sha': self.plan['head']}}])
def test_narrow_update_and_idempotent_readback(self):
request = Mock(side_effect=[{'feature_flags': self.before}, {},
{'feature_flags': {**self.before, 'autocancel-builds': True}}])
result = settings.reconcile(self.plan, self.source, True, request)
self.assertEqual({'state': 'enforced', 'changed': True}, result)
self.assertEqual({'feature_flags': {'autocancel-builds': True}}, request.call_args_list[1].args[1])
request = Mock(return_value={'feature_flags': {**self.before, 'autocancel-builds': True}})
source = Mock(return_value={'archived': False, 'default_branch': 'main'})
self.assertEqual({'state': 'enforced', 'changed': False},
settings.reconcile(self.plan, source, True, request))
self.assertEqual(1, request.call_count)
def test_dry_run_never_writes(self):
request = Mock(return_value={'feature_flags': self.before})
self.assertEqual({'state': 'inspected', 'changed': True},
settings.reconcile(self.plan, self.source, False, request))
request.assert_called_once_with(self.plan['repository'])
def test_unreviewed_profiles_and_unconverted_sources_never_call_api(self):
for change, expected in [({'profile': 'qbit'}, 'not-managed'),
({'profile': 'native-gitops'}, 'not-managed'),
({'changed': True}, 'waiting-source')]:
source, request = Mock(), Mock()
result = settings.reconcile({**self.plan, **change}, source, True, request)
self.assertEqual(expected, result['state'])
source.assert_not_called()
request.assert_not_called()
def test_changed_head_or_unexpected_default_branch_prevents_write(self):
for responses in [
[{'archived': False, 'default_branch': 'main'}, {'commit': {'sha': 'b' * 40}}],
[{'archived': False, 'default_branch': 'develop'}],
[{'archived': True, 'default_branch': 'main'}],
]:
request = Mock(return_value={'feature_flags': self.before})
result = settings.reconcile(self.plan, Mock(side_effect=responses), True, request)
self.assertEqual('unresolved', result['state'])
self.assertTrue(all(len(call.args) == 1 for call in request.call_args_list))
def test_unrelated_setting_drift_and_unavailable_api_are_not_success(self):
request = Mock(side_effect=[{'feature_flags': self.before}, {},
{'feature_flags': {**self.before, 'autocancel-builds': True,
'build-fork-prs': True}}])
self.assertEqual('unresolved', settings.reconcile(self.plan, self.source, True, request)['state'])
source = Mock(return_value={'archived': False, 'default_branch': 'main'})
for response in [Mock(side_effect=ValueError('Central CircleCI credential unavailable')),
Mock(return_value={'feature_flags': {}})]:
self.assertEqual('unresolved', settings.reconcile(self.plan, source, True, response)['state'])
def test_repository_policy_requires_every_current_branch(self):
main = {**self.plan, 'profile': 'repository-policy'}
develop = {**main, 'branch': 'develop', 'profile': 'qbit'}
for plans in ([main, develop], [develop, main]):
source, request = Mock(), Mock()
result = settings.reconcile_repository(plans, [], source, True, request)
self.assertEqual('not-managed', result['state'])
source.assert_not_called()
request.assert_not_called()
for plans, findings in [
([main, {**main, 'branch': 'develop', 'changed': True}], []),
([main], [{'repository': main['repository'], 'branch': 'develop', 'state': 'unresolved'}]),
]:
request = Mock()
self.assertEqual('waiting-source', settings.reconcile_repository(
plans, findings, Mock(), True, request)['state'])
request.assert_not_called()
def test_repository_policy_checks_all_heads_and_writes_once(self):
plans = [self.plan, {**self.plan, 'branch': 'develop', 'head': 'b' * 40}]
def source(path):
if '/branches/' in path:
return {'commit': {'sha': next(p['head'] for p in plans if path.endswith('/' + p['branch']))}}
return {'archived': False, 'default_branch': 'main'}
request = Mock(side_effect=[{'feature_flags': self.before}, {},
{'feature_flags': {**self.before, 'autocancel-builds': True}}])
self.assertEqual({'state': 'enforced', 'changed': True},
settings.reconcile_repository(plans, [], source, True, request))
self.assertEqual(1, sum(len(call.args) == 2 for call in request.call_args_list))
request = Mock()
stale = lambda path: {'commit': {'sha': self.plan['head']}}
self.assertEqual('unresolved', settings.reconcile_repository(plans, [], stale, True, request)['state'])
request.assert_not_called()
if __name__ == '__main__':
unittest.main()
+27 -10
View File
@@ -5,7 +5,7 @@ scripts=$(cd "$(dirname "${BASH_SOURCE[0]}")/../src/scripts" && pwd)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
cd "$scratch"
mkdir -p bin node_modules/.bin packages/{ui-api-client,conformance,cli}/src
mkdir -p bin node_modules/.bin packages/{ui-api-client,core,conformance,cli}/src
export CLI_LOG="$scratch/commands" PRISM_PID_FILE="$scratch/prism-pid" CONFIG_PATH_FILE="$scratch/npm-config-path"
cat > bin/npm <<'STUB'
#!/bin/bash
@@ -35,7 +35,7 @@ chmod +x bin/* node_modules/.bin/prism
export PATH="$scratch/bin:$PATH"
: > "$CLI_LOG"
bash "$scripts/cli_verify.sh"
[[ "$(cat "$CLI_LOG")" == $'run generate\nrun build\ntest' ]]
[[ "$(cat "$CLI_LOG")" == $'run generate\nrun build\ntest\nrun lint' ]]
if [[ -e "$PRISM_PID_FILE" ]] && kill -0 "$(cat "$PRISM_PID_FILE")" 2>/dev/null; then
echo 'Prism process survived cleanup' >&2
exit 1
@@ -51,20 +51,37 @@ if [[ -e "$PRISM_PID_FILE" ]] && kill -0 "$(cat "$PRISM_PID_FILE")" 2>/dev/null;
echo 'Prism process survived cleanup' >&2
exit 1
fi
for item in 'ui-api-client qqq-ui-api-client 1.6.0-rc.1' 'conformance qqq-ui-api-conformance 1.6.0-rc.1' 'cli qqq-cli 0.1.0-rc.1'; do
read -r dir name version <<< "$item"
printf '{"name":"@qrun-io/%s","version":"%s","publishConfig":{"registry":"https://npm.pkg.github.com"}}\n' "$name" "$version" > "packages/$dir/package.json"
done
write_packages() {
local core_version=$1 core_dependency=$2 client_version=${3:-1.6.0-rc.1} cli_version=${4:-0.1.0-rc.1} item dir name version
for item in "ui-api-client qqq-ui-api-client $client_version" "core qqq-core $core_version" "conformance qqq-ui-api-conformance $client_version" "cli qqq-cli $cli_version"; do
read -r dir name version <<< "$item"
printf '{"name":"@qrun-io/%s","version":"%s","publishConfig":{"registry":"https://npm.pkg.github.com"},"dependencies":{"@qrun-io/qqq-core":"%s"}}\n' "$name" "$version" "$core_dependency" > "packages/$dir/package.json"
done
}
write_packages 0.1.0-rc.1 0.1.0-rc.1
export CIRCLE_TAG=v1.6.0-rc.1 GITHUB_TOKEN=test-not-a-credential
: > "$CLI_LOG"
bash "$scripts/cli_publish.sh"
[[ $(grep -c '^publish ' "$CLI_LOG") -eq 3 ]]
[[ $(grep -c -- '--tag rc$' "$CLI_LOG") -eq 3 ]]
[[ "$(grep '^publish ' "$CLI_LOG" | cut -d' ' -f3)" == $'@qrun-io/qqq-ui-api-client\n@qrun-io/qqq-core\n@qrun-io/qqq-ui-api-conformance\n@qrun-io/qqq-cli' ]]
[[ $(grep -c -- '--tag rc$' "$CLI_LOG") -eq 4 ]]
# Final versions publish as latest; any prerelease among the four keeps rc.
write_packages 1.0.0 1.0.0 1.6.0 1.0.0
: > "$CLI_LOG"
CIRCLE_TAG=v1.6.0 bash "$scripts/cli_publish.sh"
[[ $(grep -c -- '--tag latest$' "$CLI_LOG") -eq 4 ]]
[[ $(grep -c '^publish ' "$CLI_LOG") -eq 4 ]]
write_packages 1.0.0 1.0.0 1.6.0-rc.3 1.0.0
: > "$CLI_LOG"
CIRCLE_TAG=v1.6.0-rc.3 bash "$scripts/cli_publish.sh"
[[ $(grep -c -- '--tag rc$' "$CLI_LOG") -eq 4 ]]
[[ $(grep -c '^test$' "$CLI_LOG" || true) -eq 0 ]]
[[ ! -e "$(cat "$CONFIG_PATH_FILE")" ]]
for condition in wrong-tag missing-token denied-auth; do
for condition in wrong-tag missing-token denied-auth core-version core-dependency; do
: > "$CLI_LOG"
write_packages 0.1.0-rc.1 0.1.0-rc.1
case "$condition" in
core-version) write_packages 0.1.0-rc.2 0.1.0-rc.2; if bash "$scripts/cli_publish.sh" >/dev/null 2>&1; then exit 1; fi ;;
core-dependency) write_packages 0.1.0-rc.1 0.1.0-rc.0; if bash "$scripts/cli_publish.sh" >/dev/null 2>&1; then exit 1; fi ;;
wrong-tag) if CIRCLE_TAG=v0.1.0 bash "$scripts/cli_publish.sh" >/dev/null 2>&1; then exit 1; fi ;;
missing-token) if GITHUB_TOKEN='' bash "$scripts/cli_publish.sh" >/dev/null 2>&1; then exit 1; fi ;;
denied-auth) if FAIL_AUTH=true bash "$scripts/cli_publish.sh" >/dev/null 2>&1; then exit 1; fi ;;
@@ -74,4 +91,4 @@ for condition in wrong-tag missing-token denied-auth; do
exit 1
fi
done
printf 'PASS: CLI validation once, drift/test/smoke failures, cleanup, tag/auth checks and three rc publishes (stubbed)\n'
printf 'PASS: CLI validation once, drift/test/smoke failures, cleanup, tag/core-version/auth checks and four rc/latest publishes (stubbed)\n'
+13 -1
View File
@@ -10,7 +10,7 @@ class CliContract(unittest.TestCase):
def test_single_full_validation_and_opt_in_publication(self):
config = yaml.safe_load((ROOT / "src/jobs/cli_verify_publish.yml").read_text())
self.assertIs(config["parameters"]["publish"]["default"], False)
self.assertEqual(config["docker"], [{"image": "cimg/node:22.12"}])
self.assertEqual(config["docker"], [{"image": "cimg/node:22.23"}])
steps = config["steps"]
ci = [i for i, s in enumerate(steps) if isinstance(s, dict) and s.get("run", {}).get("command") == "npm ci"]
verify = [i for i, s in enumerate(steps) if "scripts/cli_verify.sh" in str(s)]
@@ -24,6 +24,18 @@ class CliContract(unittest.TestCase):
cache = next(s["save_cache"] for s in steps if isinstance(s, dict) and "save_cache" in s)
self.assertEqual(cache["paths"], ["~/.npm"])
def test_platform_lane_runs_install_build_test_and_lint(self):
config = yaml.safe_load((ROOT / "src/jobs/cli_platform.yml").read_text())
self.assertEqual(config["executor"], "<< parameters.executor >>")
self.assertEqual(config["parameters"]["executor"]["type"], "executor")
commands = [s["run"]["command"] if isinstance(s["run"], dict) else s["run"]
for s in config["steps"] if isinstance(s, dict) and "run" in s]
self.assertIn("npm ci", commands)
self.assertEqual(commands[-1], "npm run build && npm test && npm run lint")
self.assertNotIn("publish", str(config))
for name in ("cli_macos_arm64", "cli_windows_x64"):
self.assertTrue((ROOT / "src/executors" / (name + ".yml")).exists())
if __name__ == "__main__":
unittest.main()
+131
View File
@@ -0,0 +1,131 @@
"""Discovery covers all current branches and never turns an unknown into a target."""
from pathlib import Path
import sys
import unittest
from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
import discover_enrollment as discovery
def entry(name, archived=False):
return {'nameWithOwner': 'QRun-IO/' + name, 'isArchived': archived}
class DiscoveryTests(unittest.TestCase):
def policy(self):
return {'QRun-IO/example': {'baseline_sha': 'a' * 40, 'required_paths': ['README.md'],
'forbidden_paths': ['.qqq-ci.yml'], 'forbidden_prefixes': ['.circleci/', '.github/workflows/'],
'rationale': 'Approved documentation-only snapshot'}}
def test_approved_snapshot_is_reported_without_enrollment(self):
def request(path):
if '/branches?' in path:
return [{'name': 'main'}, {'name': 'develop'}]
if '/branches/' in path:
return {'commit': {'sha': ('a' if path.endswith('main') else 'b') * 40}}
return {'truncated': False, 'tree': [{'path': 'README.md', 'type': 'blob'}]}
inspect = mock.Mock(side_effect=lambda target, version: target)
with mock.patch.dict(discovery.audit_estate.NO_CI, self.policy(), clear=True):
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual([{'repository': 'QRun-IO/example', 'branch': 'develop'}], plans)
self.assertEqual('approved-no-ci', findings[0]['state'])
self.assertEqual('a' * 40, findings[0]['head'])
inspect.assert_called_once_with(plans[0], '0.8')
def test_no_ci_tree_must_be_complete_and_match_approved_identity(self):
for tree in ({'truncated': True, 'tree': [{'path': 'README.md'}]},
{'truncated': False, 'tree': []},
{'truncated': False, 'tree': [{'path': 'README.md'}, {'path': '.circleci/config.yml'}]}):
def request(path):
if '/branches?' in path:
return [{'name': 'main'}]
if '/branches/' in path:
return {'commit': {'sha': 'a' * 40}}
return tree
inspect = mock.Mock()
with mock.patch.dict(discovery.audit_estate.NO_CI, self.policy(), clear=True):
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual([], plans)
self.assertEqual('unresolved', findings[0]['state'])
inspect.assert_not_called()
def test_old_no_ci_label_never_exempts_executable_or_deployment_source(self):
for source in ('base/deployment.yaml', 'template/pom.xml', 'scripts/customize.py', 'Formula/qctl.rb'):
def request(path):
if '/branches?' in path:
return [{'name': 'main'}]
if '/branches/' in path:
return {'commit': {'sha': 'a' * 40}}
return {'truncated': False, 'tree': [{'path': 'README.md', 'type': 'blob'},
{'path': source, 'type': 'blob'}]}
inspect = mock.Mock(side_effect=ValueError('Source needs centralized validation'))
with mock.patch.dict(discovery.audit_estate.NO_CI, self.policy(), clear=True):
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual([], plans)
self.assertEqual('unresolved', findings[0]['state'])
inspect.assert_called_once()
def test_changed_no_ci_source_is_never_exempted(self):
def request(path):
if '/branches?' in path:
return [{'name': 'main'}]
return {'commit': {'sha': 'b' * 40}}
inspect = mock.Mock(side_effect=ValueError('Unrecognized executable source'))
with mock.patch.dict(discovery.audit_estate.NO_CI, self.policy(), clear=True):
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual([], plans)
self.assertEqual('unresolved', findings[0]['state'])
inspect.assert_called_once()
def test_paginates_branches_and_ignores_historical_releases(self):
requests = []
def request(path):
requests.append(path)
if path.endswith('page=1'):
return [{'name': 'release/' + str(i)} for i in range(99)] + [{'name': 'main'}]
return [{'name': 'develop'}]
inspect = mock.Mock(side_effect=lambda target, version: {**target, 'version': version})
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual(['develop', 'main'], [p['branch'] for p in plans])
self.assertEqual(2, len(requests))
self.assertEqual([], findings)
def test_unknown_branch_and_profile_stay_unresolved_while_other_targets_progress(self):
def inspect(target, version):
if target['repository'].endswith('/custom'):
raise ValueError('Unknown orchestration')
return target
def request(path):
return [{'name': 'feature/new'}] if '/new/' in path else [{'name': 'main'}]
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request,
[entry('custom'), entry('new'), entry('good')])
self.assertEqual([{'repository': 'QRun-IO/good', 'branch': 'main'}], plans)
self.assertEqual(2, len(findings))
self.assertTrue(all(f['state'] == 'unresolved' for f in findings))
def test_archived_and_owner_repositories_are_never_modified(self):
inspect, request = mock.Mock(), mock.Mock()
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request,
[entry('old', True), entry('qqq-orb')])
self.assertEqual([], plans)
self.assertEqual(['archived', 'owner-bootstrap'], [f['state'] for f in findings])
inspect.assert_not_called()
request.assert_not_called()
def test_api_errors_and_duplicate_branches_never_become_empty_success(self):
for result in (ValueError('GitHub read unavailable'), [{'name': 'main'}, {'name': 'main'}]):
request = mock.Mock(side_effect=result) if isinstance(result, Exception) else mock.Mock(return_value=result)
inspect = mock.Mock()
plans, findings = discovery.discover('QRun-IO', '0.8', inspect, request, [entry('example')])
self.assertEqual([], plans)
self.assertEqual('unresolved', findings[0]['state'])
inspect.assert_not_called()
if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
"""Exercise the real version script and Maven install; never publish remotely."""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import xml.etree.ElementTree as ET
ROOT = Path(__file__).resolve().parents[1]
NS = {'m': 'http://maven.apache.org/POM/4.0.0'}
BASH = os.environ.get('TEST_BASH') or shutil.which('bash')
MAVEN = shutil.which('mvn') or shutil.which('mvn.cmd')
def run(args, directory, env=None):
subprocess.run(args, cwd=directory, env=env, check=True, timeout=300)
def project(body):
return '<project xmlns="http://maven.apache.org/POM/4.0.0">\n<modelVersion>4.0.0</modelVersion>\n' + body + '\n</project>\n'
def main():
assert BASH and MAVEN, 'Real Bash, Java and Maven are required'
with tempfile.TemporaryDirectory(prefix='qqq-version-') as temporary:
base = Path(temporary)
for name, version, revision, branch, expected, reactor in (
('literal', '0.4.0-SNAPSHOT', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', False),
('friendly', '${revision}', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', False),
('reactor', '0.4.0-SNAPSHOT', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', True),
('unchanged', '0.3.0-SNAPSHOT', '0.4.0-SNAPSHOT', 'develop', '0.4.0-SNAPSHOT', False),
):
root = base / name
root.mkdir()
modules = '<modules><module>child</module></modules>' if reactor else ''
(root / 'pom.xml').write_text(project(f'''<groupId>example.version</groupId>
<artifactId>{name}</artifactId><version>{version}</version><packaging>pom</packaging>
<properties>
<revision>{revision}</revision>
</properties>
{modules}'''), encoding='utf-8')
if reactor:
(root / 'child').mkdir()
(root / 'child/pom.xml').write_text(project(f'''<parent><groupId>example.version</groupId>
<artifactId>{name}</artifactId><version>{version}</version></parent>
<artifactId>child</artifactId><packaging>pom</packaging>'''), encoding='utf-8')
run(['git', 'init', '-q'], root)
env = dict(os.environ, CIRCLE_BRANCH=branch, CIRCLE_TAG='')
run([BASH, str(ROOT / 'src/scripts/calculate_version.sh')], root, env)
if name == 'friendly':
assert ET.parse(root / 'pom.xml').findtext('m:version', namespaces=NS) == '${revision}'
# Install to a temporary repository so the actual artifact coordinate
# proves the fix, rather than merely checking the revision property.
repository = base / 'repository'
run([MAVEN, '-B', '-ntp', '-Dmaven.repo.local=' + str(repository),
'-Dflatten.mode=resolveCiFriendliesOnly', '-DupdatePomFile=true',
'org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten', 'install'], root)
for artifact in ([name, 'child'] if reactor else [name]):
installed = repository / 'example/version' / artifact / expected / f'{artifact}-{expected}.pom'
assert installed.exists(), installed
pom = ET.parse(installed)
actual = pom.findtext('m:version', namespaces=NS) or pom.findtext('m:parent/m:version', namespaces=NS)
assert actual == expected, (artifact, actual, expected)
print(f'PASS: {name} installed at {expected}', flush=True)
if __name__ == '__main__':
main()
+279
View File
@@ -0,0 +1,279 @@
"""Shared enforcement only adds proven gates and preserves unrelated policy."""
import copy
import base64
import importlib.util
from pathlib import Path
import unittest
import yaml
spec = importlib.util.spec_from_file_location('enforcement', Path(__file__).resolve().parents[1] / 'tools/enforce_orb_checks.py')
enforcement = importlib.util.module_from_spec(spec)
spec.loader.exec_module(enforcement)
def runs():
return [{'id': index, 'name': name, 'app': {'id': 18001}, 'conclusion': 'success'}
for index, name in enumerate(('setup', 'verify'), 1)]
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))))
self.assertFalse(enforcement.same_checks(checks, checks[:-1]))
self.assertFalse(enforcement.same_checks(checks, checks + checks[:1]))
self.assertFalse(enforcement.same_checks(checks, [*enforcement.DESIRED, {'context': 'scanner', 'app_id': 999}]))
def test_preserves_security_gate_and_binds_orb_checks(self):
before = {'required_status_checks': {'strict': False, 'contexts': ['security', 'setup'],
'checks': [{'context': 'security', 'app_id': 15368}, {'context': 'setup', 'app_id': -1}]}}
original = copy.deepcopy(before)
result = enforcement.required_checks(before, runs())
self.assertEqual(original, before)
self.assertEqual(result, {'strict': True, 'checks': [{'context': 'security', 'app_id': 15368}, *enforcement.DESIRED]})
def test_wrong_app_failed_latest_and_missing_checks_reject(self):
cases = [[], [runs()[0]], [dict(run, app={'id': 999}) for run in runs()],
runs() + [dict(runs()[1], id=3, conclusion='failure')]]
for candidate in cases:
with self.subTest(candidate=candidate), self.assertRaises(ValueError):
enforcement.required_checks(None, candidate)
with self.assertRaises(ValueError):
enforcement.required_checks({'required_status_checks': {'checks': [{'context': 'verify', 'app_id': 999}]}}, runs())
def test_existing_unrestricted_contexts_are_retained(self):
result = enforcement.required_checks({'required_status_checks': {'contexts': ['legacy-build']}}, runs())
self.assertIn({'context': 'legacy-build', 'app_id': -1}, result['checks'])
def fixture(self, before):
state = {'before': copy.deepcopy(before), 'head': 'a' * 40, 'writes': []}
def request(path, method='GET', payload=None):
if method != 'GET':
state['writes'].append((method, path, payload))
if method == 'PUT':
state['before'] = {**payload, 'enforce_admins': {'enabled': True}}
elif method == 'PATCH':
state['before']['required_status_checks'] = copy.deepcopy(payload)
elif method == 'POST':
state['before']['enforce_admins'] = {'enabled': True}
return None
if '/rules/' in path:
return []
if path.endswith('/protection'):
return copy.deepcopy(state['before'])
return {'commit': {'sha': state['head']}}
plan = {'repository': 'QRun-IO/example', 'branch': 'develop', 'head': 'a' * 40,
'before': copy.deepcopy(before), 'required_status_checks': enforcement.required_checks(before, runs()), 'changed': True}
return plan, request, state
def test_narrow_updates_preserve_reviews_signatures_and_restrictions(self):
before = {'required_status_checks': {'strict': False, 'checks': []}, 'enforce_admins': {'enabled': False},
'required_signatures': {'enabled': True}, 'required_linear_history': {'enabled': True},
'required_pull_request_reviews': {'required_approving_review_count': 2},
'restrictions': {'users': [{'login': 'owner'}]}}
plan, request, state = self.fixture(before)
enforcement.enforce(plan, request)
self.assertEqual(['PATCH', 'POST'], [write[0] for write in state['writes']])
for key in ('required_signatures', 'required_linear_history', 'required_pull_request_reviews', 'restrictions'):
self.assertEqual(before[key], state['before'][key])
def test_new_protection_and_idempotent_noop(self):
plan, request, state = self.fixture(None)
enforcement.enforce(plan, request)
self.assertEqual('PUT', state['writes'][0][0])
self.assertIsNone(state['before']['required_pull_request_reviews'])
plan['before'] = copy.deepcopy(state['before'])
plan['changed'] = False
state['writes'] = []
enforcement.enforce(plan, request)
self.assertEqual([], state['writes'])
def test_github_may_reorder_required_checks_on_readback(self):
before = {'required_status_checks': {'strict': True, 'checks': [
*enforcement.DESIRED, {'context': 'scanner', 'app_id': 15368}]},
'enforce_admins': {'enabled': False}, 'required_signatures': {'enabled': True}}
plan, request, state = self.fixture(before)
def reordered(path, method='GET', payload=None):
value = request(path, method, payload)
if method == 'PATCH':
state['before']['required_status_checks']['checks'].reverse()
return value
enforcement.enforce(plan, reordered)
self.assertTrue(state['before']['enforce_admins']['enabled'])
self.assertEqual(before['required_signatures'], state['before']['required_signatures'])
def test_head_or_protection_drift_never_mutates(self):
for field, value in [('head', 'b' * 40), ('before', {'unexpected': True})]:
plan, request, state = self.fixture(None)
state[field] = value
with self.assertRaises(ValueError):
enforcement.enforce(plan, request)
self.assertEqual([], state['writes'])
def ruleset_fixture(self):
parameters = {'strict_required_status_checks_policy': False,
'required_status_checks': [{'context': c['context'], 'integration_id': c['app_id']}
for c in enforcement.DESIRED] + [{'context': 'scanner', 'integration_id': 15368}]}
record = {'id': 123, 'enforcement': 'active', 'target': 'branch', 'source_type': 'Repository',
'source': 'QRun-IO/example', 'bypass_actors': [],
'rules': [{'type': 'required_status_checks', 'parameters': parameters}]}
effective = [{'type': 'required_status_checks', 'ruleset_source_type': 'Repository',
'ruleset_source': 'QRun-IO/example', 'ruleset_id': 123, 'parameters': copy.deepcopy(parameters)}]
return record, effective
def test_ruleset_verification_preserves_freshness_scanner_and_never_writes(self):
record, effective = self.ruleset_fixture()
original = copy.deepcopy(record)
def request(path, method='GET', payload=None):
self.assertEqual('GET', method)
if path.endswith('/rulesets/123'):
return copy.deepcopy(record)
if '/rules/branches/' in path:
return copy.deepcopy(effective)
if path.endswith('/protection'):
return None
if '/check-runs?' in path:
return {'check_runs': runs()}
if '/contents/' in path:
data = ({'profile': 'qbit', 'orb_version': '0.8', 'default_branch': 'develop'}
if '/.qqq-ci.yml?' in path else enforcement.standard.canonical_caller('qbit', '0.8'))
return {'encoding': 'base64', 'type': 'file', 'content': base64.b64encode(yaml.safe_dump(data).encode()).decode()}
if '/branches/' in path:
return {'commit': {'sha': 'a' * 40}}
return {'archived': False}
plan = enforcement.inspect('QRun-IO/example', 'develop', '0.8', request)
self.assertFalse(plan['changed'])
self.assertFalse(plan['required_status_checks']['strict'])
self.assertEqual('rulesets', plan['protection_mode'])
enforcement.enforce(plan, request)
self.assertEqual(original, record)
record['bypass_actors'] = [{'actor_type': 'RepositoryRole', 'actor_id': 5}]
with self.assertRaises(ValueError):
enforcement.enforce(plan, request)
def test_inactive_bypass_unbound_and_missing_ruleset_gates_reject(self):
record, effective = self.ruleset_fixture()
cases = [dict(record, enforcement='evaluate'), dict(record, bypass_actors=[{'actor_id': 1}]),
dict(record, rules=[])]
unbound = copy.deepcopy(record)
unbound['rules'][0]['parameters']['required_status_checks'][1]['integration_id'] = None
cases.append(unbound)
for candidate in cases:
with self.subTest(candidate=candidate), self.assertRaises(ValueError):
enforcement.verified_rulesets('QRun-IO/example', effective, lambda path: candidate)
def test_unsupported_ruleset_sources_are_not_inferred_as_protected(self):
record, effective = self.ruleset_fixture()
effective[0]['ruleset_source_type'] = 'Organization'
with self.assertRaises(ValueError):
enforcement.verified_rulesets('QRun-IO/example', effective, lambda path: record)
def test_empty_push_allowlist_gains_ruleset_without_changing_access(self):
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):
if method != 'GET':
self.assertEqual(('POST', 'repos/QRun-IO/example/rulesets'), (method, path))
state['writes'].append(copy.deepcopy(payload))
state['ruleset'] = {**copy.deepcopy(payload), 'id': 123,
'source_type': 'Repository', 'source': 'QRun-IO/example'}
return state['ruleset']
if '/rulesets?' in path:
return []
if path.endswith('/rulesets/123'):
return copy.deepcopy(state['ruleset'])
if '/rules/branches/' in path:
if state['ruleset'] is None:
return []
return [{**state['ruleset']['rules'][0], 'ruleset_source_type': 'Repository',
'ruleset_source': 'QRun-IO/example', 'ruleset_id': 123}]
if path.endswith('/protection'):
return copy.deepcopy(classic)
if '/check-runs?' in path:
return {'check_runs': runs()}
if '/contents/' in path:
data = ({'profile': 'core', 'orb_version': '0.8', 'default_branch': 'develop'}
if '/.qqq-ci.yml?' in path else enforcement.standard.canonical_caller('core', '0.8'))
return {'encoding': 'base64', 'type': 'file', 'content': base64.b64encode(yaml.safe_dump(data).encode()).decode()}
if '/branches/' in path:
return {'commit': {'sha': 'a' * 40}}
return {'archived': False}
plan = enforcement.inspect('QRun-IO/example', 'main', '0.8', request)
self.assertEqual('create-ruleset', plan['protection_mode'])
enforcement.enforce(plan, request)
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.assertEqual(classic, plan['before'])
repeat = enforcement.inspect('QRun-IO/example', 'main', '0.8', request)
self.assertFalse(repeat['changed'])
enforcement.enforce(repeat, request)
self.assertEqual(1, len(state['writes']))
def test_existing_named_ruleset_is_not_overwritten_or_duplicated(self):
before = {'restrictions': {'users': [], 'teams': [], 'apps': []}, 'enforce_admins': {'enabled': False}}
plan, base_request, state = self.fixture(before)
plan['protection_mode'] = 'create-ruleset'
def request(path, method='GET', payload=None):
if '/rulesets?' in path:
return [{'name': 'QQQ automated verification: develop'}]
return base_request(path, method, payload)
with self.assertRaisesRegex(ValueError, 'already exists'):
enforcement.enforce(plan, request)
self.assertEqual([], state['writes'])
if __name__ == '__main__':
unittest.main()
+110
View File
@@ -0,0 +1,110 @@
"""Batch enrollment preserves policy and rejects unsafe or unknown declarations."""
from pathlib import Path
import sys
import tempfile
import unittest
from unittest import mock
import yaml
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
import enroll_consumers as enrollment
class EnrollmentTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
def legacy(self, name):
root = self.root / name
(root / '.circleci').mkdir(parents=True)
config = {'version': 2.1, 'orbs': {'qqq-orb': 'kingsrook/qqq-orb@0.5.0'},
'workflows': {'verify': {'jobs': [{'qqq-orb/mvn_test_only': {}}]}}}
(root / '.circleci/config.yml').write_text(yaml.safe_dump(config), encoding='utf-8')
return {'checkout': str(root), 'default_branch': 'main'}
def canonical(self, profile):
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'])
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')
return target
def test_mixed_fleet_preview_write_and_idempotence(self):
legacy = self.legacy('legacy')
targets = [legacy] + [self.canonical(p) for p in enrollment.rollout.standard.PROFILE_PARAMETERS]
preview = enrollment.enroll(targets, '0.8')
self.assertTrue(all(item['changed'] for item in preview))
self.assertFalse((Path(legacy['checkout']) / '.qqq-ci.yml').exists())
result = enrollment.enroll(targets, '0.8', write=True)
self.assertEqual(1, sum(item['enrollment'] for item in result))
data = yaml.safe_load((Path(legacy['checkout']) / '.qqq-ci.yml').read_text())
self.assertFalse(any(data['publish'].values()))
self.assertEqual('all', data['test_branch_policy'])
self.assertTrue(all(not item['changed'] for item in enrollment.enroll(targets, '0.8', write=True)))
def test_unknown_orchestration_rejects_entire_batch(self):
good, bad = self.legacy('good'), self.legacy('bad')
path = Path(bad['checkout']) / '.circleci/config.yml'
path.write_text(path.read_text() + '\njobs: {custom: {steps: [checkout]}}\n')
original = (Path(good['checkout']) / '.circleci/config.yml').read_bytes()
with self.assertRaises(ValueError):
enrollment.enroll([good, bad], '0.8', write=True)
self.assertEqual(original, (Path(good['checkout']) / '.circleci/config.yml').read_bytes())
self.assertFalse((Path(good['checkout']) / '.qqq-ci.yml').exists())
def test_duplicate_targets_and_wrong_default_reject_before_write(self):
target = self.canonical('core')
for targets in ([target, target], [{**target, 'default_branch': 'develop'}]):
with self.assertRaises(ValueError):
enrollment.enroll(targets, '0.8', write=True)
self.assertEqual('0.7.4', yaml.safe_load((Path(target['checkout']) / '.qqq-ci.yml').read_text())['orb_version'])
def test_invalid_manifest_and_unstable_versions_rejected(self):
target = self.canonical('qbit')
path = Path(target['checkout']) / '.qqq-ci.yml'
path.write_text(path.read_text() + '\nunknown_policy: true\n')
for version in ('0.8', 'dev:snapshot', 'latest', 0.8):
with self.assertRaises(ValueError):
enrollment.enroll([target], version, write=True)
def test_drift_after_preflight_is_not_overwritten(self):
target = self.legacy('drift')
path = Path(target['checkout']) / '.circleci/config.yml'
original_plan = enrollment.plan
def changed_plan(*args):
result = original_plan(*args)
path.write_bytes(b'concurrent edit\n')
return result
with mock.patch.object(enrollment, 'plan', side_effect=changed_plan):
with self.assertRaises(ValueError):
enrollment.enroll([target], '0.8', write=True)
self.assertEqual(b'concurrent edit\n', path.read_bytes())
self.assertFalse((Path(target['checkout']) / '.qqq-ci.yml').exists())
def test_manifest_symlink_is_rejected(self):
target = self.legacy('redirect')
outside = self.root / 'outside.yml'
outside.write_text('untouched\n')
try:
(Path(target['checkout']) / '.qqq-ci.yml').symlink_to(outside)
except OSError as error:
self.skipTest('Symlink creation unavailable: ' + str(error))
with self.assertRaises(ValueError):
enrollment.enroll([target], '0.8', write=True)
self.assertEqual('untouched\n', outside.read_text())
if __name__ == '__main__':
unittest.main()
+103
View File
@@ -0,0 +1,103 @@
"""Automatic completion requires qualified source and preserves normal merge policy."""
import json
from pathlib import Path
import sys
import unittest
from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
import finish_enrollment as finish
class FinishTests(unittest.TestCase):
def setUp(self):
self.plan = {'repository': 'QRun-IO/example', 'branch': 'main', 'head': 'a' * 40,
'profile': 'qbit', 'version': '0.8'}
self.result = {'state': 'existing-pr', 'head': 'b' * 40, 'url': 'https://github.com/QRun-IO/example/pull/1'}
self.pr = {'number': 1, 'state': 'OPEN', 'headRefOid': 'b' * 40,
'baseRefOid': 'a' * 40, 'baseRefName': 'main', 'mergeCommit': None}
def checks(self):
return [{'id': i, 'name': name, 'app': {'id': 18001}, 'status': 'completed', 'conclusion': 'success'}
for i, name in enumerate(('setup', 'verify'))]
def test_all_checks_and_statuses_must_pass_and_gates_must_use_circle_app(self):
checks = self.checks()
checks[1]['app']['id'] = 123
checks.append({'id': 3, 'name': 'scanner', 'app': {'id': 15368}, 'status': 'completed', 'conclusion': 'failure'})
with mock.patch.object(finish.remote, 'api', side_effect=[{'check_runs': checks},
{'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'])
self.assertEqual(1, command.call_count)
self.assertEqual(['gh', 'pr', 'view'], command.call_args.args[0][:3])
def test_stale_base_never_merges_even_when_checks_were_green(self):
self.pr['baseRefOid'] = 'c' * 40
with mock.patch.object(finish.remote, 'verify_submission'), mock.patch.object(finish.remote, 'command', return_value=json.dumps(self.pr)) as command:
self.assertEqual('stale-base', finish.merge_ready(self.plan, self.result)['state'])
self.assertEqual(1, command.call_count)
def test_success_uses_exact_head_normal_merge_and_verifies_result(self):
calls = []
def command(args):
calls.append(args)
if args[2] == 'merge':
return ''
if len(calls) == 1:
return json.dumps(self.pr)
return json.dumps({'state': 'MERGED', 'mergeCommit': {'oid': 'd' * 40}})
def api(path):
if '/branches/' in path:
return {'commit': {'sha': self.plan['head']}}
return {'commit': {'tree': {'sha': 'e' * 40}, 'verification': {'verified': True}}}
with mock.patch.object(finish.remote, 'verify_submission'), mock.patch.object(finish.remote, 'command', side_effect=command), mock.patch.object(finish.remote, 'api', side_effect=api), mock.patch.object(finish, 'qualification', return_value=[]):
result = finish.merge_ready(self.plan, self.result)
self.assertEqual('merged', result['state'])
self.assertEqual(['gh', 'pr', 'merge', '1', '--repo', 'QRun-IO/example', '--squash', '--match-head-commit', 'b' * 40], calls[1])
def test_enforcement_waits_for_current_head_and_uses_shared_preserving_writer(self):
with mock.patch.object(finish.enforcement, 'inspect', side_effect=ValueError('Current branch has no successful verify')), mock.patch.object(finish.enforcement, 'enforce') as enforce:
self.assertEqual('waiting-enforcement', finish.enforce_current(self.plan)['state'])
enforce.assert_not_called()
current = {'head': 'd' * 40, 'changed': True}
with mock.patch.object(finish.enforcement, 'inspect', return_value=current), mock.patch.object(finish.enforcement, 'enforce') as enforce:
self.assertEqual('enforced', finish.enforce_current(self.plan)['state'])
enforce.assert_called_once_with(current)
def test_unknown_gate_profile_never_merges_or_enforces(self):
self.plan['profile'] = 'unknown-profile'
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'])
command.assert_not_called()
inspect.assert_not_called()
def test_merged_tree_mismatch_is_not_reported_as_success(self):
self.pr.update(state='MERGED', mergeCommit={'oid': 'd' * 40})
with mock.patch.object(finish.remote, 'verify_submission'), mock.patch.object(finish.remote, 'command', return_value=json.dumps(self.pr)), mock.patch.object(finish.remote, 'api', side_effect=[
{'commit': {'tree': {'sha': 'e' * 40}}},
{'commit': {'tree': {'sha': 'f' * 40}, 'verification': {'verified': True}}}]):
with self.assertRaises(ValueError):
finish.merge_ready(self.plan, self.result)
if __name__ == '__main__':
unittest.main()
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# Exercise the actual test runner with no server, browser, network or Maven work.
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
mkdir "$scratch/bin"
export RUN_LOG="$scratch/calls"
cat > "$scratch/bin/npm" <<'STUB'
#!/bin/bash
printf 'npm %s\n' "$*" >> "$RUN_LOG"
if [[ "$*" == 'run build' && ${BUILD_FAIL:-0} == 1 ]]; then exit 12; fi
STUB
for tool in mvn dockerize; do
# shellcheck disable=SC2016
printf '#!/bin/bash\nprintf "%s %%s\\n" "$*" >> "$RUN_LOG"\n' "$tool" > "$scratch/bin/$tool"
done
chmod +x "$scratch/bin/"*
export PATH="$scratch/bin:$PATH"
cd "$scratch"
PARAM_BUILD_BEFORE_TEST=false bash "$root/src/scripts/frontend_test_run.sh" >/dev/null
if grep -qx 'npm run build' "$RUN_LOG"; then
echo 'FAIL: combined job rebuilt the already-built React app' >&2; exit 1
fi
grep -q '^mvn .* -B test$' "$RUN_LOG"
echo 'PASS: combined job retains tests without a duplicate build'
: > "$RUN_LOG"
bash "$root/src/scripts/frontend_test_run.sh" >/dev/null
grep -qx 'npm run build' "$RUN_LOG"
grep -q '^mvn .* -B test$' "$RUN_LOG"
: > "$RUN_LOG"
if BUILD_FAIL=1 bash "$root/src/scripts/frontend_test_run.sh" >/dev/null 2>&1; then
echo 'FAIL: required standalone build failure ignored' >&2; exit 1
fi
if grep -q '^mvn ' "$RUN_LOG"; then exit 1; fi
echo 'PASS: standalone command still builds and fails before tests when its build fails'
+2 -1
View File
@@ -35,7 +35,8 @@ class AllReleaseCallerTests(unittest.TestCase):
for name in inputs:
self.assertEqual('${{ inputs.' + name + ' }}', passed[name])
self.assertEqual('string', self.contract['inputs'][name]['type'])
self.assertEqual('github', inputs['smoke_evidence']['default'])
# Migrated consumers no longer own a separate GitHub Smoke workflow.
self.assertEqual('circle', inputs['smoke_evidence']['default'])
self.assertEqual(['github', 'circle'], inputs['smoke_evidence']['options'])
self.assertFalse(inputs['smoke_run_id']['required'])
self.assertFalse(inputs['circle_workflow_id']['required'])
+369 -25
View File
@@ -34,35 +34,64 @@ 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 in ("feature/example", "main", "develop", "staging", "release/1"):
commands = json.loads(build["test_commands"])
commands.insert(0, (ROOT / "tests/fixtures/marketing-worker-input.sh").read_text().rstrip())
commands.insert(5, (ROOT / "tests/fixtures/marketing-link-check.sh").read_text().rstrip())
build["test_commands"] = json.dumps(commands)
build["post-steps"] = [{"store_artifacts": {"path": path, "destination": dest}} for path, dest in [("playwright-report", "playwright-report"), (".lighthouseci", "lighthouse-report")]]
for branch, selected in (("feature/example", "pr-checks"), ("main", "production"),
("develop", "develop"), ("staging", "staging"),
("release/1", "release-candidate"), ("automation/enroll", "pr-checks")):
result = pipeline.marketing_template({}, branch, "")
self.assertEqual(result, baseline)
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.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):
result = pipeline.marketing_template({}, "main", "")
for name, workflow in result["workflows"].items():
for branch in ("main", "develop", "staging", "release/1", "automation/enroll"):
result = pipeline.marketing_template({}, branch, "")
workflow = result["workflows"]["verify"]
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")
self.assertEqual(json.loads(build["test_commands"]), [
(ROOT / "tests/fixtures/marketing-worker-input.sh").read_text().rstrip(),
"npm run lint", "npm run build",
"npx playwright install chromium --with-deps",
"npm run test:chromium", "npm run lighthouse"])
if name == "production":
"npm run test:chromium",
(ROOT / "tests/fixtures/marketing-link-check.sh").read_text().rstrip(), "npm run lighthouse"])
if branch == "main":
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"], {"branches": {"only": "main"}})
self.assertEqual(cd["filters"]["tags"], {"ignore": "/.*/"})
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"], "/")
@@ -70,7 +99,7 @@ class MarketingContractTests(unittest.TestCase):
else:
self.assertNotIn("munitor/update_cd_repo", jobs)
result["workflows"].clear()
self.assertEqual(len(pipeline.marketing_template({}, "main", "")["workflows"]), 5)
self.assertEqual(list(pipeline.marketing_template({}, "main", "")["workflows"]), ["verify"])
def test_marketing_manifest_rejects_custom_policy_and_wrong_branch(self):
data = {"profile": "marketing", "orb_version": "0.7.0", "default_branch": "main"}
@@ -191,15 +220,105 @@ 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"]), [workflow])
self.assertEqual(list(result["workflows"]), ["verify"])
self.assertNotIn("docs_only", result.get("jobs", {}))
job, options = next(iter(result["workflows"][workflow]["jobs"][0].items()))
job, options = next(iter(result["workflows"]["verify"]["jobs"][0].items()))
self.assertEqual(job, "qqq-orb/mvn_test_only" if workflow == "test_only" else "qqq-orb/mvn_publish")
if workflow != "test_only":
self.assertEqual(options["branch_type"], workflow.removeprefix("publish_"))
self.assertEqual(options["context"], ["qqq-maven-registry-credentials"])
self.assertFalse(options["compile_before_verify"])
return options
def test_ci_maintenance_source_and_packed_keep_verification(self):
self.write_manifest(test_branch_policy="feature-no-hotfix", publish={"hotfix": True})
workflow = self.repo / ".github/workflows/release-rc.yml"
workflow.parent.mkdir(parents=True)
workflow.write_text("# central RC caller migration\n", encoding="utf-8")
self.git("add", ".qqq-ci.yml", ".github/workflows/release-rc.yml")
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: adopt central pipeline")
for branch in ("develop", "release/0.1", "hotfix/0.1.1"):
result = self.render(CIRCLE_BRANCH=branch)
options = self.assert_full(result)
self.assertEqual(options["filters"]["branches"], {"ignore": "automation/qbit-rc-pending"})
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH=branch))
schema = self.repo / ".github/workflows/schema-drift.yml"
schema.write_text("# central schema drift caller migration\n", encoding="utf-8")
self.git("add", ".github/workflows/schema-drift.yml")
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: centralize schema drift")
result = self.render(CIRCLE_BRANCH="release/0.1")
self.assert_full(result)
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="release/0.1"))
(self.repo / "App.java").write_text("application change\n", encoding="utf-8")
self.git("add", "App.java")
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: misleading title")
result = self.render(CIRCLE_BRANCH="release/0.1")
self.assert_full(result, "publish_release_candidate")
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="release/0.1"))
def test_defaults_and_options(self):
options = self.assert_full(self.render())
self.assertTrue(options["install_browsers"])
@@ -210,6 +329,15 @@ class PipelineTests(unittest.TestCase):
self.assertTrue(options["check_middleware_api_versions"])
self.assertEqual(options["java_version"], "17")
def test_minor_track_reaches_continuation_without_changing_jobs(self):
expected = self.render()
expected['orbs']['qqq-orb'] = 'kingsrook/qqq-orb@0.7'
self.write_manifest(orb_version='0.7')
self.assertEqual(expected, self.render(QQQ_CI_ORB_VERSION='0.7'))
if PACKED:
self.assertEqual(expected, self.render(packed=True, QQQ_CI_ORB_VERSION='0.7'))
self.render(ok=False, QQQ_CI_ORB_VERSION='0.8')
def test_branch_matrix(self):
for branch, workflow in [("develop", "publish_snapshot"), ("release/1.0", "publish_release_candidate"),
("main", "test_only"), ("hotfix/fix", "test_only"),
@@ -225,6 +353,121 @@ class PipelineTests(unittest.TestCase):
self.write_manifest(publish={"asciidoc": True})
self.assertTrue(self.assert_full(self.render(CIRCLE_BRANCH="develop"), "publish_snapshot")["publish_asciidoc"])
def test_qbit_hotfix_is_opt_in_in_source_and_packed_generator(self):
for packed in ([False, True] if PACKED else [False]):
self.write_manifest()
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="hotfix/1.2.3"))
self.write_manifest(publish={"hotfix": True})
options = self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="hotfix/1.2.3"), "publish_hotfix")
self.assertNotIn("notify_rc_published", options)
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="main"))
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="hotfix/"))
self.write_manifest(publish={"hotfix": "true"})
self.render(packed=packed, CIRCLE_BRANCH="hotfix/1.2.3", ok=False)
def test_qbit_feature_tags_source_and_packed_require_opt_in_and_head(self):
self.git("tag", "publish-test")
for packed in ([False, True] if PACKED else [False]):
self.write_manifest()
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="", CIRCLE_TAG="publish-test"))
self.write_manifest(publish={"feature": True})
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="", CIRCLE_TAG="publish-test"), "publish_feature")
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="feature/example"))
self.assert_full(self.render(packed=packed, CIRCLE_BRANCH="", CIRCLE_TAG="publish-missing"))
self.commit()
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]):
for branch, tag in (("main", ""), ("develop", ""), ("release/1", ""), ("", "v1.0.0")):
result = self.render(packed=packed, CIRCLE_BRANCH=branch, CIRCLE_TAG=tag)
self.assertEqual({"verify": {"jobs": ["validate-policy"]}}, result["workflows"])
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)
for packed in ([False, True] if PACKED else [False]):
self.assert_full(self.render(packed=packed, CIRCLE_TAG=tag))
def test_qbit_rc_completion_is_explicit_and_rc_only(self):
options = self.assert_full(self.render(CIRCLE_BRANCH="release/1"), "publish_release_candidate")
self.assertFalse(options["notify_rc_published"])
@@ -298,8 +541,8 @@ class PipelineTests(unittest.TestCase):
self.change_docs()
for packed in ([False, True] if PACKED else [False]):
result = self.render(packed=packed)
self.assertEqual(list(result["workflows"]), ["test_only"])
options = result["workflows"]["test_only"]["jobs"][0]["docs_only"]
self.assertEqual(list(result["workflows"]), ["verify"])
options = result["workflows"]["verify"]["jobs"][0]["docs_only"]
self.assertEqual(options["name"], "qqq-orb/mvn_test_only")
self.assertIn("git diff --check", result["jobs"]["docs_only"]["steps"][1]["run"]["command"])
(self.repo / "App.java").write_text("changed\n", encoding="utf-8")
@@ -349,9 +592,36 @@ class PipelineTests(unittest.TestCase):
self.change_docs()
self.assertIn("docs_only", self.render()["jobs"])
def test_core_snapshot_publisher_waits_for_all_acceptance_and_analysis(self):
self.write_manifest(profile="core")
result = self.render(CIRCLE_BRANCH="develop")
jobs = {options.get("name", kind): options
for entry in result["workflows"]["verify"]["jobs"]
for kind, options in entry.items()}
def ancestors(name, path=()):
self.assertNotIn(name, path, "Workflow dependencies must be acyclic")
required = jobs[name].get("requires", [])
return set(required).union(*(ancestors(parent, path + (name,)) for parent in required))
self.assertEqual(ancestors("qqq-orb/mvn_publish"), set(jobs) - {"qqq-orb/mvn_publish"})
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="develop"))
def test_core_workflow_graphs_match_baseline(self):
self.write_manifest(profile="core")
baseline = yaml.safe_load((ROOT / "tests/fixtures/core_pipeline_baseline.yml").read_text(encoding="utf-8"))
# Snapshot publication must now wait for the existing sample and analysis gates.
for entry in baseline["workflows"]["publish_snapshot"]["jobs"]:
if "qqq-orb/mvn_publish" in entry:
entry["qqq-orb/mvn_publish"]["requires"] += ["snapshot_sample_coverage_gate", "qqq-orb/static_analysis"]
# Dependency assembly repeats neither analyzer; all acceptance commands stay exact.
assembly_jobs = ("sample_acceptance", "sample_multinode_acceptance", "sample_consumer_acceptance")
for name in assembly_jobs:
assemblies = [step["run"] for step in baseline["jobs"][name]["steps"]
if isinstance(step, dict) and "run" in step
and "-DskipTests clean install" in step["run"]["command"]]
self.assertEqual(len(assemblies), 1, name)
assemblies[0]["command"] = assemblies[0]["command"].replace(
"-DskipTests clean install", "-DskipTests -Dspotbugs.skip=true -Dpmd.skip=true clean install")
self.git("tag", "v1.0.0")
self.git("tag", "publish-fixture")
events = [("feature/test", "", "test_only"), ("develop", "", "publish_snapshot"),
@@ -360,8 +630,8 @@ class PipelineTests(unittest.TestCase):
for branch, tag, workflow in events:
with self.subTest(workflow=workflow):
result = self.render(CIRCLE_BRANCH=branch, CIRCLE_TAG=tag)
self.assertEqual(list(result["workflows"]), [workflow])
actual = result["workflows"][workflow]["jobs"]
self.assertEqual(list(result["workflows"]), ["verify"])
actual = result["workflows"]["verify"]["jobs"]
expected = baseline["workflows"][workflow]["jobs"]
self.assertEqual(len(actual), len(expected))
for before, after in zip(expected, actual):
@@ -422,8 +692,8 @@ class PipelineTests(unittest.TestCase):
with self.subTest(branch=branch, enabled=enabled):
result = self.render(CIRCLE_BRANCH=branch, QQQ_CI_RUN_PLAYWRIGHT=str(enabled).lower())
workflow = base + ("_with_playwright" if enabled else "")
self.assertEqual(list(result["workflows"]), [workflow])
jobs = result["workflows"][workflow]["jobs"]
self.assertEqual(list(result["workflows"]), ["verify"])
jobs = result["workflows"]["verify"]["jobs"]
self.assertEqual(len(jobs), 2 if enabled else 1)
maven = [j for j in jobs if next(iter(j)).startswith("qqq-orb/mvn_frontend_")]
self.assertEqual(len(maven), 1)
@@ -454,8 +724,10 @@ class PipelineTests(unittest.TestCase):
("hotfix/fix", "", "publish_hotfix_release"), ("", "publish-fixture", "publish_feature"),
("", "v1.0.0", "publish_release")]:
result = self.render(CIRCLE_BRANCH=branch, CIRCLE_TAG=tag)
self.assertEqual(list(result["workflows"]), [workflow])
options = next(iter(result["workflows"][workflow]["jobs"][0].values()))
self.assertEqual(list(result["workflows"]), ["verify"])
options = next(iter(result["workflows"]["verify"]["jobs"][0].values()))
expected_kind = {"publish_hotfix_release": "hotfix"}.get(workflow, workflow.removeprefix("publish_"))
self.assertEqual(options["branch_type"], expected_kind)
if profile == "frontend-core":
self.assertTrue(options["npm_trusted_publishing"])
self.assertEqual(options["node_version"], "24.21")
@@ -463,9 +735,9 @@ class PipelineTests(unittest.TestCase):
else:
self.assertEqual(options["context"], ["qqq-maven-registry-credentials"])
main = self.render(CIRCLE_BRANCH="main")
self.assertEqual(list(main["workflows"]), ["publish_release" if profile == "frontend-core" else "test_only"])
self.assertEqual(list(main["workflows"]), ["verify"])
rc_tag = self.render(CIRCLE_BRANCH="", CIRCLE_TAG="v1.0.0-RC.1")
self.assertEqual(list(rc_tag["workflows"]), ["publish_release" if profile == "frontend-core" else "test_only"])
self.assertEqual(list(rc_tag["workflows"]), ["verify"])
def test_profile_specific_options_rejected(self):
for profile, options in [("qbit", {"node_version": "22"}), ("frontend-core", {"browsers": False}),
@@ -494,11 +766,55 @@ class PipelineTests(unittest.TestCase):
if PACKED:
self.assertEqual(self.render(), self.render(packed=True))
def test_cli_platform_lanes_are_opt_in_and_gate_publication(self):
self.write_manifest(profile="cli", default_branch="main")
jobs = self.render(CIRCLE_BRANCH="main")["workflows"]["test_only"]["jobs"]
self.assertEqual([next(iter(job)) for job in jobs], ["qqq-orb/cli_verify_publish"])
for invalid in (["linux-x64"], ["macos-arm64", "macos-arm64"], "macos-arm64", [{"macos-arm64": True}]):
self.write_manifest(profile="cli", default_branch="main", platforms=invalid)
self.render(ok=False)
self.write_manifest(profile="qbit", platforms=["macos-arm64"])
self.render(ok=False)
self.write_manifest(profile="cli", default_branch="main", platforms=["macos-arm64", "windows-x64"])
jobs = self.render(CIRCLE_BRANCH="main")["workflows"]["test_only"]["jobs"]
lanes = [job["qqq-orb/cli_platform"] for job in jobs[:2]]
self.assertEqual([(lane["name"], lane["executor"]) for lane in lanes],
[("cli-macos-arm64", "qqq-orb/cli_macos_arm64"), ("cli-windows-x64", "qqq-orb/cli_windows_x64")])
verify = jobs[2]["qqq-orb/cli_verify_publish"]
self.assertNotIn("requires", verify)
self.assertTrue(all(lane["filters"] == verify["filters"] for lane in lanes))
self.write_manifest(profile="cli", default_branch="main", platforms=["windows-x64"],
publish={"release": True}, publish_context="verified-packages")
self.git("tag", "v1.0.0-RC.2")
jobs = self.render(CIRCLE_TAG="v1.0.0-RC.2")["workflows"]["publish_release"]["jobs"]
self.assertEqual(jobs[0]["qqq-orb/cli_platform"]["name"], "cli-windows-x64")
self.assertNotIn("context", jobs[0]["qqq-orb/cli_platform"])
self.assertEqual(jobs[1]["qqq-orb/cli_verify_publish"]["requires"], ["cli-windows-x64"])
if PACKED:
self.assertEqual(self.render(CIRCLE_TAG="v1.0.0-RC.2"), self.render(packed=True, CIRCLE_TAG="v1.0.0-RC.2"))
def test_voyage_selected_workflow_retains_all_filters_and_actions(self):
self.write_manifest(profile="voyage")
template = json.loads(json.dumps(pipeline.VOYAGE_TEMPLATE).replace("__ORB_VERSION__", "0.7.0"))
for packed in ([False, True] if PACKED else [False]):
for branch, selected in (("main", "release"), ("release/1", "release"),
("develop", "develop"), ("automation/enroll", "pull-request"),
("hotfix/1", "pull-request"), ("release-please--branches--main", "pull-request")):
result = self.render(packed=packed, CIRCLE_BRANCH=branch)
expected = copy.deepcopy(template)
expected["workflows"] = {"verify": expected["workflows"][selected]}
self.assertEqual(expected, result)
jobs = {next(iter(job.values())).get("name", next(iter(job))): next(iter(job.values())) for job in result["workflows"]["verify"]["jobs"]}
if selected == "release":
for name in ("update-cd-repo", "release-please"):
self.assertEqual({"branches": {"only": "main"}}, jobs[name]["filters"])
self.assertNotIn("sonar", json.dumps(result).lower())
def test_voyage_owns_complete_template(self):
self.write_manifest(profile="voyage")
result = self.render(CIRCLE_BRANCH="release/1")
self.assertEqual(len(result["jobs"]), 9)
self.assertEqual(len(result["workflows"]), 3)
self.assertEqual(len(result["jobs"]), 7)
self.assertEqual(list(result["workflows"]), ["verify"])
self.assertNotIn("__ORB_VERSION__", json.dumps(result))
self.assertEqual(result["orbs"]["qqq-orb"], "kingsrook/qqq-orb@0.7.0")
if PACKED:
@@ -519,7 +835,34 @@ 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)
self.assertEqual(result, pipeline.marketing_template({}, "main", ""))
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="main"))
def test_frontend_ci_only_commits_verify_with_packed_parity(self):
for profile, job_name in (("frontend-core", "qqq-orb/node_test_only"),
("frontend-material", "qqq-orb/mvn_frontend_test_only")):
self.write_manifest(profile=profile)
self.git("add", ".qqq-ci.yml")
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: adopt managed orb")
for branch in ("main", "develop"):
with self.subTest(profile=profile, branch=branch):
result = self.render(CIRCLE_BRANCH=branch)
job = result["workflows"]["verify"]["jobs"][0][job_name]
self.assertNotIn("branch_type", job)
self.assertEqual(job["filters"]["branches"], {"ignore": "automation/qbit-rc-pending"})
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH=branch))
def test_nonpublishing_main_ci_change_runs_verification_with_packed_parity(self):
self.write_manifest(default_branch="main", release_on_main=False,
test_branch_policy="feature")
self.git("add", ".qqq-ci.yml")
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: use central pipeline")
result = self.render(CIRCLE_BRANCH="main")
job = result["workflows"]["verify"]["jobs"][0]["qqq-orb/mvn_test_only"]
self.assertEqual(job["filters"]["branches"], {"ignore": "automation/qbit-rc-pending"})
self.assertNotIn("branch_type", job)
if PACKED:
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="main"))
@@ -532,7 +875,8 @@ class PipelineTests(unittest.TestCase):
{"CIRCLE_BRANCH": "integration-example"}):
result = self.render(**environment)
if environment.get("CIRCLE_BRANCH") != "integration-example":
self.assertIn("publish_release", result["workflows"])
self.assertEqual(list(result["workflows"]), ["verify"])
self.assertEqual(result["workflows"]["verify"]["jobs"][0]["qqq-orb/mvn_publish"]["branch_type"], "release")
if PACKED:
self.assertEqual(result, self.render(packed=True, **environment))
+5 -2
View File
@@ -35,13 +35,16 @@ class RcBridgeTests(unittest.TestCase):
data = rc.canonical(SHA)
inputs = data["on"]["workflow_dispatch"]["inputs"]
passed = data["jobs"]["release-rc"]["with"]
self.assertEqual({"dry_run", "finalize", "merge_sha", "bump_sha", "branch", "version"}, set(inputs))
self.assertEqual({"dry_run", "finalize", "recover", "circle_build", "merge_sha", "bump_sha", "branch", "version"}, set(inputs))
self.assertEqual(set(inputs), set(passed))
for name in ("dry_run", "finalize"):
for name in ("dry_run", "finalize", "recover"):
self.assertEqual("boolean", inputs[name]["type"])
self.assertIs(False, inputs[name]["default"])
self.assertEqual("${{ github.event_name == 'repository_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.finalize) }}", passed["finalize"])
self.assertEqual("${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || false }}", passed["dry_run"])
self.assertEqual("${{ github.event_name == 'workflow_dispatch' && inputs.recover || false }}", passed['recover'])
self.assertEqual("${{ github.event_name == 'workflow_dispatch' && inputs.circle_build || '' }}", passed['circle_build'])
self.assertEqual({'description': 'Original Circle publisher build number (recovery only)', 'type': 'string', 'default': ''}, inputs['circle_build'])
for name in ("merge_sha", "bump_sha", "branch", "version"):
self.assertEqual("string", inputs[name]["type"])
self.assertEqual("", inputs[name]["default"])
+28
View File
@@ -0,0 +1,28 @@
"""Capability probes must drain help output while still rejecting missing options."""
from pathlib import Path
import shlex
import subprocess
import unittest
class InstallerTests(unittest.TestCase):
def probe(self, flags):
installer = Path(__file__).resolve().parents[1] / 'tools/install_reconcile_gh.sh'
checks = '\n'.join(line for line in installer.read_text().splitlines()
if line.startswith(('gh api --help', 'gh pr merge --help')))
self.assertEqual(2, len(checks.splitlines()))
producer = ("import signal,sys; signal.signal(signal.SIGPIPE,signal.SIG_DFL); "
f"print({flags!r},flush=True); sys.stdout.write('x'*1048576)")
script = 'set -euo pipefail\ngh() { python3 -c ' + shlex.quote(producer) + '; }\n' + checks
return subprocess.run(['bash', '-c', script], capture_output=True, timeout=10).returncode
def test_large_help_output_does_not_kill_producer(self):
self.assertEqual(0, self.probe('--slurp --match-head-commit'))
def test_missing_required_option_fails(self):
self.assertNotEqual(0, self.probe('--slurp'))
self.assertNotEqual(0, self.probe('--match-head-commit'))
if __name__ == '__main__':
unittest.main()
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""Run the generated link-check shell with controlled server/readiness commands."""
import json
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[1]
class MarketingLinkCheckTests(unittest.TestCase):
def run_check(self, ready, link_status):
template = json.loads((ROOT / 'src/scripts/templates/marketing.json').read_text())
build = template['workflows']['pr-checks']['jobs'][0]['munitor/node_build_and_test']
command = json.loads(build['test_commands'])[5]
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
scripts = {
'npm': '#!/bin/bash\nif [ "$2" = start ]; then echo $$ > "$TEST_ROOT/server.pid"; exec /bin/sleep 30; fi\necho checked > "$TEST_ROOT/checked"\nexit "$LINK_STATUS"\n',
'curl': '#!/bin/bash\nexit "$READY_STATUS"\n',
'sleep': '#!/bin/bash\n/bin/sleep 0.01\n',
}
for name, text in scripts.items():
file = root / name
file.write_text(text)
file.chmod(0o755)
env = {**os.environ, 'PATH': str(root) + ':' + os.environ['PATH'],
'TEST_ROOT': str(root), 'READY_STATUS': str(ready), 'LINK_STATUS': str(link_status)}
result = subprocess.run(['bash', '-c', command], env=env, capture_output=True, timeout=10)
self.assertEqual((root / 'checked').exists(), ready == 0)
pid_file = root / 'server.pid'
if pid_file.exists():
with self.assertRaises(ProcessLookupError):
os.kill(int(pid_file.read_text()), 0)
return result
def test_worker_input_is_generated_before_tests(self):
import yaml
template = json.loads((ROOT / 'src/scripts/templates/marketing.json').read_text())
for workflow in template['workflows'].values():
build = workflow['jobs'][0]['munitor/node_build_and_test']
command = json.loads(build['test_commands'])[0]
with tempfile.TemporaryDirectory() as directory:
subprocess.run(['bash', '-c', command], cwd=directory, check=True)
actual = yaml.safe_load((Path(directory) / '.munitor.yml').read_text())
self.assertEqual(actual, {'pipeline': 'node-webapp', 'node_version': 22,
'docker': {'use_repo_dockerfile': True}})
def test_ready_server_runs_links_and_is_cleaned_up(self):
self.assertEqual(self.run_check(0, 0).returncode, 0)
def test_broken_links_fail_and_server_is_cleaned_up(self):
self.assertEqual(self.run_check(0, 7).returncode, 7)
def test_unready_server_fails_without_running_links(self):
result = self.run_check(1, 0)
self.assertEqual(result.returncode, 1)
self.assertIn(b'did not become ready', result.stderr)
if __name__ == '__main__':
unittest.main()
+3 -1
View File
@@ -43,7 +43,7 @@ class MavenCiContract(unittest.TestCase):
self.assertIs(job["parameters"]["notify_rc_published"]["default"], False)
self.assertIs(read("src/commands/git_operations.yml")["parameters"]["require_pushed_version"]["default"], False)
steps = job["steps"]
deploy = steps.index("mvn_jar_deploy")
deploy = next(i for i, s in enumerate(steps) if isinstance(s, dict) and "mvn_jar_deploy" in s)
pushed = next(i for i, s in enumerate(steps) if "git_operations" in str(s))
dispatch = next(i for i, s in enumerate(steps) if "notify_rc_published.sh" in str(s))
self.assertLess(deploy, pushed)
@@ -57,6 +57,8 @@ class MavenCiContract(unittest.TestCase):
return next(i for i, s in enumerate(steps) if s == name or isinstance(s, dict) and name in s)
self.assertLess(position("mvn_manage_version"), position("mvn_verify"))
self.assertLess(position("mvn_verify"), position("mvn_jar_deploy"))
self.assertEqual(steps[position("mvn_jar_deploy")], {"mvn_jar_deploy": {"skip_verified_analysis": True}})
self.assertIs(read("src/commands/mvn_jar_deploy.yml")["parameters"]["skip_verified_analysis"]["default"], False)
self.assertTrue(any("check_middleware_api_versions" in str(s) for s in steps[position("mvn_verify") + 1:position("mvn_jar_deploy")]))
deploy = (ROOT / "src/scripts/mvn_jar_deploy.sh").read_text()
self.assertIn("-P release", deploy)
+49
View File
@@ -6,6 +6,7 @@ scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
mkdir "$scratch/bin"
export INSTALL_LOG="$scratch/install.log"
export APT_CONFIG_CAPTURE="$scratch/apt.conf"
export BASH_ENV="$scratch/bash-env"
export QQQ_MAVEN_BIN_DIR="$scratch/maven-bin"
: > "$BASH_ENV"
@@ -14,6 +15,29 @@ cat > "$scratch/bin/sudo" <<'STUB'
printf '%s\n' "$*" >> "$INSTALL_LOG"
if [[ "$*" == *apt-get* ]]; then
[[ "$1" == env && "$2" == DEBIAN_FRONTEND=noninteractive && "$3" == NEEDRESTART_MODE=l ]] || exit 90
[[ -f "$APT_CONFIG_CAPTURE" ]] && grep -qx 'Acquire::Retries "3";' "$APT_CONFIG_CAPTURE" || exit 91
[[ ${APT_FAIL:-0} == 0 ]] || exit "$APT_FAIL"
if [[ "$*" == *'apt-get update'* ]]; then
updates=$(grep -c 'apt-get update' "$INSTALL_LOG")
if [[ $updates -eq 1 ]]; then
# An unavailable image PPA must not participate in base-tool setup.
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || exit 100
[[ "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list'* || "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list.d/ubuntu.sources'* ]] || exit 93
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 92
[[ ${UBUNTU_UPDATE_FAIL:-0} == 0 ]] || exit "$UBUNTU_UPDATE_FAIL"
fi
if [[ $updates -eq 2 ]]; then
# Model a PPA outage after the initial base-package installation. Only
# the new signed repository may be contacted; existing indexes survive.
[[ "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list.d/adoptium.list'* ]] || exit 100
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || exit 100
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 92
[[ ${TEMURIN_UPDATE_FAIL:-0} == 0 ]] || exit "$TEMURIN_UPDATE_FAIL"
fi
fi
fi
if [[ "$1" == tee && "$2" == /etc/apt/apt.conf.d/80-qqq-download-retries ]]; then
cat > "$APT_CONFIG_CAPTURE"; exit 0
fi
if [[ "$1" == tee || "$1" == gpg || "$1" == -E ]]; then cat >/dev/null; fi
STUB
@@ -32,9 +56,29 @@ grep -q 'tee /etc/needrestart/conf.d/99-qqq-ci.conf' "$INSTALL_LOG"
grep -q 'export JAVA_HOME=' "$BASH_ENV"
: > "$INSTALL_LOG"
: > "$BASH_ENV"
rm "$APT_CONFIG_CAPTURE"
PARAM_INSTALL_NODE=true bash "$script_dir/install_java.sh" >/dev/null 2>&1
[[ $(grep -c 'apt-get' "$INSTALL_LOG") -eq 5 ]]
grep -q 'apt-get install -y -qq nodejs' "$INSTALL_LOG"
# An outage of the required repository must still stop before Java installation.
: > "$INSTALL_LOG"
if UBUNTU_UPDATE_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
echo 'required Ubuntu repository failure accepted' >&2; exit 1
else
[[ $? -eq 100 ]]
fi
if grep -q 'apt-get install' "$INSTALL_LOG"; then
echo 'package installation continued after Ubuntu repository failure' >&2; exit 1
fi
: > "$INSTALL_LOG"
if TEMURIN_UPDATE_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
echo 'required Temurin repository failure accepted' >&2; exit 1
else
[[ $? -eq 100 ]]
fi
if grep -q 'apt-get install -y -qq temurin-' "$INSTALL_LOG"; then
echo 'Java installation continued after repository failure' >&2; exit 1
fi
# Execute the actual generated selector. Arguments containing spaces stay intact.
export SELECTOR_LOG="$scratch/selector.log"
cat > "$scratch/bin/mvn" <<'NATIVE'
@@ -82,4 +126,9 @@ if PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1;
echo 'invalid native Maven accepted' >&2; exit 1
fi
unset -f mvn
if APT_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
echo 'persistent apt failure accepted' >&2; exit 1
else
[[ $? -eq 100 ]]
fi
printf 'PASS: unattended installation and native/executable/nonexecutable wrapper selection\n'
+16 -1
View File
@@ -56,13 +56,28 @@ org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten
deploy
EOF
diff -u "$test_dir/expected-args" "$test_dir/mvn-args"
# The verified publishing job skips only duplicate analysis. Every signing,
# flattening and publication argument must remain identical to the default.
for mode in true 1 false 0; do
PATH="$test_dir/bin:$PATH" TEST_MVN_ARGS="$test_dir/verified-args" \
GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase QQQ_SKIP_VERIFIED_ANALYSIS="$mode" \
bash "$test_dir/deploy.sh" > "$test_dir/verified-output" 2>&1
if [[ "$mode" == true || "$mode" == 1 ]]; then
grep -Fxq -- '-Dspotbugs.skip=true' "$test_dir/verified-args"
grep -Fxq -- '-Dpmd.skip=true' "$test_dir/verified-args"
grep -Fxv -e '-Dspotbugs.skip=true' -e '-Dpmd.skip=true' "$test_dir/verified-args" > "$test_dir/verified-common-args"
diff -u "$test_dir/expected-args" "$test_dir/verified-common-args"
else
diff -u "$test_dir/expected-args" "$test_dir/verified-args"
fi
done
# A Central validation failure or publication timeout must fail this wrapper.
cat > "$test_dir/bin/mvn" <<'EOF'
#!/bin/bash
exit 42
EOF
set +e
PATH="$test_dir/bin:$PATH" GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase \
PATH="$test_dir/bin:$PATH" GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase QQQ_SKIP_VERIFIED_ANALYSIS=true \
bash "$test_dir/deploy.sh" > "$test_dir/failure-output" 2>&1
status=$?
set -e
+65 -2
View File
@@ -2,7 +2,10 @@
import contextlib
import io
import json
import os
from pathlib import Path, PurePosixPath
import subprocess
import tempfile
import unittest
from unittest import mock
@@ -17,17 +20,77 @@ class MobilePolicyTests(unittest.TestCase):
after = json.loads((ROOT / "src/scripts/templates/android.json").read_text())
self.assertEqual(after["orbs"], before["orbs"])
self.assertEqual(set(after["jobs"]), {"unit-test", "android-test", "maven-deploy"})
for name, job in after["jobs"].items():
self.assertEqual(job, before["jobs"][name])
for name in ("unit-test", "android-test"):
self.assertEqual(after["jobs"][name], before["jobs"][name])
self.assertEqual(after["jobs"]["maven-deploy"]["executor"], before["jobs"]["maven-deploy"]["executor"])
self.assertEqual(after["jobs"]["maven-deploy"]["steps"][:2], before["jobs"]["maven-deploy"]["steps"][:2])
entries = after["workflows"]["test-and-build"]["jobs"]
self.assertEqual(entries[0], "unit-test")
self.assertEqual(entries[1], {"android-test": {}})
publish = entries[2]["maven-deploy"]
self.assertEqual(publish["context"], ["qqq-maven-registry-credentials"])
self.assertEqual(publish["requires"], ["unit-test", "android-test"])
self.assertEqual(publish["filters"], {"branches": {"only": "main"}})
# No new dormant Firebase benchmark or nonexistent app module build.
self.assertNotIn("benchmarks-ftl", after["jobs"])
def test_android_publication_uses_shared_credentials_without_persisting_them(self):
data = json.loads((ROOT / "src/scripts/templates/android.json").read_text())
steps = data["jobs"]["maven-deploy"]["steps"]
self.assertEqual(len(steps), 3)
raw = steps[2]["run"]["command"]
self.assertIn("python3 \\<<'PYTHON'", raw)
command = raw.replace("\\<<", "<<")
with tempfile.TemporaryDirectory() as folder:
root = Path(folder)
runner = root / "gradlew"
runner.write_text('''#!/bin/bash
set -eu
test "$1" = --console=plain
test "$2" = publishMavenPublicationToGithubQqqMavenRegistryRepository
test "$ORG_GRADLE_PROJECT_githubQqqMavenRegistryUsername" = fixture-user
test "$ORG_GRADLE_PROJECT_githubQqqMavenRegistryPassword" = fixture-password
touch invoked
''')
runner.chmod(0o755)
python = root / "python3"
python.write_text("#!/bin/bash\ncat >/dev/null\n[[ ${DENY_ACCESS:-0} == 0 ]] || exit 1\necho fixture-user\n")
python.chmod(0o755)
base = {**os.environ, "GITHUB_TOKEN": "fixture-password",
"PATH": str(root) + os.pathsep + os.environ["PATH"]}
for mode in ("missing", "denied", "success"):
env = dict(base)
if mode == "missing":
env.pop("GITHUB_TOKEN")
elif mode == "denied":
env["DENY_ACCESS"] = "1"
result = subprocess.run(["bash", "-c", command], cwd=root, env=env, capture_output=True, text=True)
self.assertEqual(result.returncode == 0, mode == "success")
self.assertEqual((root / "invoked").exists(), mode == "success")
self.assertFalse((root / "gradle.properties").exists())
self.assertNotIn("fixture-password", result.stdout + result.stderr)
def test_android_registry_preflight_fails_closed(self):
data = json.loads((ROOT / "src/scripts/templates/android.json").read_text())
command = data["jobs"]["maven-deploy"]["steps"][2]["run"]["command"]
script = command.split("<<'PYTHON'\n", 1)[1].split("\nPYTHON", 1)[0]
for identity, permissions, allowed in (({"login": "fixture-user"}, {"push": True}, True),
({"login": "fixture-user"}, {"push": False}, False),
({}, {"push": True}, False)):
opener = mock.Mock()
responses = [json.dumps(identity), json.dumps({"permissions": permissions})]
opener.open.side_effect = lambda *args, **kwargs: io.StringIO(responses.pop(0))
with mock.patch("urllib.request.build_opener", return_value=opener), \
mock.patch.dict(os.environ, {"GITHUB_TOKEN": "fixture-password"}), \
contextlib.redirect_stdout(io.StringIO()) as output:
if allowed:
exec(compile(script, "registry-preflight", "exec"), {})
self.assertEqual(output.getvalue().strip(), "fixture-user")
else:
with self.assertRaises(SystemExit):
exec(compile(script, "registry-preflight", "exec"), {})
self.assertNotIn("fixture-password", output.getvalue())
def test_policy_stays_small_and_validates_actual_pattern_content(self):
data = json.loads((ROOT / "src/scripts/templates/mcp-policy.json").read_text())
job = data["jobs"]["validate-patterns"]
+112
View File
@@ -0,0 +1,112 @@
"""Native GitOps discovery must prove shared ownership without adding Circle jobs."""
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_gitops_gates as gitops
import reconcile_enrollment as remote
import enforce_orb_checks as enforcement
import finish_enrollment as finish
class GitOpsTests(unittest.TestCase):
def setUp(self):
self.pin, self.head = 'a' * 40, 'b' * 40
self.repo = 'QRun-IO/voyage-cd'
self.caller = gitops.bridge.canonical('gitops', self.pin)
self.signed, self.worker_drift, self.truncated = True, False, False
self.paths = ['.github/workflows/validate.yml', 'base/kustomization.yaml']
self.runs = [{'id': 1, 'name': 'gitops / validate', 'app': {'id': 15368},
'status': 'completed', 'conclusion': 'success'}]
self.before = {'required_status_checks': {'strict': True, 'checks': gitops.gates()},
'enforce_admins': {'enabled': True}}
def request(self, path, method='GET', payload=None):
self.assertEqual(method, 'GET')
if '/contents/' in path:
self.assertNotIn('.circleci/', path)
if '/QRun-IO/qqq-orb/' in path:
raw = (ROOT / '.github/workflows/gitops.yml').read_text() + ('# drift' if self.worker_drift else '')
else:
raw = yaml.safe_dump(self.caller, 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} 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_discovery_returns_unchanged_native_plan_without_circle_reads_or_writes(self):
for repo in sorted(gitops.REPOSITORIES):
with mock.patch.object(remote, 'api', side_effect=self.request):
plan = remote.inspect({'repository': repo, 'branch': 'main'}, '0.8')
self.assertEqual(plan['profile'], 'native-gitops')
self.assertFalse(plan['changed'])
self.assertEqual(plan['worker_pin'], self.pin)
self.assertEqual(remote.apply(plan), {'state': 'unchanged'})
self.assertEqual(finish.merge_ready(plan, {'state': 'unchanged'}), {'state': 'unchanged'})
def test_enforcement_retains_bound_native_gate(self):
plan = enforcement.inspect(self.repo, 'main', '0.8', self.request)
self.assertFalse(plan['changed'])
self.assertEqual(plan['gates'], gitops.gates())
enforcement.enforce(plan, self.request)
def test_wrong_app_and_failed_gate_reject(self):
for field, value in [('app', {'id': 18001}), ('conclusion', 'failure')]:
original = copy.deepcopy(self.runs)
self.runs[0][field] = value
with self.assertRaises(ValueError):
enforcement.inspect(self.repo, 'main', '0.8', self.request)
self.runs = original
def test_noncanonical_or_unsigned_or_changed_worker_rejects(self):
self.caller['jobs']['gitops']['uses'] = 'other/repo/workflow.yml@' + self.pin
with self.assertRaisesRegex(ValueError, 'canonical'):
gitops.validate(self.repo, self.head, 'main', self.request, yaml.safe_load)
self.caller = gitops.bridge.canonical('gitops', self.pin)
self.signed = False
with self.assertRaisesRegex(ValueError, 'not verified'):
gitops.validate(self.repo, self.head, 'main', self.request, yaml.safe_load)
self.signed, self.worker_drift = True, True
with self.assertRaisesRegex(ValueError, 'supported contract'):
gitops.validate(self.repo, self.head, 'main', self.request, yaml.safe_load)
def test_additional_orchestration_and_incomplete_inventory_reject(self):
for path in ['.circleci/config.yml', '.github/workflows/custom.yaml']:
self.paths.append(path)
with self.assertRaisesRegex(ValueError, 'additional orchestration'):
gitops.validate(self.repo, self.head, 'main', self.request, yaml.safe_load)
self.paths.pop()
self.truncated = True
with self.assertRaisesRegex(ValueError, 'complete source tree'):
gitops.validate(self.repo, self.head, 'main', self.request, yaml.safe_load)
def test_unknown_repository_and_develop_are_not_exempted(self):
for repo, branch in [('QRun-IO/unknown', 'main'), (self.repo, 'develop')]:
with self.assertRaises(ValueError):
gitops.validate(repo, self.head, branch, self.request, yaml.safe_load)
def test_native_pr_qualification(self):
with mock.patch.object(finish.remote, 'api', side_effect=self.request):
self.assertEqual(finish.qualification(self.repo, self.head, 'native-gitops'), [])
self.runs = []
self.assertEqual(finish.qualification(self.repo, self.head, 'native-gitops'), ['gitops / validate'])
if __name__ == '__main__':
unittest.main()
+108
View File
@@ -0,0 +1,108 @@
"""Recognize native ownership without duplicate CI or weaker PR protections."""
import base64
import copy
from pathlib import Path
import sys
import unittest
from unittest import mock
import yaml
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools'))
import enforce_orb_checks as enforcement
import finish_enrollment as finish
class NativeTests(unittest.TestCase):
def setUp(self):
self.pin = 'a' * 40
self.head = 'b' * 40
self.caller = enforcement.native.bridge.canonical_next(self.pin)
self.signed = True
self.worker_drift = False
self.runs = [{'id': i, 'name': gate['context'], 'app': {'id': 15368},
'status': 'completed', 'conclusion': 'success'}
for i, gate in enumerate(enforcement.native.gates())]
self.record = {'id': 1, 'enforcement': 'active', 'target': 'branch',
'source_type': 'Repository', 'source': 'QRun-IO/example', 'bypass_actors': [],
'rules': [{'type': 'required_status_checks', 'parameters': {
'strict_required_status_checks_policy': False,
'required_status_checks': [{'context': g['context'], 'integration_id': g['app_id']}
for g in enforcement.gates('frontend-next')]}}]}
def request(self, path, method='GET', payload=None):
self.assertEqual('GET', method, 'Recognition must not mutate correct protections')
if '/contents/' in path:
if '.github/workflows/ci.yml?' in path:
raw = yaml.safe_dump(self.caller)
elif 'repos/QRun-IO/qqq-orb/' in path:
name = path.split('/contents/')[1].split('?')[0]
raw = (ROOT / name).read_text(encoding='utf-8') + ('# drift' if self.worker_drift else '')
else:
data = ({'profile': 'frontend-next', 'orb_version': '0.8', 'default_branch': 'main'}
if '/.qqq-ci.yml?' in path else enforcement.standard.canonical_caller('frontend-next', '0.8'))
raw = yaml.safe_dump(data)
return {'type': 'file', 'encoding': 'base64', 'content': base64.b64encode(raw.encode()).decode()}
if path.endswith('/commits/' + self.pin):
return {'commit': {'verification': {'verified': self.signed}}}
if '/check-runs?' in path:
return {'check_runs': copy.deepcopy(self.runs)}
if '/status?' in path:
return {'statuses': []}
if '/rulesets/1' in path:
return copy.deepcopy(self.record)
if '/rules/branches/' in path:
return [{'type': 'required_status_checks', 'ruleset_source_type': 'Repository',
'ruleset_source': 'QRun-IO/example', 'ruleset_id': 1}]
if path.endswith('/protection'):
return None
if '/branches/' in path:
return {'commit': {'sha': self.head}}
return {'archived': False}
def test_main_recognition_retains_all_eight_pr_gates_without_image_run(self):
plan = enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
self.assertFalse(plan['changed'])
self.assertEqual('rulesets', plan['protection_mode'])
self.assertEqual(enforcement.gates('frontend-next'), plan['required_status_checks']['checks'])
self.assertEqual(8, len(plan['gates']))
enforcement.enforce(plan, self.request)
def test_caller_drift_unsigned_and_changed_workers_fail_closed(self):
self.caller['jobs']['ci']['uses'] = 'untrusted/repo/ci.yml@' + self.pin
with self.assertRaisesRegex(ValueError, 'canonical'):
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
self.caller = enforcement.native.bridge.canonical_next(self.pin)
self.signed = False
with self.assertRaisesRegex(ValueError, 'not verified'):
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
self.signed = True
self.worker_drift = True
with self.assertRaisesRegex(ValueError, 'supported contract'):
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
def test_missing_main_gate_wrong_app_and_missing_pr_protection_reject(self):
self.runs[0]['app']['id'] = 18001
with self.assertRaises(ValueError):
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
self.runs[0]['app']['id'] = 15368
self.record['rules'][0]['parameters']['required_status_checks'].pop()
with self.assertRaisesRegex(ValueError, 'missing app-bound gate'):
enforcement.inspect('QRun-IO/example', 'main', '0.8', self.request)
def test_pr_qualification_requires_both_image_architectures(self):
with mock.patch.object(finish.remote, 'api', side_effect=self.request):
missing = finish.qualification('QRun-IO/example', self.head, 'frontend-next')
self.assertEqual(sorted(enforcement.native.PR_GATES[-2:]), missing)
for i, name in enumerate(enforcement.native.PR_GATES[-2:], 20):
self.runs.append({'id': i, 'name': name, 'app': {'id': 15368},
'status': 'completed', 'conclusion': 'success'})
self.assertEqual([], finish.qualification('QRun-IO/example', self.head, 'frontend-next'))
def test_develop_has_no_native_push_contract(self):
with self.assertRaisesRegex(ValueError, 'main only'):
enforcement.native.validate('QRun-IO/example', self.head, 'develop', self.request, enforcement.standard.load_yaml)
if __name__ == '__main__':
unittest.main()
+149
View File
@@ -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()
+34
View File
@@ -76,6 +76,7 @@ sys.exit(subprocess.run([os.environ['TEST_REAL_NODE'], *sys.argv[1:]], input=sou
def test_tags_and_legacy_authentication(self):
for trusted in [True, False]:
for version, tag in [('1.0.0-RC.1', 'rc'), ('1.0.0-SNAPSHOT', 'snapshot'),
('1.0.0-SNAPSHOT.101', 'snapshot'),
('1.0.0-alpha.1', 'next'), ('1.0.0-beta.1', 'next'), ('1.0.0', 'latest')]:
with self.subTest(trusted=trusted, version=version):
result, args, oidc = self.run_publish(version, trusted)
@@ -133,5 +134,38 @@ sys.exit(subprocess.run([os.environ['TEST_REAL_NODE'], *sys.argv[1:]], input=sou
self.assertNotIn('Successfully published', result.stdout)
class SnapshotVersionTests(unittest.TestCase):
def test_snapshot_jobs_keep_source_head_and_publish_distinct_versions(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
def git(*args):
return subprocess.check_output(['git', *args], cwd=root, text=True).strip()
git('init', '-q', '-b', 'develop')
source = '{"name": "snapshot-test", "version": "0.40.27-SNAPSHOT"}\n'
package = root / 'package.json'
package.write_text(source)
git('add', 'package.json')
git('-c', 'user.name=Test', '-c', 'user.email=test@example.invalid',
'-c', 'commit.gpgsign=false', 'commit', '-qm', 'initial source')
head = git('rev-parse', 'HEAD')
for number in ('101', '102'):
package.write_text(source)
env = dict(os.environ, CIRCLE_BUILD_NUM=number, BRANCH_TYPE='snapshot')
subprocess.run(['bash', str(SCRIPT.parent / 'sync-npm-version.sh')],
cwd=root, env=env, check=True, capture_output=True)
self.assertEqual(json.loads(package.read_text())['version'], '0.40.28-SNAPSHOT.' + number)
subprocess.run(['bash', str(SCRIPT.parent / 'node_version_commit.sh')],
cwd=root, env=env, check=True, capture_output=True)
self.assertEqual(git('rev-parse', 'HEAD'), head)
self.assertEqual(git('diff', '--cached', '--name-only'), '')
for number in ('', '0', '01', '-1', 'abc'):
package.write_text(source)
result = subprocess.run(['bash', str(SCRIPT.parent / 'sync-npm-version.sh')],
cwd=root, env=dict(os.environ, CIRCLE_BUILD_NUM=number),
capture_output=True)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(package.read_text(), source)
if __name__ == '__main__':
unittest.main()
+58
View File
@@ -0,0 +1,58 @@
import json
import os
from pathlib import Path
import subprocess
import sys
import tempfile
import unittest
import yaml
ROOT = Path(__file__).parents[1]
class BranchLanguages(unittest.TestCase):
def select(self, tracked, untracked=()):
worker = yaml.safe_load((ROOT / '.github/workflows/qbit-codeql.yml').read_text())
script = next(s['run'] for s in worker['jobs']['analyze']['steps'] if s.get('id') == 'languages')
script = script.split("python3 <<'PY'\n", 1)[1].rsplit('\nPY', 1)[0]
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
subprocess.run(['git', 'init', '-q', directory], check=True)
for name in (*tracked, *untracked):
path = root / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text('fixture')
if tracked:
subprocess.run(['git', 'add', '--', *tracked], cwd=root, check=True)
output = root / 'outputs'
result = subprocess.run([sys.executable, '-c', script], cwd=root,
env={**os.environ, 'GITHUB_OUTPUT': str(output)}, capture_output=True, text=True)
return result, output.read_text() if output.exists() else ''
def test_historical_java_branch_does_not_scan_absent_actions(self):
result, output = self.select(['src/Example.java'])
self.assertEqual(0, result.returncode, result.stderr)
self.assertIn('languages=java-kotlin\n', output)
self.assertIn('build-mode=none\n', output)
def test_current_branch_preserves_all_present_supported_languages(self):
result, output = self.select(['src/Example.java', '.github/workflows/ci.yaml', 'web/app.tsx', 'tools/check.py'])
self.assertEqual(0, result.returncode, result.stderr)
self.assertIn('languages=java-kotlin,javascript-typescript,python,actions\n', output)
def test_kotlin_requires_a_build(self):
result, output = self.select(['src/Example.kt', '.github/workflows/ci.yml'])
self.assertEqual(0, result.returncode, result.stderr)
self.assertIn('build-mode=autobuild\n', output)
def test_untracked_files_do_not_select_languages(self):
result, output = self.select(['src/Example.java'], ['web/generated.js', '.github/workflows/untracked.yml'])
self.assertEqual(0, result.returncode, result.stderr)
self.assertIn('languages=java-kotlin\n', output)
def test_placeholder_fails_explicitly(self):
result, output = self.select(['README.md'])
self.assertNotEqual(0, result.returncode)
self.assertIn('No supported source', result.stderr)
if __name__ == '__main__':
unittest.main()
+73
View File
@@ -0,0 +1,73 @@
"""Preserve Workflows' audited publish-tag contract without broadening branches."""
import unittest
from unittest import mock
from pathlib import Path
import yaml
from test_qbit_hotfix_profile import load, migration, pipeline, selects, ROOT
standard = load('standard', 'src/scripts/validate_standard.py')
class FeaturePublicationTests(unittest.TestCase):
def config(self, manifest):
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
return pipeline.load_manifest('unused', '0.7.16')
def test_audited_event_selection_matches_legacy(self):
legacy = yaml.safe_load((ROOT / 'tests/fixtures/qbit-feature-publication.yml').read_text())
manifest = migration.infer_manifest(legacy, '0.7.16', 'main')
self.assertTrue(manifest['publish']['feature'])
caller = migration.canonical_caller('0.7.16', manifest['release_tag_policy'], True)
standard.validate(yaml.safe_dump(caller), yaml.safe_dump(manifest), '0.7.16')
setup = caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']
cases = [(branch, '') for branch in ['main', 'develop', 'feature/example', 'release/0.3.0', 'hotfix/0.3.1', 'integration-test']]
cases += [('', tag) for tag in ['publish', 'publish-example', 'v1.2.3', 'v1.2.3-RC.1', 'other']]
for branch, tag in cases:
with self.subTest(branch=branch, tag=tag):
expected = sorted((job, args.get('branch_type')) for workflow in legacy['workflows'].values()
for entry in workflow['jobs'] for job, args in entry.items()
if selects(args.get('filters', {}), branch, tag))
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
rendered = pipeline.qbit_template(self.config(manifest), branch, tag)
actual = sorted((job, args.get('branch_type')) for workflow in rendered['workflows'].values()
for entry in workflow['jobs'] for job, args in entry.items()
if selects(args.get('filters', {}), branch, tag))
if not selects(setup['filters'], branch, tag):
actual = []
self.assertEqual(expected, actual)
def test_feature_is_opt_in_and_requires_exact_tag_head(self):
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main'}
self.assertFalse(self.config(manifest)['publish']['feature'])
manifest['publish'] = {'feature': True}
for tagged in [None, b'wrong-head\n']:
def git(*args):
return b'head\n' if args == ('rev-parse', 'HEAD') else tagged
with self.subTest(tagged=tagged), mock.patch.object(pipeline, 'git', side_effect=git):
rendered = pipeline.qbit_template(self.config(manifest), '', 'publish-test')
self.assertIn('qqq-orb/mvn_test_only', rendered['workflows']['test_only']['jobs'][0])
def test_feature_tag_recovery_checks_fetched_commit(self):
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main', 'publish': {'feature': True}}
with mock.patch.object(pipeline, 'git', side_effect=[None, b'', b'head\n', b'head\n']):
rendered = pipeline.qbit_template(self.config(manifest), '', 'publish-test')
self.assertEqual('feature', rendered['workflows']['publish_feature']['jobs'][0]['qqq-orb/mvn_publish']['branch_type'])
def test_setup_preserves_release_policy_and_rejects_drift(self):
for policy in ['stable', 'v-prefix', 'none']:
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main',
'release_tag_policy': policy, 'publish': {'feature': True}}
caller = migration.canonical_caller('0.7.16', policy, True)
standard.validate(yaml.safe_dump(caller), yaml.safe_dump(manifest), '0.7.16')
self.assertEqual(caller, standard.canonical_caller('qbit', '0.7.16', release_tag_policy=policy, publish_feature=True))
with self.assertRaises(standard.StandardError):
standard.validate(yaml.safe_dump(migration.canonical_caller('0.7.16', policy)), yaml.safe_dump(manifest), '0.7.16')
def test_unrecognized_feature_branch_filters_are_rejected(self):
for branches in [{'only': ['/feature/.*/']}, {'only': ['main']}, {'ignore': '/.*/'}]:
with self.subTest(branches=branches), self.assertRaises(ValueError):
migration.publication_filters('feature', {'branches': branches, 'tags': {'only': ['/publish.*/']}})
if __name__ == '__main__':
unittest.main()
+73
View File
@@ -0,0 +1,73 @@
"""Preserve the audited main-branch hotfix contracts in the shared profile."""
import importlib.util
import json
from pathlib import Path
import re
import unittest
from unittest import mock
import yaml
ROOT = Path(__file__).resolve().parents[1]
def load(name, path):
spec = importlib.util.spec_from_file_location(name, ROOT / path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
migration = load('migration', 'tools/standardize_qbit.py')
pipeline = load('pipeline', 'src/scripts/generate_pipeline.py')
def selects(filters, branch, tag):
selector = filters.get('tags' if tag else 'branches', {})
if tag and not selector:
return False
def matches(patterns):
patterns = patterns if isinstance(patterns, list) else [patterns]
return any(re.fullmatch(p[1:-1], tag or branch, flags=re.ASCII) is not None if p.startswith('/') and p.endswith('/') else p == (tag or branch) for p in patterns)
return ('only' not in selector or matches(selector['only'])) and ('ignore' not in selector or not matches(selector['ignore']))
class HotfixMigrationTests(unittest.TestCase):
def test_audited_main_job_selection_is_preserved(self):
fixtures = json.loads((ROOT/'tests/fixtures/qbit-main-hotfix-policies.json').read_text())
for fixture in fixtures:
manifest = migration.infer_manifest(fixture['config'], '0.7.13', 'develop')
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
config = pipeline.load_manifest('unused', '0.7.13')
cases = [(branch, '') for branch in ('main','develop','feature/a','release/1','hotfix/1.2.3','integration-test','staging')]
cases += [('', tag) for tag in ('v1.2.3','v1.2.3-RC.1','vanything','publish1','invalid','v\u0661.\u0662.\u0663')]
for branch, tag in cases:
with self.subTest(repository=fixture['repository'], branch=branch, tag=tag):
expected = sorted((job, options.get('branch_type')) for workflow in fixture['config']['workflows'].values() for entry in workflow['jobs'] for job, options in entry.items() if selects(options.get('filters', {}), branch, tag))
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
generated = pipeline.qbit_template(config, branch, tag)
actual = sorted((job, options.get('branch_type')) for workflow in generated['workflows'].values() for entry in workflow['jobs'] for job, options in entry.items() if selects(options.get('filters', {}), branch, tag))
# The canonical setup's tag filter prevents non-release tag runs.
caller = migration.canonical_caller('0.7.13', manifest['release_tag_policy'])
setup = caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']
if not selects(setup['filters'], branch, tag): actual = []
self.assertEqual(actual, expected)
def test_cms_repair_only_quotes_the_existing_tag_pattern(self):
fixtures = json.loads((ROOT/'tests/fixtures/qbit-main-hotfix-policies.json').read_text())
fixture = next(row for row in fixtures if row['repository'] == 'QRun-IO/qbit-cms')
with self.assertRaises(yaml.YAMLError):
yaml.safe_load(fixture['original_yaml'])
repaired = fixture['original_yaml'].replace(r'only: [/^v[0-9]+\.[0-9]+\.[0-9]+$/]',
r"only: ['/^v[0-9]+\.[0-9]+\.[0-9]+$/']")
self.assertEqual(yaml.safe_load(repaired), fixture['config'])
def test_stable_tag_selection_uses_ascii_digits(self):
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
self.assertEqual(pipeline.event_kind('', 'v\u0661.\u0662.\u0663'), 'test')
self.assertEqual(pipeline.event_kind('', 'v1.2.3'), 'release')
def test_existing_manifest_does_not_enable_hotfix_publication(self):
raw = 'profile: qbit\norb_version: 0.7.13\ndefault_branch: develop\n'
with mock.patch.object(Path, 'read_text', return_value=raw):
config = pipeline.load_manifest('unused','0.7.13')
self.assertFalse(config['publish'].get('hotfix', False))
result = pipeline.qbit_template(config, 'hotfix/1.2.3', '')
self.assertIn('qqq-orb/mvn_test_only', result['workflows']['test_only']['jobs'][0])
if __name__ == '__main__': unittest.main()
+51
View File
@@ -0,0 +1,51 @@
"""Run the workflow's publication shell with a recording CLI, never GitHub."""
import json
import os
import subprocess
import tempfile
import yaml
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def workflow_shell(name):
worker = yaml.safe_load((ROOT / ".github/workflows/qqq-all-release.yml").read_text())
return next(step["run"] for step in worker["jobs"]["release"]["steps"]
if step.get("name") == name)
class ReleaseWorkflowTest(unittest.TestCase):
def test_rc_is_prerelease_never_latest_and_ga_keeps_existing_release_behavior(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
gh = root / "gh"
gh.write_text("#!/usr/bin/env python3\nimport json, os, sys\n"
"with open(os.environ['CALLS'], 'w') as f: json.dump(sys.argv[1:], f)\n")
gh.chmod(0o755)
calls = root / "calls.json"
for version in ("4.1.0", "4.1.0-RC.1", "4.1.0-RC.2"):
calls.unlink(missing_ok=True)
environment = {**os.environ, "PATH": directory + os.pathsep + os.environ["PATH"],
"CALLS": str(calls), "VERSION": version, "TAG": version,
"RUNNER_TEMP": directory, "GITHUB_REPOSITORY": "QRun-IO/qqq-all"}
result = subprocess.run(["bash", "-c", workflow_shell("Publish GitHub release with Compose bundle")],
env=environment, capture_output=True, text=True)
if version == "4.1.0-RC.2":
self.assertNotEqual(0, result.returncode)
self.assertFalse(calls.exists())
continue
self.assertEqual(0, result.returncode, result.stderr)
args = json.loads(calls.read_text())
self.assertEqual(["release", "create", version], args[:3])
self.assertIn(str(root / ("qqq-all-" + version + ".tar.gz")), args)
self.assertIn("--verify-tag", args)
if version == "4.1.0-RC.1":
self.assertIn("--prerelease", args)
self.assertIn("--latest=false", args)
else:
self.assertNotIn("--prerelease", args)
self.assertNotIn("--latest=false", args)
+11
View File
@@ -58,6 +58,17 @@ class FixtureAPI:
class SweepTests(unittest.TestCase):
def test_stable_gate_and_mixed_name_latest_failure(self):
api = FixtureAPI()
api.status['check_runs'][0]['name'] = 'verify'
self.assertEqual('dispatched', sweep.reconcile(api, REPO))
api.sent.clear()
api.status['check_runs'].append(dict(api.status['check_runs'][0],
id=10, name='publish_release_candidate', conclusion='failure'))
with self.assertRaises(sweep.InvalidIntent):
sweep.reconcile(api, REPO)
self.assertEqual([], api.sent)
def test_idle_never_dispatches_or_reads_artifacts(self):
api = FixtureAPI(); api.lock = None
self.assertEqual('idle', sweep.reconcile(api, REPO))
+11
View File
@@ -23,6 +23,17 @@ def bump(parent=SHA, version='1.2.3-RC.4'):
class ReleaseGuardTests(unittest.TestCase):
def test_stable_workflow_preserves_exact_source_and_latest_attempt_checks(self):
result = status()
result['check_runs'][0]['name'] = 'verify'
self.assertEqual('1.2.3-RC.4', evaluate(SHA, result, bump()))
result['check_runs'].append(dict(result['check_runs'][0], id=10, conclusion='failure'))
with self.assertRaisesRegex(Failure, 'CircleCI failed'):
evaluate(SHA, result, bump())
result['check_runs'] = [dict(result['check_runs'][0], head_sha=OTHER)]
with self.assertRaises(Failure):
evaluate(SHA, result, bump())
def test_success_exact_built_source(self):
self.assertEqual('1.2.3-RC.4', evaluate(SHA, status(), bump()))
+44
View File
@@ -0,0 +1,44 @@
"""Exercise actual shell handling of gh error JSON, including the observed 404."""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import textwrap
import unittest
SOURCE = Path(__file__).parents[1].joinpath('.github/workflows/qbit-release-rc.yml').read_text()
FUNCTION = textwrap.dedent(SOURCE.split(' # BEGIN RC REF LOOKUP\n')[1].split(' # END RC REF LOOKUP')[0])
@unittest.skipUnless(shutil.which('bash') and shutil.which('jq'), 'Bash and jq required')
class RefLookupTests(unittest.TestCase):
def lookup(self, body, code):
with tempfile.TemporaryDirectory() as directory:
env = dict(os.environ, BODY=body, CODE=str(code), REPO='QRun-IO/qbit-alerts', workdir=directory)
script = 'set -euo pipefail\ngh() { printf "%s" "$BODY"; return "$CODE"; }\n' + FUNCTION + '\nresult=$(read_ref tags/v0.1.0-RC.17)\nprintf "%s" "$result"\n'
return subprocess.run(['bash', '-c', script], env=env, text=True, capture_output=True)
def test_absent_tag_returns_empty_not_error_json(self):
result = self.lookup('{"message":"Not Found","documentation_url":"https://docs.github.com/rest/git/refs#get-a-reference","status":"404"}', 1)
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('', result.stdout)
def test_existing_tag_returns_only_valid_object_sha(self):
result = self.lookup('{"object":{"sha":"' + 'a' * 40 + '"}}', 0)
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('a' * 40, result.stdout)
def test_permission_network_and_server_errors_are_not_missing_refs(self):
for body in ('{"status":"403"}', '{"status":"500"}', '', ' ', '\n', 'not json'):
with self.subTest(body=body):
self.assertNotEqual(0, self.lookup(body, 1).returncode)
def test_malformed_success_response_is_rejected(self):
for body in ('{}', '{"object":{"sha":null}}', '{"object":{"sha":"not-a-sha"}}'):
with self.subTest(body=body):
self.assertNotEqual(0, self.lookup(body, 0).returncode)
if __name__ == '__main__':
unittest.main()
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff. Show more