Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98a7cd60bb
|
No files matched your search
@@ -31,9 +31,6 @@ 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:
|
||||
@@ -52,16 +49,10 @@ jobs:
|
||||
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_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
|
||||
@@ -69,8 +60,6 @@ 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
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
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
|
||||
@@ -19,14 +19,6 @@ 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: ''
|
||||
@@ -40,10 +32,6 @@ 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
|
||||
@@ -60,7 +48,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
cut-rc:
|
||||
if: ${{ !inputs.finalize && !inputs.recover }}
|
||||
if: ${{ !inputs.finalize }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
@@ -135,7 +123,7 @@ jobs:
|
||||
echo "merge_sha=$merge_sha"
|
||||
echo "merged_at=$merged_at"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
echo "Pushed $branch; the CircleCI publisher cuts the RC." >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "Pushed $branch; CircleCI publish_release_candidate 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 != ''
|
||||
@@ -147,7 +135,7 @@ jobs:
|
||||
retention-days: 90
|
||||
|
||||
tag-and-release:
|
||||
if: inputs.finalize || inputs.recover
|
||||
if: inputs.finalize
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
@@ -159,12 +147,6 @@ 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
|
||||
@@ -174,22 +156,6 @@ 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
|
||||
@@ -198,12 +164,12 @@ jobs:
|
||||
class ReleaseFailure(ValueError):
|
||||
pass
|
||||
|
||||
def evaluate(merge_sha, status, commit, recovered_version=""):
|
||||
def evaluate(merge_sha, status, commit):
|
||||
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") in ("publish_release_candidate", "verify") and x.get("app", {}).get("id") == 18001]
|
||||
if x.get("name") == "publish_release_candidate" and x.get("app", {}).get("id") == 18001]
|
||||
if not publishers:
|
||||
return ""
|
||||
publisher = max(publishers, key=lambda x: x["id"])
|
||||
@@ -211,7 +177,7 @@ jobs:
|
||||
raise ReleaseFailure("Publisher Check Run identifies a different source")
|
||||
if publisher.get("status") != "completed":
|
||||
return ""
|
||||
if publisher.get("conclusion") != "success" and not recovered_version:
|
||||
if publisher.get("conclusion") != "success":
|
||||
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)
|
||||
@@ -219,8 +185,6 @@ 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):
|
||||
@@ -259,168 +223,24 @@ 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] == "recover":
|
||||
verify_recovery(*sys.argv[2:])
|
||||
elif sys.argv[1] == "lock":
|
||||
if 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:
|
||||
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))
|
||||
print(evaluate(sys.argv[1], json.load(open(sys.argv[2])), json.load(open(sys.argv[3]))))
|
||||
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}$ ]]
|
||||
if [[ "$RECOVER" == true ]]; then
|
||||
[[ "$RECOVERY_EVENT" == workflow_dispatch && "$CIRCLE_BUILD" =~ ^[1-9][0-9]*$ ]]
|
||||
else
|
||||
[[ "$BUMP_SHA" =~ ^[0-9a-f]{40}$ ]]
|
||||
fi
|
||||
[[ "$MERGE_SHA" =~ ^[0-9a-f]{40}$ && "$BUMP_SHA" =~ ^[0-9a-f]{40}$ ]]
|
||||
[[ "$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"
|
||||
@@ -458,53 +278,13 @@ jobs:
|
||||
PY
|
||||
MERGED_AT=$(jq -er .merged_at "$workdir/intent.json")
|
||||
lock=automation/qbit-rc-pending
|
||||
current_lock=$(read_ref "heads/$lock")
|
||||
current_lock=$(gh api "repos/$REPO/git/ref/heads/$lock" -q .object.sha 2>/dev/null || true)
|
||||
# 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"
|
||||
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[@]}")
|
||||
version=$(python3 "$workdir/rc_guard.py" "$MERGE_SHA" "$workdir/status.json" "$workdir/commit.json")
|
||||
[[ -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; }
|
||||
@@ -536,7 +316,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=$(read_ref "tags/v$version")
|
||||
existing=$(gh api "repos/$REPO/git/ref/tags/v$version" --jq '.object.sha' 2>/dev/null || true)
|
||||
target=""; release_exists=false
|
||||
if [[ -n "$existing" ]]; then
|
||||
target=$(gh api "repos/$REPO/git/tags/$existing" --jq '.object.sha')
|
||||
|
||||
@@ -58,15 +58,10 @@ 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_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
|
||||
@@ -220,4 +215,3 @@ 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
|
||||
@@ -87,11 +87,6 @@ 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:
|
||||
@@ -119,21 +114,6 @@ 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 |
|
||||
|
||||
@@ -3,18 +3,6 @@
|
||||
`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
|
||||
@@ -77,29 +65,3 @@ actionlint .github/workflows/workflow-lint.yml
|
||||
Tests cover exact no-CI allowlists and drift, unknown repositories, missing configured
|
||||
profiles/native bridges, retained legacy workflows, bootstrap dependency/gate removal,
|
||||
required-check unknown states, and the lint image/tool/command/caller contract.
|
||||
|
||||
## Batch orb-version rollout
|
||||
|
||||
Upgrade existing canonical CircleCI consumers with one command:
|
||||
|
||||
```sh
|
||||
python tools/rollout_version.py --orb-version 0.7.11 /checkouts/qbit-one /checkouts/qqq-cli
|
||||
python tools/rollout_version.py --orb-version 0.7.11 --write /checkouts/qbit-one /checkouts/qqq-cli
|
||||
```
|
||||
|
||||
The first command previews the batch. The second updates only `.qqq-ci.yml` and
|
||||
`.circleci/config.yml`, after every supplied checkout passes the existing manifest
|
||||
and canonical-caller validators. It preserves publication opt-outs, release filters,
|
||||
credential context names and forwarded profile parameters. Already-current files
|
||||
are unchanged. Duplicate checkouts, custom jobs, invalid options and mismatched
|
||||
pins reject the batch before writing; resolve these in the central profile first.
|
||||
|
||||
Use isolated checkouts of the intended repository heads, inspect the resulting
|
||||
patches, then commit and push through the normal automated gates. The tool does not
|
||||
commit, push, publish packages, change GitHub rules or modify native/RC worker pins.
|
||||
A version update does not prove a publication succeeded: retain exact-head hosted
|
||||
verification and artifact evidence. The requested version must already be published.
|
||||
|
||||
```sh
|
||||
python3 -m unittest discover -s tests -p test_rollout_version.py
|
||||
```
|
||||
@@ -61,23 +61,11 @@ 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.
|
||||
| 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
|
||||
@@ -111,10 +99,8 @@ 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
|
||||
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
|
||||
@@ -196,7 +182,7 @@ 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
|
||||
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.
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# 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).
|
||||
@@ -8,16 +8,11 @@ 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`, `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. |
|
||||
| `test_branch_policy` | `all`, `non-release`, `non-release-no-integration`, `feature`, `non-release-no-main` | Selects one of the five audited test branch exclusions. |
|
||||
|
||||
`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.
|
||||
|
||||
@@ -37,27 +32,10 @@ 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"], manifest["publish"].get("feature", False))`; the legacy one-argument
|
||||
`canonical_caller(version, manifest["release_tag_policy"])`; 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.
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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.
|
||||
+1
-39
@@ -26,8 +26,7 @@ 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 `verify` (or legacy
|
||||
`publish_release_candidate`) Check Run
|
||||
- The exact merge SHA must have a successful `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
|
||||
@@ -81,40 +80,3 @@ 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.
|
||||
@@ -12,9 +12,8 @@ text = source.read_text(encoding="utf-8")
|
||||
start = text.index("# BEGIN PROFILE RESOURCES")
|
||||
end = text.index("# END PROFILE RESOURCES") + len("# END PROFILE RESOURCES")
|
||||
embedded = ["# Generated by scripts/pack_pipeline.py; edit source/resources, then regenerate.", "import base64", "import zlib"]
|
||||
for variable, name in (("CORE_TEMPLATE", "core"), ("MATERIAL_TEMPLATE", "frontend-material"), ("VOYAGE_TEMPLATE", "voyage"), ("NEXT_TEMPLATE", "frontend-next"), ("ALL_TEMPLATE", "all"), ("STARTER_TEMPLATE", "app-starter"), ("ANDROID_TEMPLATE", "android"), ("POLICY_TEMPLATE", "mcp-policy"), ("REPOSITORY_POLICY_TEMPLATE", "repository-policy"), ("MARKETING_TEMPLATE", "marketing")):
|
||||
resource = (source.parent / "templates" / (name + ".json")).read_text(encoding="utf-8").encode("utf-8")
|
||||
payload = base64.b64encode(zlib.compress(resource, 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"), ("MARKETING_TEMPLATE", "marketing")):
|
||||
payload = base64.b64encode(zlib.compress((source.parent / "templates" / (name + ".json")).read_bytes(), 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:
|
||||
|
||||
@@ -161,7 +161,7 @@ set_version() {
|
||||
##############################################
|
||||
## Use Maven versions plugin to set version ##
|
||||
##############################################
|
||||
mvn -f "$POM_FILE" versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
|
||||
mvn versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
|
||||
|
||||
#######################
|
||||
## Verify the change ##
|
||||
@@ -175,26 +175,6 @@ 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 ##
|
||||
#############################################
|
||||
@@ -454,9 +434,6 @@ main() {
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
ensure_project_version "$NEW_VERSION"
|
||||
fi
|
||||
echo "=== Version calculation complete ==="
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ 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"))
|
||||
# END PROFILE RESOURCES
|
||||
|
||||
@@ -70,7 +69,7 @@ def load_manifest(path, setup_version):
|
||||
if not isinstance(data, dict):
|
||||
raise ManifestError("Manifest must be a mapping")
|
||||
profile = data.get("profile")
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
@@ -79,7 +78,7 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
elif profile == "cli":
|
||||
allowed += ("publish_context",)
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "marketing"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -111,8 +110,6 @@ 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")
|
||||
@@ -129,8 +126,7 @@ def load_manifest(path, setup_version):
|
||||
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",
|
||||
"non-release-no-hotfix", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
if test_policy not in ("all", "non-release", "non-release-no-integration", "feature", "non-release-no-main"):
|
||||
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),
|
||||
@@ -140,8 +136,7 @@ def load_manifest(path, setup_version):
|
||||
"release_tag_policy": tag_policy, "test_branch_policy": test_policy,
|
||||
"docs_only": boolean(data, "docs_only", False),
|
||||
"publish_context": publish_context,
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all"))
|
||||
for key in publish_keys}}
|
||||
|
||||
|
||||
@@ -176,28 +171,9 @@ 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, flags=re.ASCII):
|
||||
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag):
|
||||
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:
|
||||
@@ -215,35 +191,21 @@ 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 = kind != "test" and 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 and not maintenance:
|
||||
if kind == "test" and not tag:
|
||||
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-hotfix": "/(develop|release/.*|hotfix/.*)/",
|
||||
"non-release-no-main-hotfix": "/(develop|main|release/.*|hotfix/.*)/",
|
||||
"feature-no-hotfix": "/(develop|main|release/.*|hotfix/.*|integration.*)/"}
|
||||
"non-release-no-main": "/(develop|main|release/.*)/"}
|
||||
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" and not maintenance else False
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" 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"}],
|
||||
@@ -445,13 +407,7 @@ def voyage_template(config, branch, tag):
|
||||
return json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
|
||||
|
||||
|
||||
def repository_policy_template(config, branch, tag):
|
||||
del config, branch, tag
|
||||
return copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
|
||||
|
||||
PROFILE_TEMPLATES = {"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}
|
||||
|
||||
@@ -485,12 +441,6 @@ 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"])
|
||||
|
||||
@@ -17,16 +17,12 @@ 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 {
|
||||
|
||||
@@ -20,10 +20,6 @@ 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
|
||||
|
||||
@@ -22,9 +22,8 @@ VOYAGE_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtW+tz2zYS/56/A
|
||||
NEXT_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrNVE1v2zAMvedXCFqAtlscb70tQLGtXTEUGFYgHXqJM0OxmUSJLCmS7DYr8t9HubaXOOnHYYfdLPLp6fGR9EOHEFqAsVxJOiCn/Q89H1FmYvH4gN94Wq1WAUYwQJdczqxRahlWwc9xfD08j28vhzdX1z/imOKVTcmxUNscOp8Ibudxyux8ophJ4wUzTRoBcA9J7pSP1Q+GC1Yw2qsR1oH2jKMqgKFkDslS5a4BkYZwW3nIpXVMiLgkHOxgEFVnpUoBs87k0NtF+Ez81yZ6ekq3AJvme/OEDpPL/Wcly/xz9BYMn66JmwPhWZY7NhFADAhgFkj9aEtQorKMydRfr5C1vLOIdh8uroYX3y/jn1++vSk2EY3k1CjpQKYNqnvsayKBJhEyrHJu4PioH2qWLNkM+gur5NFJv0JH9CSSGStAbt3PCkmCcxKsyByEHkDBRM4cUn6Fe23AljBt1AISVxNhcqpMAjcuxa4hqQPrUEG3rS+i5MzHW8X5UuorO3qewf/DTp3nXKRlo3BgHE8IVqqMe6Y5iTLgPSUgfVsjqaXOSDVwJAiw7t8gA6GS5ZQ3ebfWUI52dRZcujqF1VefE69m8CjhFWU2y4CN88sXp6CFWtf3xp365uP63imznAp1d2CHK5O3t7da9tHza1iuEdM6LqXv+4wWOGzcXgJTE8MkWnIo5zd4JtFob3jYfxvSFmDTa7M5NnuCSUmx3ilkKxcWB8hr5w653z69PH4v/SabCcM1uHcHhJZel6sRGJhx68w6SAykIB1nwu6qH/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("eNrtWG1v2zYQ/p5fQWgF6rSW3CXYMDhJ13YNkm5rkrrugKEKDFqiZCYUyZBUbC/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592Iv+CF45vULxjSSfsRoh7Hce7Ef7AV7HvCtnIYr0daQc2p8Q7Spt2CTLEiUG6Fae7DLcUasghJABcTPcDSjnJRQHKvBqeWMSYJzZrySsKo4PG2ItCA+NkeiGYmuRW7aYipNCvAJRfxU4ZgRPwKFbXUNxvaZnDu7dMeIAh1s+5HIMuC1MINBIXiOLOU1meap1zqxqterLdg0vn0YMAC0CaXy6XuQ4rQjsBVcpltSCvc0cLPrmCrkS/T3wFlSnhhc2VgOQp5QHqMA+WYpCUoQ0FOyQKEXPBlMc8ri7qngySJjoYd8G3QUSXS32i4YheFByNdxzWeEu6Rgc7zUn3VbxyMuqBOralJZveEgic3Myu9C+ho9WBma4OjhSgq7P6GqXF3utBRXObFRTxIriLOBYu9WlF5CIWQ+zXBK1lB5NnoWkzaK8rTj9rquhl0R+qACsP/sIBUiZWC1pPpg8dOP3gb0phq/kXLfWsbaQNx8kuUMA0Iftv2vquxIcE4iQ2JX3i8L6WMbp7WEXouJd3iImvAFbSp6/vzL8vDb6QDgeJnDAdz44f+G8C80hAyCyv2YSCaW/5UBe28WX+RTRvUMzamZIT3DisTorXUCimBJuKGY3ZfZmhhIvFwgSSXYRlnIh5C4j+5O3oxPP7yajM9/Oz4b/nxCzWk+RRc4urZ9D80VNaSlAlENZXSTU9hZhV7Iv0MvczOzxAgD55QkYC40hUxSBu31ALil0BScsEQ4iojWVgR0DFhhtewjLgySSogEwZ8s9JZqC/4g5FBmFNr1cpJroo4e9eTSzATfhzo5PHx88ef49PzscchpJoUy6EoLXr8IXS9zxRidBhY9BCUEnohhgHMmRgSqHnpYr8sSnI7HFxXtFPzIiNodhty6FvIDLCtIk5K/pwlL+tY9fZTIPjghJn2U6bSPZgTH0OXAWjIHJZUU+yhMNUGjHDyYkWOlhOqFXhkG3LgWLrO1Qlgk4Ik49HatGeCYUp6QhBOFjtZsDVxvmhTUXmPvbmNLSkzP1mYHWXF6U9yotDf0ZsZIPRwMYBgGKWRmPg0g9ANock+RFddvpNmndMPRXejZrBGK/uUsCz2bi68IZLVC7rDQAeG3VAn+EbzRStHQu1wTWj8gFBJGmkIalpKVjhvc8riE99Rlh7fabWS4iip8E9ifXmlmH9mIQF0f7T/bRdjmvZaCazLs6lfE5Iq7tAuYwHGv4it12JwFH1oPh559gbAFxRsTKeUuipaRJq4YqKYchjOPSM9y9xFk/i4SyhGdsHJdyHD1NXgHCeS/OR/c3Nz4RW+saqbRJonKqLafRTr0+jB9akKuZ8C2kZR/YJbXKfnWHuUpquSW1Vmjl3CbMg4xbJCFDQQ6dj+gsBRdiH3vRv3xgpom0+uG02o1EebWzLJrQCWUDa9lGUqUyKCCOQl50QdC7tS7ij8fnUxORi9f/348uRid/3r8y3hSZMG7mxsnalRK+gCobaM9gobY6TW2w32psAtoKnOhYiusm7khb65NPtymuBaMHEmGKUey6O9Okuv1ReqOxclWJaO6q8JF4SFzs/5KBWjXCRPz1qeqG8X2Auj6RHuclp+0rWHXfNbef7+sr+qfvzR8YpZXU7GYNl0Y94DZBqNDvFwbkgllGx8QJWmqoAxnZBvN/keBs6W7NEL8vDXyqvO+2pjL3JCF2WbSZgH77QHfteShgd9Z7fwDUg7law==")))
|
||||
ANDROID_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtWG1v2zYQ/p5fQWgF6rSW3CXYMDhJ13YNkm5rkrrugKEKDFqiZCYUyZBUbC/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592Iv+CF45vULxjSSfsRoh7Hce7Ef7AV7HvCtnIYr0daQc2p8Q7Spt2CTLEiUG6Fae7DLcUasghJABcTPcDSjnJRQHKvBqeWMSYJzZrySsKo4PG2ItCA+NkeiGYmuRW7aYipNCvAJRfxU4ZgRPwKFbXUNxvaZnDu7dMeIAh1s+5HIMuC1MINBIXiOLOU1meap1zqxqterLdg0vn0YMAC0CaXy6XuQ4rQjsBVcpltSCvc0cLPrmCrkS/T3wFlSnhhc2VgOQp5QHqMA+WYpCUoQ0FOyQKEXPBlMc8ri7qngySJjoYd8G3QUSXS32i4YheFByNdxzWeEu6Rgc7zUn3VbxyMuqBOralJZveEgic3Myu9C+ho9WBma4OjhSgq7P6GqXF3utBRXObFRTxIriLOBYu9WlF5CIWQ+zXBK1lB5NnoWkzaK8rTj9rquhl0R+qACsP/sIBUiZWC1pPpg8dOP3gb0phq/kXLfWsbaQNx8kuUMA0Iftv2vquxIcE4iQ2JX3i8L6WMbp7WEXouJd3iImvAFbSp6/vzL8vDb6QDgeJnDAdz44f+G8C80hAyCyv2YSCaW/5UBe28WX+RTRvUMzamZIT3DisTorXUCimBJuKGY3ZfZmhhIvFwgSSXYRlnIh5C4j+5O3oxPP7yajM9/Oz4b/nxCzWk+RRc4urZ9D80VNaSlAlENZXSTU9hZhV7Iv0MvczOzxAgD55QkYC40hUxSBu31ALil0BScsEQ4iojWVgR0DFhhtewjLgySSogEwZ8s9JZqC/4g5FBmFNr1cpJroo4e9eTSzATfR4eHjy/+HJ+enz0OOc2kUAZdacHrF6HrZa4Yo9PAYoeQhMATMQxgzsSIQM1DB+t1WYLT8fiiop2CFxlRu8OQW8dCdoBdBWlS8vc0YUnfOqePEtkHF8SkjzKd9tGM4Bh6HNhK5qCkkmIfhakmaJSD/zJyrJRQvdArg4Abx8JVtlYIiwT8EIferjUD3FLKE5JwotDRmq2B60yTgtpr7N1tbEmJ6dnK7CArTm+KG5X2ht7MGKmHgwGMwiCFvMynAQR+AC3uKbLi+o00+5RuOLoLPZszQtG/nGWhZzPxFYGcVsgdFjog/JYqwT+CN1oJGnqXa0LrB4RCukhTSMNSstJxg1sel/CeuuzwVruNDFdPhW8C+9MrzewjGxGo6qP9Z7sI26zXUnBNhl39iphccZd2ARM47lV8pQ6bseBD6+HQsy8QtqB4YyKl3EXRMtLElQLVlMNo5hHpWe4+grzfRUI5ohNWrgsZrroG7yCB/Dfng5ubG7/ojFXFNNokURnV9qNIh14fZk9NyPUM2DaS8g/M8jol39qjPEWV3LI2a/QS7lLGIYYNsrCBQMfuBxSWogux792gP15Q02R63W5ajSbC3JpZ9gyohLLdtSxDiRIZVDAnIS/6QMidelfx56OTycno5evfjycXo/Nfj38ZT4oseHdz40SNSkkfALVts0fQDjudxva3LxV2AU1lLlRshXUzN+TNpcmHuxTXgpEjyTDlSBbd3Ulynb5I3bE42apkVPdUuCY8ZGrW36gA7TphYt76UHWD2F7/XJ9oD9Pyg7Y16pqP2vtvl/VF/fNXhk9M8momFrOmC+MeMNtgdIiXayMyoWzj86EkTRWU4Yxso9n/J3C2dFdGiJ+3Rl513lcbU5kbsjDbTNosYL893ruWPDTwO6udfwDDGeSz")))
|
||||
POLICY_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNqdVU1v2zAMvedXCL442Rq3aYEegubQQwYMWLGeBgxVESg2nWqVJU9S1gZB/vtIWXbsdCuw+WKJH4+PlEjtR4wlv8A6aXQyZ5fZ7IwkP8za4XaPa9ILJQvhYVoL78HqowqVhcmfwaLkIUpYpwt6WYkNoDrJZbU5r3f+yej5VTa7TDqrQ1w9nrWgFpzZ2hxWuRKOwiWuEkolnYHzULtB0CR/gvzZbH1ndELEbnWPdxRqUQVyn7XzGIDd777f3n3pQTTQpqqELsiwljWT0Xg6LaQTa4WFkfU0VnEaeESgxeI6u8iukh7c4Zj2/xD9Fs+CxbNgpVTg3iMcKn7FOL+5Yeny66eUa1nVxnq2E5XqNm7nuC6tqQj5Sck1i4p73HLNNVhrrGML9vDIdYy+ys1We5RdkEVpbMBcESesUnAdp1k6yexGmfU4/ZCRPp3MuSaesmRC78a1sD7DklrvXmT0YARGCsLpQDOSuNadvtxoL/UWKD7tvd31tATHTA163EFMmHCs7NnQhxUVmAUZZU6UsFJGFONy0qJGsmnbAOcp0XLe9nBPIC383EoLBRUslUV6xlIvvQJa5HiAG2N3tC7A5VbWHq9OUGE+oH36OESrpHNSbwisDKUpiUAXA7mVTJtQLMrlxBvVEeCEJH3NuWaixjJhzjzZdzkd5uwuBi4lqMLhtYxAB55MhljDK/FxwWZt9eA1h7q5bhl1xZIi0jFAj877NMiNroODxhCJwJFCDLAMPyzkv2Evh4B4ua3UnszaZivYfpDdYdh90Q2r3ASKkRsYnnCul03vlOhczDvadI6hTwZuR1dkwNh0kCl2aQav0o9nKADl4CTWLY6l9pKyMLeDK7Y913+ZQu3wHbW7MJeSF2OfS2Ve/vAO9Md/fCl6c/jta/E2wugw+g3AlOQ8")))
|
||||
REPOSITORY_POLICY_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNqdVltv2zYUfs+vIPwiGYjotgGGIa0fis7YAnRO0HgtgigwaOnIZkKRGkkl9gL/951DXSK7aDNML+K56ON3bqSeTxgbPYJ10ujROXvH356S5t6sHIrPuCa7UDIXHpLKKJntegOacpM9gEXNbathvS3YZSnWgOZRJsv1pNr5jdHnZ/ztu1HvtW9Xd6cdqAVnapvBMlPCEY+RK4VSo97BeajcwaajbAPZg6l973RExNZ6wLtValEGchfaedyA+Q2wm49/fmaVsA7DOj10z0xZCp3TF00kZywpWSUrJluAJMmlEyuFqZJV0uY1CdzY1Y6gp9Nf+Bt+Nhog719S8X/If22rE9iLqsISCU/bFhaArazQ2eY/RJKmHz5EVzeLPy7nUaplWRnr2b0zOtWFNRim8BslV6y1XKHYu7l6VVmTgXO9alsqDh4Z8JmCErRfEBvh2GzR++xEqVLEJ2jHpgMYHlK2xHpWtY9vo7X00SmLlEsKqcDROvknuhvzHDKTQxzVvkh+jcbcYfg+jtL0TTR+Ab4ltjElbMwKYxmtsGasscsiKO6QF66Mb9TnqaZUWSEdsOsdtlw52xL23DBvBbZ9zpp5YA0n3I9gaL/n6PPFp9n8ekZE55cLFGj16fLq5mL+e7P8bXb5bT77ck0Sx/jkWhsLnSS8t3JVe4q1IRKeiEMuvbGZ0YVck3P5qJ+6N8/KPNqn2tVFIbctE446ArUupJD7bfMWOLphsStV8xbtgooeFliMCqyXSAJRsWFkAc43sJUp+bb5oMJk4JT332XCrg33prXuEOYeMt9r0Fia/CCuENuqlirnaytyFfIwlPmDD1V34L3UazdwO1IFT6RLdaZC9nVuC4o1JpFLt3QYutQP8Zi1vpwKyJV5AotK/LCP+fyF7HcdUUQfX6aOoFpcZuHvWuJhxgQLsTDMBPUKjjLttqeWGVISblkZJ7e493SK+ceaTp4sjjTYSSkeQSetxO+FjQaUsB0wBTX8FC6MlPM7BZOmfUL9BiizBadJd9h5eh0HCAsiX3rY+hg0Dhrqp92ojV/bPgwZjRPmsRkMPHEaU9OgfaJbp65tf57rv7C9Kzo+DufvPXOgsMteyzUFgw38WnSHoRzxRa7x0dyMB6SVdD4mLXeigKUyuAteDjHt1KUN1A+wQ+HDJA0QSeaE4xoQPNmwRpSN7vDP2bMCHYrmxvujA2qCo17TGdx0aDiu3mPWh7dFmzUahHrVKSkPzZWQ6h/cWN3lfdJJ4Q4bPRn7UGBMw78IsLI4+Hlo/zIGt/jxn8b36Cf7k38B2PmvaA==")))
|
||||
MARKETING_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtW89v4ygUvuevQD7MSKsSp5lbD6OR9rRa7W1uk8oiGMc0GFzATbNV/vd9+EeaOHaqVpt6knBpbfh4wHufee9z3ZcRQsET04YrGdyh6fj2xrUoPTdw+wLXcJcVkluloSFYqmQ6DeuGH5Pxt/HtbQCoTTlspfQyEWq1MzbXmKaMLl+boPFBleZ/1fdo27M7XShVzKJ5wUUcERlHlhm7Y6QGS5Ixt7AShwGHS9xNC+VMvW4zmE7biJzQJVmwKCMSfpV7lXnWRjnbEVUZoGK3g+DXzMGQLiQSXNpZcINeW8o1NU3PKBdkvdJ8kVrEpbFECERTrTJeZAjjFbcpjllu9m24Ge8a2H6XcKZSVRg2C+7bK6VKWvZs97xcdy1gpmIe7DXft4YnXFhw14G/oWuuiYSQdvU55kix7pi07AsTRmyh2WwWjv8IWytuMKmyCX+uIQeI+1bLZtR393q9uTnOs1jRJdORoUT284tnQAtcYlquKnuiBpcRvWSWywVesbnhlrXhmi24sdo5KVikVI+5Ch8hnJirQ+hjwTUzXUFs8d0Hsw6mYVQza96IZo3qjOdVeYvAefaGqwDS7SfCRaRklHAZA9/L4zAhwrBrdmiZaKj78VgQwe2637EOhRvUifKVP0E+HELwPjj2WPhqxIlCl3G5u4pgcpjhq87IKiUc4qGj8NmCTAFFi15HObHp7vLD5gLXiPGDUbLXTF37lJluGXONcI6aTvTlC2I0VejryyywCgqcWXAHl1AYMVNd5hRKpLvbyWSz2XxF39H7VuHZ/EE2Q7orNBwzb2fFEtZ53Psj6YRBHO2OrUMaxOyJCZV74XRNwmkb9YusjU+6u3OoZU/pAF97DuVyXyv6WnEo9vna7nOdXr8trMqrvDBpv88rKK52XkI/7dVhyoiw6fYJDvv6lXaVTvBtMpn0QOJ5bzI8Fu4jGQb1HojoaPWB+hM4ahP8KL2OlXjg1t+Ym506ASriBbDG64Sr0glN1C9TJ5xyd2ehE07oAK8ThnK51wleJwzFPq8TPtfpXid4nTAYNzt1gmaCEcMw7DvmMbHMKwb/SVZNCv+JzjCuON/vbwbwlhcuZxEfr3K8yjkLqnpJ9BtHyOsnr58ugshVbR/VM/ezuMLhBvcODhzy/8NhuSgd0qmCc63igtrquPby93r+YJYRLv2LvsES1XuKmGFfvJ2KKEXuXrpFNIZckKt+llQ4TGNc4tq+2Q4P/lbJzxWTdv1zpUIqCgP7xvAsqdy0RzH5xLWSGaDdSHcIdhhOlM5ICViCMXjA/2UdqH2StngXvklasNCw0DJJpDXl2LCGh83UxJ3R4zXJxIEFHsEuIwaBKuUb5T+chfEh62tks9Z/qkigP/+63PR6Mvr6Oub/cvR+XeL+e3q0Gf0Hgnpc+w==")))
|
||||
|
||||
|
||||
@@ -70,7 +69,7 @@ def load_manifest(path, setup_version):
|
||||
if not isinstance(data, dict):
|
||||
raise ManifestError("Manifest must be a mapping")
|
||||
profile = data.get("profile")
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
@@ -79,7 +78,7 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("release_completion", "release_on_main", "release_tag_policy", "test_branch_policy")
|
||||
elif profile == "cli":
|
||||
allowed += ("publish_context",)
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "marketing"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -111,8 +110,6 @@ 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")
|
||||
@@ -129,8 +126,7 @@ def load_manifest(path, setup_version):
|
||||
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",
|
||||
"non-release-no-hotfix", "non-release-no-main-hotfix", "feature-no-hotfix"):
|
||||
if test_policy not in ("all", "non-release", "non-release-no-integration", "feature", "non-release-no-main"):
|
||||
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),
|
||||
@@ -140,8 +136,7 @@ def load_manifest(path, setup_version):
|
||||
"release_tag_policy": tag_policy, "test_branch_policy": test_policy,
|
||||
"docs_only": boolean(data, "docs_only", False),
|
||||
"publish_context": publish_context,
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all"))
|
||||
for key in publish_keys}}
|
||||
|
||||
|
||||
@@ -176,28 +171,9 @@ 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, flags=re.ASCII):
|
||||
if release_tag_policy == "none" or not re.fullmatch(r"v.*" if release_tag_policy == "v-prefix" else r"v\d+\.\d+\.\d+", tag):
|
||||
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:
|
||||
@@ -215,35 +191,21 @@ 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 = kind != "test" and 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 and not maintenance:
|
||||
if kind == "test" and not tag:
|
||||
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-hotfix": "/(develop|release/.*|hotfix/.*)/",
|
||||
"non-release-no-main-hotfix": "/(develop|main|release/.*|hotfix/.*)/",
|
||||
"feature-no-hotfix": "/(develop|main|release/.*|hotfix/.*|integration.*)/"}
|
||||
"non-release-no-main": "/(develop|main|release/.*)/"}
|
||||
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" and not maintenance else False
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" 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"}],
|
||||
@@ -445,13 +407,7 @@ def voyage_template(config, branch, tag):
|
||||
return json.loads(json.dumps(VOYAGE_TEMPLATE).replace("__ORB_VERSION__", config["orb_version"]))
|
||||
|
||||
|
||||
def repository_policy_template(config, branch, tag):
|
||||
del config, branch, tag
|
||||
return copy.deepcopy(REPOSITORY_POLICY_TEMPLATE)
|
||||
|
||||
|
||||
PROFILE_TEMPLATES = {"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}
|
||||
|
||||
@@ -485,12 +441,6 @@ 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"])
|
||||
|
||||
@@ -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') in ('publish_release_candidate', 'verify') and c.get('app', {}).get('id') == 18001]
|
||||
if c.get('name') == 'publish_release_candidate' and c.get('app', {}).get('id') == 18001]
|
||||
if not publishers:
|
||||
return 'publisher-running'
|
||||
publisher = max(publishers, key=lambda c: c['id'])
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
{
|
||||
"run": {
|
||||
"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"
|
||||
"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"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -198,10 +198,20 @@
|
||||
"caller": {
|
||||
"name": "Database migrations",
|
||||
"on": {
|
||||
"pull_request": {},
|
||||
"pull_request": {
|
||||
"paths": [
|
||||
"db/**",
|
||||
"pom.xml",
|
||||
".github/workflows/db-migrations.yml"
|
||||
]
|
||||
},
|
||||
"push": {
|
||||
"branches": [
|
||||
"main"
|
||||
],
|
||||
"paths": [
|
||||
"db/**",
|
||||
"pom.xml"
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -212,10 +222,6 @@
|
||||
"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' }}"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -256,6 +262,11 @@
|
||||
"main"
|
||||
]
|
||||
},
|
||||
"schedule": [
|
||||
{
|
||||
"cron": "17 6 * * *"
|
||||
}
|
||||
],
|
||||
"workflow_dispatch": null
|
||||
},
|
||||
"permissions": {
|
||||
@@ -263,7 +274,7 @@
|
||||
},
|
||||
"concurrency": {
|
||||
"group": "e2e-${{ github.ref }}",
|
||||
"cancel-in-progress": "${{ github.event_name == 'pull_request' }}"
|
||||
"cancel-in-progress": true
|
||||
},
|
||||
"jobs": {
|
||||
"validate": {
|
||||
@@ -427,45 +438,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"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\nfrom pathlib import Path\nimport subprocess\nimport xml.etree.ElementTree as ET\nimport yaml\n\npaths = subprocess.check_output(['git', 'ls-files', '-z']).decode('utf-8').split('\\0')\npaths = [Path(name) for name in paths if name]\nif not paths:\n raise SystemExit('No tracked policy files')\nnames = {'LICENSE', 'NOTICE', 'COPYING', 'CODEOWNERS', '.gitignore', '.gitattributes',\n '.editorconfig', 'mvnw', 'mvnw.cmd'}\nsuffixes = {'.md', '.rst', '.txt', '.adoc', '.yml', '.yaml', '.json', '.properties'}\nmanifests = {'pom.xml', 'package.json', 'cargo.toml', 'pyproject.toml', 'go.mod',\n 'build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'}\nfor path in paths:\n if path.is_symlink() or path.name.lower() in manifests:\n raise SystemExit(f'Application or symlink requires a build profile: {path}')\n if path.as_posix() == '.mvn/wrapper/maven-wrapper.jar':\n continue\n if path.as_posix() == 'checkstyle/config.xml':\n ET.fromstring(path.read_text(encoding='utf-8'))\n continue\n if path.name not in names and path.suffix.lower() not in suffixes:\n raise SystemExit(f'Unsupported policy file; select a build profile: {path}')\n text = path.read_text(encoding='utf-8')\n if path.suffix.lower() in ('.yml', '.yaml'):\n list(yaml.safe_load_all(text))\n elif path.suffix.lower() == '.json':\n json.loads(text)\nprint(f'Validated {len(paths)} tracked policy/documentation files; no application build or publication')\nPYTHON\n"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"workflows": {
|
||||
"verify": {
|
||||
"jobs": [
|
||||
"validate-policy"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ PROFILE_PARAMETERS = {
|
||||
"app-starter": {},
|
||||
"android": {},
|
||||
"mcp-policy": {},
|
||||
"repository-policy": {},
|
||||
"marketing": {},
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ def load_yaml(raw):
|
||||
raise StandardError("Invalid YAML declaration") from error
|
||||
|
||||
|
||||
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None, publish_feature=False):
|
||||
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None):
|
||||
if not isinstance(profile, str) or profile not in PROFILE_PARAMETERS:
|
||||
raise StandardError("Unsupported CI profile")
|
||||
options = {
|
||||
@@ -73,9 +72,6 @@ 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]
|
||||
@@ -113,11 +109,8 @@ def validate(config_raw, manifest_raw, setup_version):
|
||||
raise StandardError("Manifest must pin an explicit orb version")
|
||||
if version != setup_version:
|
||||
raise StandardError("Manifest and running setup orb versions differ")
|
||||
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))
|
||||
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"))
|
||||
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")
|
||||
|
||||
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
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\/.*/
|
||||
-1835
File diff suppressed because it is too large.
Load diff
+1
-183
@@ -26,148 +26,6 @@ class Snapshot:
|
||||
|
||||
|
||||
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)
|
||||
@@ -216,25 +74,6 @@ 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
|
||||
@@ -387,31 +226,10 @@ 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],
|
||||
['release/*'], ['release/1.2/extra'], ['hotfix/1..2'],
|
||||
['release/1.2', 'release/1.2']]:
|
||||
for managed in [[], ['main', 'main'], ['feature'], 'main', None, [True]]:
|
||||
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')
|
||||
|
||||
@@ -58,14 +58,12 @@ 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_gate_reports_for_every_pr_and_preserves_validation(self):
|
||||
def test_business_database_job_and_path_filters_are_unchanged(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'], {'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(caller['on'], original['events'])
|
||||
self.assertEqual(set(worker['jobs']), {'empty-database-migration'})
|
||||
self.assertNotIn('secrets', caller['jobs']['validate'])
|
||||
self.assertNotIn('schedule', caller['on'])
|
||||
|
||||
@@ -29,14 +29,11 @@ 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_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'])
|
||||
def test_events_permissions_path_and_single_concurrency_owner_preserved(self):
|
||||
self.assertEqual(self.original['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']['group'], self.caller['concurrency']['group'])
|
||||
self.assertEqual("${{ github.event_name == 'pull_request' }}", self.caller['concurrency']['cancel-in-progress'])
|
||||
self.assertEqual(self.original['workflow']['concurrency'], self.caller['concurrency'])
|
||||
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'])
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
"""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_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()
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/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()
|
||||
@@ -192,45 +192,14 @@ class PipelineTests(unittest.TestCase):
|
||||
return result
|
||||
|
||||
def assert_full(self, result, workflow="test_only"):
|
||||
self.assertEqual(list(result["workflows"]), ["verify"])
|
||||
self.assertEqual(list(result["workflows"]), [workflow])
|
||||
self.assertNotIn("docs_only", result.get("jobs", {}))
|
||||
job, options = next(iter(result["workflows"]["verify"]["jobs"][0].items()))
|
||||
job, options = next(iter(result["workflows"][workflow]["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"])
|
||||
@@ -256,46 +225,6 @@ 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_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_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"])
|
||||
@@ -369,8 +298,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"]), ["verify"])
|
||||
options = result["workflows"]["verify"]["jobs"][0]["docs_only"]
|
||||
self.assertEqual(list(result["workflows"]), ["test_only"])
|
||||
options = result["workflows"]["test_only"]["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")
|
||||
@@ -431,8 +360,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"]), ["verify"])
|
||||
actual = result["workflows"]["verify"]["jobs"]
|
||||
self.assertEqual(list(result["workflows"]), [workflow])
|
||||
actual = result["workflows"][workflow]["jobs"]
|
||||
expected = baseline["workflows"][workflow]["jobs"]
|
||||
self.assertEqual(len(actual), len(expected))
|
||||
for before, after in zip(expected, actual):
|
||||
@@ -493,8 +422,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"]), ["verify"])
|
||||
jobs = result["workflows"]["verify"]["jobs"]
|
||||
self.assertEqual(list(result["workflows"]), [workflow])
|
||||
jobs = result["workflows"][workflow]["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)
|
||||
@@ -525,10 +454,8 @@ 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"]), ["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)
|
||||
self.assertEqual(list(result["workflows"]), [workflow])
|
||||
options = next(iter(result["workflows"][workflow]["jobs"][0].values()))
|
||||
if profile == "frontend-core":
|
||||
self.assertTrue(options["npm_trusted_publishing"])
|
||||
self.assertEqual(options["node_version"], "24.21")
|
||||
@@ -536,9 +463,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"]), ["verify"])
|
||||
self.assertEqual(list(main["workflows"]), ["publish_release" if profile == "frontend-core" else "test_only"])
|
||||
rc_tag = self.render(CIRCLE_BRANCH="", CIRCLE_TAG="v1.0.0-RC.1")
|
||||
self.assertEqual(list(rc_tag["workflows"]), ["verify"])
|
||||
self.assertEqual(list(rc_tag["workflows"]), ["publish_release" if profile == "frontend-core" else "test_only"])
|
||||
|
||||
def test_profile_specific_options_rejected(self):
|
||||
for profile, options in [("qbit", {"node_version": "22"}), ("frontend-core", {"browsers": False}),
|
||||
@@ -605,8 +532,7 @@ class PipelineTests(unittest.TestCase):
|
||||
{"CIRCLE_BRANCH": "integration-example"}):
|
||||
result = self.render(**environment)
|
||||
if environment.get("CIRCLE_BRANCH") != "integration-example":
|
||||
self.assertEqual(list(result["workflows"]), ["verify"])
|
||||
self.assertEqual(result["workflows"]["verify"]["jobs"][0]["qqq-orb/mvn_publish"]["branch_type"], "release")
|
||||
self.assertIn("publish_release", result["workflows"])
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, **environment))
|
||||
|
||||
|
||||
@@ -35,16 +35,13 @@ 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", "recover", "circle_build", "merge_sha", "bump_sha", "branch", "version"}, set(inputs))
|
||||
self.assertEqual({"dry_run", "finalize", "merge_sha", "bump_sha", "branch", "version"}, set(inputs))
|
||||
self.assertEqual(set(inputs), set(passed))
|
||||
for name in ("dry_run", "finalize", "recover"):
|
||||
for name in ("dry_run", "finalize"):
|
||||
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"])
|
||||
|
||||
@@ -6,7 +6,6 @@ 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"
|
||||
@@ -15,11 +14,6 @@ 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"
|
||||
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
|
||||
@@ -38,7 +32,6 @@ 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"
|
||||
@@ -89,9 +82,4 @@ 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'
|
||||
@@ -38,9 +38,7 @@ class MobilePolicyTests(unittest.TestCase):
|
||||
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("\\<<", "<<")
|
||||
command = steps[2]["run"]["command"]
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = Path(folder)
|
||||
runner = root / "gradlew"
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
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()
|
||||
@@ -1,73 +0,0 @@
|
||||
"""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()
|
||||
@@ -1,73 +0,0 @@
|
||||
"""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()
|
||||
@@ -58,17 +58,6 @@ 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))
|
||||
|
||||
@@ -23,17 +23,6 @@ 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()))
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
"""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()
|
||||
@@ -1,136 +0,0 @@
|
||||
"""A timeout recovery must prove the original upload, not forgive a failed build."""
|
||||
import copy
|
||||
import unittest
|
||||
|
||||
from test_rc_guard import scope, SHA, OTHER, Failure, bump, status, evaluate
|
||||
|
||||
REPO = 'QRun-IO/qbit-alerts'
|
||||
WORKFLOW = '86efe478-29d6-41a4-93f0-d74b178bf329'
|
||||
DEPLOYMENT = '993e5a6d-23ce-4696-8e5a-9176ae19e670'
|
||||
VERSION = '0.1.0-RC.17'
|
||||
PURL = 'pkg:maven/com.kingsrook.qbits/qbit-alerts@' + VERSION
|
||||
|
||||
|
||||
def evidence():
|
||||
publisher = status('failure')['check_runs'][0]
|
||||
publisher['details_url'] = 'https://app.circleci.com/workflow/' + WORKFLOW + '?utm_source=github'
|
||||
job = {'username': 'QRun-IO', 'reponame': 'qbit-alerts', 'vcs_revision': SHA,
|
||||
'branch': 'release/0.1', 'build_num': 148, 'status': 'failed', 'outcome': 'failed',
|
||||
'start_time': '2026-10-21T00:01:00Z',
|
||||
'workflows': {'workflow_name': 'publish_release_candidate',
|
||||
'job_name': 'qqq-orb/mvn_publish', 'workflow_id': WORKFLOW},
|
||||
'steps': [{'actions': [{'name': 'Run Maven Verify', 'status': 'success'}]},
|
||||
{'actions': [{'name': 'Publish to Sonatype Central (releases and SNAPSHOTs)',
|
||||
'status': 'timedout', 'timedout': True, 'step': 124, 'index': 0}]}]}
|
||||
return job, publisher
|
||||
|
||||
|
||||
def validate(job, publisher):
|
||||
return scope['validate_timeout'](job, publisher, REPO, SHA, 'release/0.1', '148', '2026-10-21T00:00:00Z')
|
||||
|
||||
|
||||
class TimeoutRecoveryTests(unittest.TestCase):
|
||||
def test_stable_gate_must_match_the_actual_publishing_workflow(self):
|
||||
job, publisher = evidence()
|
||||
job['workflows']['workflow_name'] = 'verify'
|
||||
publisher['name'] = 'verify'
|
||||
validate(job, publisher)
|
||||
publisher['name'] = 'publish_release_candidate'
|
||||
with self.assertRaises(Failure):
|
||||
validate(job, publisher)
|
||||
|
||||
def test_exact_upload_timeout_after_successful_verify(self):
|
||||
self.assertEqual((124, 0), validate(*evidence()))
|
||||
|
||||
def test_other_source_branch_repository_or_attempt_is_rejected(self):
|
||||
for key, value in [('vcs_revision', OTHER), ('branch', 'develop'),
|
||||
('username', 'untrusted'), ('reponame', 'other'), ('build_num', 149)]:
|
||||
with self.subTest(key=key), self.assertRaises(Failure):
|
||||
job, publisher = evidence()
|
||||
job[key] = value
|
||||
validate(job, publisher)
|
||||
|
||||
def test_non_circle_or_unrelated_workflow_cannot_authorize_recovery(self):
|
||||
for key, value in [('head_sha', OTHER), ('app', {'id': 1}), ('status', 'in_progress'),
|
||||
('conclusion', 'success'), ('name', 'test_only'),
|
||||
('details_url', 'https://example.com/workflow/' + WORKFLOW),
|
||||
('details_url', 'https://app.circleci.com/workflow/another')]:
|
||||
with self.subTest(key=key, value=value), self.assertRaises(Failure):
|
||||
job, publisher = evidence()
|
||||
publisher[key] = value
|
||||
validate(job, publisher)
|
||||
|
||||
def test_prior_failure_or_missing_verify_never_becomes_release_success(self):
|
||||
for action in [{'name': 'Run Maven Verify', 'status': 'failed'},
|
||||
{'name': 'Run Maven Verify', 'status': 'skipped'},
|
||||
{'name': 'Some other build', 'status': 'success'}]:
|
||||
with self.subTest(action=action), self.assertRaises(Failure):
|
||||
job, publisher = evidence()
|
||||
job['steps'][0]['actions'][0] = action
|
||||
validate(job, publisher)
|
||||
|
||||
def test_only_a_terminal_deployment_timeout_is_eligible(self):
|
||||
for change in [{'name': 'Run Maven Verify'}, {'timedout': False}, {'status': 'failed'},
|
||||
{'step': -1}, {'index': '0'}]:
|
||||
with self.subTest(change=change), self.assertRaises(Failure):
|
||||
job, publisher = evidence()
|
||||
job['steps'][-1]['actions'][0].update(change)
|
||||
validate(job, publisher)
|
||||
|
||||
def test_failed_later_git_push_is_not_an_upload_timeout(self):
|
||||
job, publisher = evidence()
|
||||
job['steps'].append({'actions': [{'name': 'Commit version', 'status': 'failed'}]})
|
||||
with self.assertRaises(Failure):
|
||||
validate(job, publisher)
|
||||
|
||||
def test_publisher_cannot_predate_the_cut(self):
|
||||
job, publisher = evidence()
|
||||
job['start_time'] = '2026-10-20T23:59:00Z'
|
||||
with self.assertRaises(Failure):
|
||||
validate(job, publisher)
|
||||
|
||||
def test_receipt_requires_one_upload_and_expected_staged_coordinates(self):
|
||||
log = ('[INFO] Installing x to /home/circleci/project/target/central-staging/'
|
||||
'com/kingsrook/qbits/qbit-alerts/' + VERSION + '/qbit-alerts-' + VERSION + '.pom\n'
|
||||
'[INFO] Uploaded bundle successfully, deployment name: Deployment, deploymentId: '
|
||||
+ DEPLOYMENT + '. Deployment will publish automatically\n')
|
||||
self.assertEqual((DEPLOYMENT, [PURL]), scope['upload_receipt'](log, 'qbit-alerts', VERSION))
|
||||
for invalid in [log + log, log.replace('Uploaded bundle successfully', 'Upload failed'),
|
||||
log.replace('qbit-alerts', 'qbit-other'), log.replace(VERSION, '0.1.0-RC.16')]:
|
||||
with self.subTest(invalid=invalid), self.assertRaises(Failure):
|
||||
scope['upload_receipt'](invalid, 'qbit-alerts', VERSION)
|
||||
|
||||
def test_central_must_confirm_the_exact_receipt_and_all_coordinates(self):
|
||||
result = {'deploymentId': DEPLOYMENT, 'deploymentState': 'PUBLISHED', 'purls': [PURL]}
|
||||
scope['validate_deployment'](result, DEPLOYMENT, [PURL])
|
||||
for key, value in [('deploymentId', 'other'), ('deploymentState', 'PUBLISHING'),
|
||||
('deploymentState', 'FAILED'), ('purls', []), ('purls', [PURL, 'other'])]:
|
||||
with self.subTest(key=key, value=value), self.assertRaises(Failure):
|
||||
invalid = copy.deepcopy(result)
|
||||
invalid[key] = value
|
||||
scope['validate_deployment'](invalid, DEPLOYMENT, [PURL])
|
||||
|
||||
def test_retry_bump_cannot_hide_other_source_changes(self):
|
||||
source = '<project><revision>0.1.0-RC.16</revision><name>Alerts</name></project>'
|
||||
actual = source.replace('0.1.0-RC.16', VERSION)
|
||||
commit = bump(version=VERSION)
|
||||
commit['files'] = [{'filename': 'pom.xml', 'status': 'modified'}]
|
||||
scope['validate_recovery_bump'](commit, source, actual, VERSION, SHA)
|
||||
for changed in [actual.replace('Alerts', 'Other'), actual + '<extra/>', source]:
|
||||
with self.subTest(changed=changed), self.assertRaises(Failure):
|
||||
scope['validate_recovery_bump'](commit, source, changed, VERSION, SHA)
|
||||
commit['files'].append({'filename': 'other.java', 'status': 'modified'})
|
||||
with self.assertRaises(Failure):
|
||||
scope['validate_recovery_bump'](commit, source, actual, VERSION, SHA)
|
||||
|
||||
def test_recovery_still_requires_exact_bump_parent_and_verified_version(self):
|
||||
self.assertEqual(VERSION, evaluate(SHA, status('failure'), bump(version=VERSION), VERSION))
|
||||
for commit in [bump(parent=OTHER, version=VERSION), bump(version='0.1.0-RC.18')]:
|
||||
with self.subTest(commit=commit), self.assertRaises(Failure):
|
||||
evaluate(SHA, status('failure'), commit, VERSION)
|
||||
with self.assertRaises(Failure):
|
||||
evaluate(SHA, status('failure'), bump(version=VERSION))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,89 +0,0 @@
|
||||
"""Execute the policy job against real git indexes, including application promotion."""
|
||||
import importlib.util
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
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)
|
||||
TEMPLATE = json.loads((ROOT / 'src/scripts/templates/repository-policy.json').read_text())
|
||||
SCRIPT = TEMPLATE['jobs']['validate-policy']['steps'][-1]['run']['command'].split("<<'PYTHON'\n", 1)[1].rsplit('PYTHON', 1)[0]
|
||||
|
||||
|
||||
class RepositoryPolicyTests(unittest.TestCase):
|
||||
def test_packing_is_independent_of_checkout_line_endings(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
shutil.copytree(ROOT / 'src/scripts', root / 'src/scripts')
|
||||
(root / 'scripts').mkdir()
|
||||
shutil.copy(ROOT / 'scripts/pack_pipeline.py', root / 'scripts/pack_pipeline.py')
|
||||
resources = list((root / 'src/scripts/templates').glob('*.json'))
|
||||
for resource in resources:
|
||||
resource.write_bytes(resource.read_bytes().replace(b'\r\n', b'\n'))
|
||||
subprocess.run([sys.executable, str(root / 'scripts/pack_pipeline.py')], check=True)
|
||||
packed = (root / 'src/scripts/packed_generate_pipeline.py').read_bytes()
|
||||
for resource in resources:
|
||||
resource.write_bytes(resource.read_bytes().replace(b'\n', b'\r\n'))
|
||||
subprocess.run([sys.executable, str(root / 'scripts/pack_pipeline.py'), '--check'], check=True)
|
||||
self.assertEqual(packed, (root / 'src/scripts/packed_generate_pipeline.py').read_bytes())
|
||||
|
||||
def execute(self, files, untracked=None):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
subprocess.run(['git', 'init', '-q'], cwd=root, check=True)
|
||||
for name, content in files.items():
|
||||
file = root / name
|
||||
file.parent.mkdir(parents=True, exist_ok=True)
|
||||
file.write_text(content, encoding='utf-8')
|
||||
subprocess.run(['git', 'add', '.'], cwd=root, check=True)
|
||||
for name, content in (untracked or {}).items():
|
||||
(root / name).write_text(content, encoding='utf-8')
|
||||
return subprocess.run([sys.executable, '-c', SCRIPT], cwd=root, capture_output=True, text=True)
|
||||
|
||||
def test_placeholder_with_wrappers_and_workflows(self):
|
||||
result = self.execute({'LICENSE': 'Apache-2.0', 'docs/DESIGN.md': '# Planned application',
|
||||
'.github/workflows/release-rc.yml': 'name: Release\non: workflow_dispatch\n',
|
||||
'.mvn/wrapper/maven-wrapper.properties': 'distributionUrl=https://example.invalid/maven.zip',
|
||||
'mvnw': '#!/bin/sh\n', 'mvnw.cmd': '@echo off\n'})
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
|
||||
def test_new_application_requires_real_build_profile(self):
|
||||
for name in ('pom.xml', 'package.json', 'src/App.java', 'main.py', 'main.go', 'Dockerfile'):
|
||||
with self.subTest(name=name):
|
||||
self.assertNotEqual(0, self.execute({'LICENSE': 'license', name: '{}'}).returncode)
|
||||
|
||||
def test_malformed_configuration_fails(self):
|
||||
for name in ('.github/dependabot.yml', 'settings.json'):
|
||||
with self.subTest(name=name):
|
||||
self.assertNotEqual(0, self.execute({name: '[unterminated'}).returncode)
|
||||
|
||||
def test_unused_checkstyle_policy_is_validated_without_allowing_application_xml(self):
|
||||
self.assertEqual(0, self.execute({'checkstyle/config.xml': '<module name="Checker"/>'}).returncode)
|
||||
self.assertNotEqual(0, self.execute({'checkstyle/config.xml': '<module>'}).returncode)
|
||||
self.assertNotEqual(0, self.execute({'application.xml': '<application/>'}).returncode)
|
||||
self.assertNotEqual(0, self.execute({'pom.xml': '<project/>'}).returncode)
|
||||
|
||||
def test_only_tracked_files_are_policy_inputs(self):
|
||||
self.assertEqual(0, self.execute({'README.md': '# Docs'}, {'main.py': 'temporary tool'}).returncode)
|
||||
|
||||
def test_manifest_cannot_enable_publication(self):
|
||||
manifest = {'profile': 'repository-policy', 'orb_version': '0.7.14', 'default_branch': 'develop'}
|
||||
with patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
config = pipeline.load_manifest('unused', '0.7.14')
|
||||
self.assertFalse(any(config['publish'].values()))
|
||||
self.assertEqual({'verify': {'jobs': ['validate-policy']}}, pipeline.repository_policy_template(config, 'main', '')['workflows'])
|
||||
manifest['publish'] = {'release': True}
|
||||
with patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)), self.assertRaises(pipeline.ManifestError):
|
||||
pipeline.load_manifest('unused', '0.7.14')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,109 +0,0 @@
|
||||
"""Version rollouts preserve policy and reject drift before changing any repo."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import yaml
|
||||
|
||||
spec = importlib.util.spec_from_file_location('rollout', Path(__file__).resolve().parents[1] / 'tools/rollout_version.py')
|
||||
rollout = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(rollout)
|
||||
|
||||
|
||||
class RolloutTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
|
||||
def checkout(self, name, profile='qbit', explicit=False, **policy):
|
||||
root = self.root / name
|
||||
(root / '.circleci').mkdir(parents=True)
|
||||
manifest = {'profile': profile, 'orb_version': '0.7.4', 'default_branch': 'develop', **policy}
|
||||
caller = rollout.standard.canonical_caller(profile, '0.7.4', explicit_manifest=explicit,
|
||||
release_tag_policy=manifest.get('release_tag_policy'))
|
||||
(root / '.qqq-ci.yml').write_text(yaml.safe_dump(manifest), encoding='utf-8')
|
||||
(root / '.circleci/config.yml').write_text(yaml.safe_dump(caller), encoding='utf-8')
|
||||
return root
|
||||
|
||||
def contents(self, root):
|
||||
return [(root / path).read_bytes() for path in ('.circleci/config.yml', '.qqq-ci.yml')]
|
||||
|
||||
def test_batch_preserves_opt_outs_filters_contexts_and_forwarded_parameters(self):
|
||||
qbit = self.checkout('qbit', release_tag_policy='none', release_on_main=False,
|
||||
test_branch_policy='feature', browsers=False,
|
||||
publish={'snapshot': False, 'release_candidate': False, 'release': False})
|
||||
core = self.checkout('core', profile='core', explicit=True)
|
||||
cli = self.checkout('cli', profile='cli', publish={'release': True}, publish_context='npm-publisher')
|
||||
roots = [qbit, core, cli]
|
||||
originals = [yaml.safe_load((root / '.qqq-ci.yml').read_text()) for root in roots]
|
||||
results = rollout.rollout(roots, '0.7.11', write=True)
|
||||
self.assertTrue(all(result['changed'] for result in results))
|
||||
for root, original in zip(roots, originals):
|
||||
expected = {**original, 'orb_version': '0.7.11'}
|
||||
self.assertEqual(expected, yaml.safe_load((root / '.qqq-ci.yml').read_text()))
|
||||
rollout.standard.validate(*(data.decode() for data in self.contents(root)), '0.7.11')
|
||||
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.7.11')
|
||||
core_caller = yaml.safe_load((core / '.circleci/config.yml').read_text())
|
||||
options = core_caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']
|
||||
self.assertEqual('.qqq-ci.yml', options['manifest'])
|
||||
self.assertEqual('<< pipeline.parameters.mongo_bind_diagnostics >>', options['mongo_bind_diagnostics'])
|
||||
|
||||
def test_all_supported_profiles_remain_valid_after_the_same_batch_upgrade(self):
|
||||
roots = [self.checkout(profile, profile=profile, default_branch='main') for profile in rollout.standard.PROFILE_PARAMETERS]
|
||||
results = rollout.rollout(roots, '0.7.11', write=True)
|
||||
self.assertEqual(set(rollout.standard.PROFILE_PARAMETERS), {item['profile'] for item in results})
|
||||
for root in roots:
|
||||
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.7.11')
|
||||
rollout.standard.validate(*(data.decode() for data in self.contents(root)), '0.7.11')
|
||||
|
||||
def test_dry_run_and_repeated_application_do_not_rewrite_files(self):
|
||||
root = self.checkout('qbit')
|
||||
before = self.contents(root)
|
||||
self.assertTrue(rollout.rollout([root], '0.7.11')[0]['changed'])
|
||||
self.assertEqual(before, self.contents(root))
|
||||
rollout.rollout([root], '0.7.11', write=True)
|
||||
applied = self.contents(root)
|
||||
self.assertFalse(rollout.rollout([root], '0.7.11', write=True)[0]['changed'])
|
||||
self.assertEqual(applied, self.contents(root))
|
||||
|
||||
def test_one_custom_caller_rejects_entire_batch_before_any_write(self):
|
||||
good = self.checkout('good')
|
||||
bad = self.checkout('bad')
|
||||
before = self.contents(good)
|
||||
with (bad / '.circleci/config.yml').open('a') as stream:
|
||||
stream.write('\njobs: {custom: {steps: [checkout]}}\n')
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([good, bad], '0.7.11', write=True)
|
||||
self.assertEqual(before, self.contents(good))
|
||||
|
||||
def test_duplicate_manifest_keys_unknown_settings_and_mismatched_pins_are_rejected(self):
|
||||
for suffix in ['orb_version: 0.7.4\n', 'unknown_setting: true\n', 'publish: {release: maybe}\n']:
|
||||
with self.subTest(suffix=suffix):
|
||||
root = self.checkout(str(len(list(self.root.iterdir()))))
|
||||
with (root / '.qqq-ci.yml').open('a') as stream:
|
||||
stream.write(suffix)
|
||||
before = self.contents(root)
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([root], '0.7.11', write=True)
|
||||
self.assertEqual(before, self.contents(root))
|
||||
root = self.checkout('mismatch')
|
||||
path = root / '.circleci/config.yml'
|
||||
path.write_text(path.read_text().replace('0.7.4', '0.7.3'))
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([root], '0.7.11', write=True)
|
||||
|
||||
def test_invalid_target_and_duplicate_checkout_are_rejected(self):
|
||||
root = self.checkout('qbit')
|
||||
before = self.contents(root)
|
||||
for version in ['latest', 'dev:test', '0.7', '0.7.11\n']:
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([root], version, write=True)
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([root, root], '0.7.11', write=True)
|
||||
self.assertEqual(before, self.contents(root))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+17
-52
@@ -6,10 +6,6 @@ Example: python tools/audit_estate.py --inventory inventory.json --orb-version 0
|
||||
Policy: {"profiles":{"qbit":{"required_checks":{"main":["observed context"],
|
||||
"develop":["observed context"]}}},"repositories":{"QRun-IO/example":{...}}}.
|
||||
Only use contexts verified on hosted canaries. Absent policy is unknown, not pass.
|
||||
Use --live --source-branch main (or release/...) to inspect that branch's source;
|
||||
omitting it retains default-branch auditing. Unavailable branches remain unknown.
|
||||
A profile/repository policy may set rc_worker_sha independently of --worker-sha
|
||||
so an RC-only worker change does not require updating unchanged native workers.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
@@ -73,17 +69,11 @@ class Snapshot:
|
||||
raise ReadError('invalid repository name')
|
||||
self.live = live
|
||||
self.path = entry.get('localPath', '')
|
||||
requested = entry.get('sourceBranch')
|
||||
if requested is not None and (not live or not isinstance(requested, str)
|
||||
or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9._/-]*', requested)):
|
||||
raise ReadError('explicit source branch requires a valid branch name and live lookup')
|
||||
self.default_branch = (entry.get('defaultBranchRef') or {}).get('name')
|
||||
self.branch = requested or self.default_branch
|
||||
self.branch = (entry.get('defaultBranchRef') or {}).get('name')
|
||||
self.sha = entry.get('sha', '')
|
||||
if live:
|
||||
info = gh('repos/' + self.repo)
|
||||
self.default_branch = info['default_branch']
|
||||
self.branch = requested or self.default_branch
|
||||
self.branch = info['default_branch']
|
||||
if info['archived']:
|
||||
raise ReadError('repository is now archived; refresh inventory')
|
||||
self.sha = gh('repos/' + self.repo + '/commits/' + quote(self.branch, safe=''))['sha']
|
||||
@@ -175,10 +165,9 @@ def owner_gate_errors(snapshot):
|
||||
|
||||
def audit(entry, snapshot, version, worker_sha, policy):
|
||||
name = entry['name']
|
||||
profile = policy.get('branch_profiles', {}).get(snapshot.branch) or policy.get('profile') or ('qbit' if name.startswith('qbit-') else PROFILES.get(name))
|
||||
profile = policy.get('profile') or ('qbit' if name.startswith('qbit-') else PROFILES.get(name))
|
||||
result = {'repository': entry['nameWithOwner'], 'sha': snapshot.sha,
|
||||
'default_branch': getattr(snapshot, 'default_branch', snapshot.branch),
|
||||
'source_branch': snapshot.branch, 'profile': profile, 'findings': [], 'required_checks': {}}
|
||||
'default_branch': snapshot.branch, 'profile': profile, 'findings': [], 'required_checks': {}}
|
||||
findings = result['findings']
|
||||
def finding(code, path=None, detail=None):
|
||||
findings.append({k: v for k, v in {'code': code, 'path': path, 'detail': detail}.items() if v is not None})
|
||||
@@ -207,7 +196,7 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
manifest = Path(directory) / 'manifest.yml'
|
||||
manifest.write_text(raw, encoding='utf-8')
|
||||
generator.load_manifest(manifest, pin)
|
||||
if data.get('default_branch') != result['default_branch']:
|
||||
if data.get('default_branch') != snapshot.branch:
|
||||
finding('default_branch_drift', '.qqq-ci.yml')
|
||||
if caller is not None:
|
||||
standard.validate(caller, raw, pin)
|
||||
@@ -217,15 +206,14 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
native_paths = set()
|
||||
rc_source = snapshot.read(rc_worker.CALLER_PATH)
|
||||
existing_rc = rc_source is not None and 'qbit-release-rc.yml@' in rc_source
|
||||
if profile in ('qbit', 'repository-policy') and (rc_enabled or existing_rc):
|
||||
if profile == 'qbit' and (rc_enabled or existing_rc):
|
||||
path = rc_worker.CALLER_PATH
|
||||
raw = rc_source
|
||||
rc_sha = policy.get("rc_worker_sha", worker_sha)
|
||||
if raw is None:
|
||||
finding('missing_rc_bridge', path)
|
||||
elif not re.fullmatch(r'[0-9a-f]{40}', rc_sha or ''):
|
||||
elif not re.fullmatch(r'[0-9a-f]{40}', worker_sha or ''):
|
||||
finding('native_pin_policy_missing', path)
|
||||
elif raw != rc_worker.generate(rc_sha):
|
||||
elif raw != rc_worker.generate(worker_sha):
|
||||
finding('rc_bridge_drift', path)
|
||||
else:
|
||||
native_paths.add(path)
|
||||
@@ -233,30 +221,17 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
if other != path and 'qbit-release-rc.yml@' in snapshot.read(other):
|
||||
finding('duplicate_rc_bridge', other)
|
||||
for kind, definition in auxiliary.BRIDGES.items():
|
||||
bridge_sha = worker_sha
|
||||
if kind == 'qbit-codeql':
|
||||
if profile not in ('qbit', 'repository-policy', 'all') or 'codeql_worker_sha' not in policy:
|
||||
continue
|
||||
bridge_sha = policy['codeql_worker_sha']
|
||||
elif definition['repository'] != entry['nameWithOwner']:
|
||||
if definition['repository'] != entry['nameWithOwner']:
|
||||
continue
|
||||
path = definition['path']
|
||||
raw = snapshot.read(path)
|
||||
if kind == 'all-release' and profile == 'repository-policy' and raw is None:
|
||||
continue
|
||||
# Older release branches can predate Authentik's schema contract test.
|
||||
# Keep the default branch required, and validate every existing bridge.
|
||||
if (kind == 'qbit-schema-drift' and raw is None
|
||||
and snapshot.branch != result['default_branch']
|
||||
and not any(path.endswith('/SchemaDriftTest.java') for path in snapshot.paths)):
|
||||
continue
|
||||
if raw is None:
|
||||
finding('missing_native_maintenance_bridge', path)
|
||||
continue
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', bridge_sha or ''):
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', worker_sha or ''):
|
||||
finding('native_pin_policy_missing', path)
|
||||
continue
|
||||
expected = generator.yaml.safe_dump(auxiliary.canonical(kind, bridge_sha), sort_keys=False)
|
||||
expected = generator.yaml.safe_dump(auxiliary.canonical(kind, worker_sha), sort_keys=False)
|
||||
if raw != expected:
|
||||
finding('native_maintenance_bridge_drift', path)
|
||||
else:
|
||||
@@ -318,11 +293,9 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
branches = policy.get('required_checks', {})
|
||||
managed = policy.get('managed_branches', ['main', 'develop'])
|
||||
if (not isinstance(managed, list) or not managed
|
||||
or any(not isinstance(branch, str) or not re.fullmatch(
|
||||
r'(?:main|develop|(?:release|hotfix)/[0-9]+\.[0-9]+(?:\.[0-9]+)?)', branch)
|
||||
for branch in managed)
|
||||
or any(branch not in ('main', 'develop') for branch in managed)
|
||||
or len(set(managed)) != len(managed)):
|
||||
raise ReadError('managed_branches must be a nonempty unique main/develop or numeric release/hotfix list')
|
||||
raise ReadError('managed_branches must be a nonempty unique main/develop list')
|
||||
result['managed_branches'] = managed
|
||||
for branch in managed:
|
||||
if branch not in branches:
|
||||
@@ -348,13 +321,9 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
return result
|
||||
|
||||
|
||||
def run(entries, version, worker_sha, policies, live=False, snapshot_factory=Snapshot, source_branch=None):
|
||||
if source_branch is not None and not live:
|
||||
raise ValueError('Explicit source branch audits require --live')
|
||||
def run(entries, version, worker_sha, policies, live=False, snapshot_factory=Snapshot):
|
||||
results = []
|
||||
for entry in entries:
|
||||
if source_branch is not None:
|
||||
entry = dict(entry, sourceBranch=source_branch)
|
||||
if entry.get('isArchived'):
|
||||
results.append({'repository': entry['nameWithOwner'], 'status': 'archived_skip'})
|
||||
continue
|
||||
@@ -365,11 +334,10 @@ def run(entries, version, worker_sha, policies, live=False, snapshot_factory=Sna
|
||||
try:
|
||||
results.append(audit(entry, snapshot_factory(entry, live), version, worker_sha, policy))
|
||||
except (ReadError, OSError, ValueError, KeyError, subprocess.TimeoutExpired):
|
||||
results.append({'repository': entry['nameWithOwner'], 'source_branch': source_branch,
|
||||
'status': 'unknown', 'reason': 'source/API/policy read failed'})
|
||||
results.append({'repository': entry['nameWithOwner'], 'status': 'unknown', 'reason': 'source/API/policy read failed'})
|
||||
return {'inventory_count': len(entries), 'active_count': sum(not e.get('isArchived', False) for e in entries),
|
||||
'covered_count': len(results), 'unique_repository_count': len({e['nameWithOwner'] for e in entries}),
|
||||
'live': live, 'source_branch_selector': source_branch or 'default', 'results': results}
|
||||
'live': live, 'results': results}
|
||||
|
||||
|
||||
def main():
|
||||
@@ -379,15 +347,12 @@ def main():
|
||||
parser.add_argument('--worker-sha')
|
||||
parser.add_argument('--policy', type=Path)
|
||||
parser.add_argument('--live', action='store_true', help='Read current source and branch rules using existing gh authentication')
|
||||
parser.add_argument('--source-branch', help='Inspect this branch instead of the repository default; requires --live')
|
||||
parser.add_argument('--expected-active', type=int, default=68)
|
||||
parser.add_argument('--output', type=Path)
|
||||
args = parser.parse_args()
|
||||
if args.source_branch is not None and not args.live:
|
||||
parser.error('--source-branch requires --live')
|
||||
entries = json.loads(args.inventory.read_text(encoding='utf-8'))
|
||||
policies = json.loads(args.policy.read_text(encoding='utf-8')) if args.policy else {}
|
||||
report = run(entries, args.orb_version, args.worker_sha, policies, args.live, source_branch=args.source_branch)
|
||||
report = run(entries, args.orb_version, args.worker_sha, policies, args.live)
|
||||
report['expected_active_count'] = args.expected_active
|
||||
report['coverage_matches_expected'] = (report['active_count'] == args.expected_active
|
||||
and report['unique_repository_count'] == report['inventory_count'])
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Upgrade canonical CircleCI callers in one batch; dry-run unless --write.
|
||||
|
||||
Only the orb pin changes. Repository publication policy and profile parameters
|
||||
are preserved. Git commits, pushes and hosted verification remain separate.
|
||||
"""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def module(name):
|
||||
spec = importlib.util.spec_from_file_location(name, ROOT / 'src/scripts' / (name + '.py'))
|
||||
result = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(result)
|
||||
return result
|
||||
|
||||
|
||||
standard = module('validate_standard')
|
||||
pipeline = module('generate_pipeline')
|
||||
|
||||
|
||||
def plan(checkout, version):
|
||||
root = Path(checkout).resolve(strict=True)
|
||||
paths = [root / '.circleci/config.yml', root / '.qqq-ci.yml']
|
||||
if any(not path.resolve(strict=True).is_relative_to(root) for path in paths):
|
||||
raise ValueError('CI declarations must remain inside their checkout')
|
||||
originals = [path.read_bytes() for path in paths]
|
||||
caller_raw, manifest_raw = [data.decode('utf-8') for data in originals]
|
||||
manifest = standard.load_yaml(manifest_raw)
|
||||
if not isinstance(manifest, dict):
|
||||
raise ValueError('Existing manifest must be a mapping')
|
||||
previous = manifest.get('orb_version')
|
||||
standard.validate(caller_raw, manifest_raw, previous)
|
||||
pipeline.load_manifest(paths[1], previous)
|
||||
caller = standard.load_yaml(caller_raw)
|
||||
if previous == version:
|
||||
replacements = originals
|
||||
else:
|
||||
manifest['orb_version'] = version
|
||||
caller['orbs']['qqq-orb'] = 'kingsrook/qqq-orb@' + version
|
||||
caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']['orb_version'] = version
|
||||
new_caller = yaml.safe_dump(caller, sort_keys=False)
|
||||
new_manifest = yaml.safe_dump(manifest, sort_keys=False)
|
||||
standard.validate(new_caller, new_manifest, version)
|
||||
replacements = [new_caller.encode('utf-8'), new_manifest.encode('utf-8')]
|
||||
return {'checkout': str(root), 'profile': manifest['profile'], 'from': previous, 'to': version,
|
||||
'files': list(zip(paths, originals, replacements))}
|
||||
|
||||
|
||||
def rollout(checkouts, version, write=False):
|
||||
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
|
||||
raise ValueError('Fleet upgrades require an explicit stable orb version')
|
||||
# Validate the entire batch before writing any repository.
|
||||
plans = [plan(path, version) for path in checkouts]
|
||||
if len({item['checkout'] for item in plans}) != len(plans):
|
||||
raise ValueError('Each checkout may appear only once')
|
||||
if write:
|
||||
for item in plans:
|
||||
for path, original, replacement in item['files']:
|
||||
if path.read_bytes() != original:
|
||||
raise ValueError('CI declaration changed after preflight; rerun the rollout')
|
||||
for item in plans:
|
||||
for path, original, replacement in item['files']:
|
||||
if replacement != original:
|
||||
path.write_bytes(replacement)
|
||||
return [{**{key: value for key, value in item.items() if key != 'files'},
|
||||
'changed': any(old != new for _, old, new in item['files']), 'written': write}
|
||||
for item in plans]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('checkouts', nargs='+', type=Path)
|
||||
parser.add_argument('--orb-version', required=True)
|
||||
parser.add_argument('--write', action='store_true')
|
||||
args = parser.parse_args()
|
||||
print(json.dumps(rollout(args.checkouts, args.orb_version, args.write), indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except (ValueError, OSError) as error:
|
||||
sys.exit('Version rollout rejected: ' + str(error))
|
||||
@@ -2,7 +2,7 @@
|
||||
"""Replace audited standard QBit pipelines with the canonical orb caller.
|
||||
|
||||
Only modifies the two CI declarations in a supplied checkout. Git operations and
|
||||
publication remain separate. Unknown jobs/options fail closed for central profile resolution.
|
||||
publication remain separate. Unknown jobs/options fail closed for human review.
|
||||
"""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
@@ -11,7 +11,7 @@ import re
|
||||
import yaml
|
||||
|
||||
|
||||
def canonical_caller(version, release_tag_policy=None, publish_feature=False):
|
||||
def canonical_caller(version, release_tag_policy=None):
|
||||
caller = {
|
||||
"version": 2.1,
|
||||
"setup": True,
|
||||
@@ -28,9 +28,6 @@ def canonical_caller(version, release_tag_policy=None, publish_feature=False):
|
||||
if release_tag_policy not in filters:
|
||||
raise ValueError("Unknown tag policy")
|
||||
caller["workflows"]["setup"]["jobs"][0]["qqq-orb/generate_pipeline"]["filters"]["tags"] = filters[release_tag_policy]
|
||||
if publish_feature:
|
||||
caller["workflows"]["setup"]["jobs"][0]["qqq-orb/generate_pipeline"]["filters"]["tags"] = {
|
||||
"only": ([filters[release_tag_policy]["only"]] if release_tag_policy != "none" else []) + ["/publish.*/"]}
|
||||
return caller
|
||||
|
||||
|
||||
@@ -46,14 +43,8 @@ def publication_filters(kind, filters):
|
||||
raise ValueError("Unknown publication filters")
|
||||
branches = filters.get("branches")
|
||||
tags = filters.get("tags")
|
||||
if kind == "feature":
|
||||
# Preserve the audited literal branch selector; it is not a regex and
|
||||
# contains a character Git forbids, so only publish* tags can select it.
|
||||
if branches != {"only": ["feature/.*"]} or tags != {"only": ["/publish.*/"]}:
|
||||
raise ValueError("Unknown feature publication filters")
|
||||
return False, "none"
|
||||
if kind in ("snapshot", "release_candidate", "hotfix"):
|
||||
expected = {"snapshot": "develop", "release_candidate": r"/release\/.*/", "hotfix": r"/hotfix\/.*/"}[kind]
|
||||
if kind in ("snapshot", "release_candidate"):
|
||||
expected = "develop" if kind == "snapshot" else r"/release\/.*/"
|
||||
if not isinstance(branches, dict) or set(branches) != {"only"} or single_filter(branches["only"]) != expected or tags not in (None, {"only": []}):
|
||||
raise ValueError("Unknown snapshot/RC filters")
|
||||
return False, "none"
|
||||
@@ -67,8 +58,7 @@ def publication_filters(kind, filters):
|
||||
tag_filter = single_filter(tags["only"])
|
||||
if not isinstance(tag_filter, str):
|
||||
raise ValueError("Unknown release tag filter")
|
||||
policy = {r"/^v\d+\.\d+\.\d+$/": "stable", r"/^v[0-9]+\.[0-9]+\.[0-9]+$/": "stable",
|
||||
"/v.*/": "v-prefix"}.get(tag_filter)
|
||||
policy = {r"/^v\d+\.\d+\.\d+$/": "stable", "/v.*/": "v-prefix"}.get(tag_filter)
|
||||
if policy is None:
|
||||
raise ValueError("Unknown release tag filter")
|
||||
return main, policy
|
||||
@@ -90,9 +80,6 @@ def test_filters(filters):
|
||||
"/(develop|release/.*|integration.*)/": "non-release-no-integration",
|
||||
"/(develop|main|release/.*|integration.*)/": "feature",
|
||||
"/(develop|main|release/.*)/": "non-release-no-main",
|
||||
"/(develop|release/.*|hotfix/.*)/": "non-release-no-hotfix",
|
||||
"/(develop|main|release/.*|hotfix/.*)/": "non-release-no-main-hotfix",
|
||||
"/(develop|main|release/.*|hotfix/.*|integration.*)/": "feature-no-hotfix",
|
||||
}.get(pattern.replace(r"\/", "/"))
|
||||
if policy is None:
|
||||
raise ValueError("Unknown test branch filters")
|
||||
@@ -132,7 +119,7 @@ def infer_manifest(config, version, default_branch):
|
||||
raise ValueError("Custom pre-steps require review")
|
||||
if job.endswith("/mvn_publish"):
|
||||
kind = options.get("branch_type")
|
||||
if kind not in ("snapshot", "release_candidate", "release", "hotfix", "feature"):
|
||||
if kind not in ("snapshot", "release_candidate", "release"):
|
||||
raise ValueError("Custom publication contract requires review")
|
||||
if kind in publications:
|
||||
raise ValueError("Duplicate publication jobs require review")
|
||||
@@ -156,8 +143,6 @@ def infer_manifest(config, version, default_branch):
|
||||
"test_branch_policy": test_policy or "all",
|
||||
"publish": {**{kind: kind in publications
|
||||
for kind in ("snapshot", "release_candidate", "release")},
|
||||
**({"hotfix": True} if "hotfix" in publications else {}),
|
||||
**({"feature": True} if "feature" in publications else {}),
|
||||
"asciidoc": False},
|
||||
}
|
||||
|
||||
@@ -173,9 +158,9 @@ def main():
|
||||
manifest_path = args.checkout / ".qqq-ci.yml"
|
||||
config = yaml.safe_load(config_path.read_text(encoding="utf-8"))
|
||||
if manifest_path.exists():
|
||||
raise ValueError("Already has a manifest; use tools/rollout_version.py")
|
||||
raise ValueError("Already has a manifest; use the version rollout operation")
|
||||
manifest = infer_manifest(config, args.orb_version, args.default_branch)
|
||||
caller = canonical_caller(args.orb_version, manifest["release_tag_policy"], manifest["publish"].get("feature", False))
|
||||
caller = canonical_caller(args.orb_version, manifest["release_tag_policy"])
|
||||
if args.write:
|
||||
for path, data in ((config_path, caller), (manifest_path, manifest)):
|
||||
path.write_bytes(yaml.safe_dump(data, sort_keys=False).encode("utf-8"))
|
||||
|
||||
Reference in new issue
Block a user