Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b666ea5a3f
|
||
|
|
7b1756818f | ||
|
|
68f17d3b09 | ||
|
|
130bc35ab0 | ||
|
|
9b7161c3c8 | ||
|
|
482d72ce21 | ||
|
|
45a439796f | ||
|
|
02f0b93e41 | ||
|
|
5e433ec629 | ||
|
|
cec7a76f12 | ||
|
|
8717d3536e | ||
|
|
8229a66bc5 | ||
|
|
9687feb36c | ||
|
|
0fefe6a064 | ||
|
|
2956e3ffce | ||
|
|
0afe2a231f | ||
|
|
65265e48a4 | ||
|
|
49399deb3d | ||
|
|
9fe4257490 | ||
|
|
0965a45653 | ||
|
|
bfd41c8e0d | ||
|
|
9c30a30754 | ||
|
|
ee8953bd93 | ||
|
|
5bc3167286 | ||
|
|
1a3368e119 | ||
|
|
1ddba883c9 | ||
|
|
da8044d6f2 | ||
|
|
67ba48da1f | ||
|
|
5196609974 | ||
|
|
49e09a6776 | ||
|
|
748016f105 | ||
|
|
6514aaa688 | ||
|
|
3ac47adc21 |
No files matched your search
@@ -31,6 +31,9 @@ jobs:
|
||||
- run:
|
||||
name: Verify resolved multi-module publication POMs
|
||||
command: python3 tests/test_maven_publication_poms.py
|
||||
- run:
|
||||
name: Verify calculated versions match installed Maven coordinates
|
||||
command: python3 tests/test_effective_publication_version.py
|
||||
pipeline-contract-test:
|
||||
resource_class: small
|
||||
docker:
|
||||
@@ -50,12 +53,17 @@ jobs:
|
||||
python3 tests/test_maven_ci_contract.py
|
||||
python3 tests/test_standardize_qbit.py
|
||||
python3 tests/test_qbit_hotfix_profile.py
|
||||
python3 tests/test_qbit_feature_profile.py
|
||||
python3 tests/test_ci_maintenance.py
|
||||
python3 tests/test_rollout_version.py
|
||||
python3 tests/test_enforce_orb_checks.py
|
||||
python3 tests/test_static_analysis_exit.py
|
||||
python3 tests/test_validate_standard.py
|
||||
python3 tests/test_voyage_profile.py
|
||||
python3 tests/test_next_native.py
|
||||
python3 tests/test_auxiliary_workflows.py
|
||||
python3 tests/test_qbit_codeql.py
|
||||
python3 tests/test_repository_policy.py
|
||||
python3 tests/test_intellij_plugin.py
|
||||
python3 tests/test_workflow_lint.py
|
||||
python3 tests/test_business_e2e.py
|
||||
@@ -79,6 +87,8 @@ jobs:
|
||||
bash tests/test_maven_ci_cache.sh
|
||||
bash tests/test_maven_test_results.sh
|
||||
bash tests/test_maven_ci_install.sh
|
||||
bash tests/test_browser_install.sh
|
||||
bash tests/test_frontend_build_reuse.sh
|
||||
bash tests/test_snapshot_refresh.sh
|
||||
bash tests/test_maven_settings_output.sh
|
||||
# Create jobs to test the commands of your orbs.
|
||||
|
||||
@@ -59,12 +59,16 @@ test-pipelines: pack
|
||||
python3 tests/test_cli_ci_contract.py
|
||||
python3 tests/test_standardize_qbit.py
|
||||
python3 tests/test_qbit_hotfix_profile.py
|
||||
python3 tests/test_ci_maintenance.py
|
||||
python3 tests/test_rollout_version.py
|
||||
python3 tests/test_enforce_orb_checks.py
|
||||
python3 tests/test_static_analysis_exit.py
|
||||
python3 tests/test_validate_standard.py
|
||||
python3 tests/test_voyage_profile.py
|
||||
python3 tests/test_next_native.py
|
||||
python3 tests/test_auxiliary_workflows.py
|
||||
python3 tests/test_qbit_codeql.py
|
||||
python3 tests/test_repository_policy.py
|
||||
python3 tests/test_intellij_plugin.py
|
||||
python3 tests/test_workflow_lint.py
|
||||
python3 tests/test_business_e2e.py
|
||||
@@ -218,3 +222,4 @@ publish-release: check-clean check-branch lint clean dev test-all
|
||||
# an isolated temporary repository. Never publishes or uses signing credentials.
|
||||
test-publication-poms:
|
||||
python3 tests/test_maven_publication_poms.py
|
||||
python3 tests/test_effective_publication_version.py
|
||||
@@ -4,6 +4,8 @@ CircleCI orb for QQQ framework projects.
|
||||
|
||||
For centralized pipeline ownership, see [standardized manifest-driven pipelines](docs/GENERATED-PIPELINES.md).
|
||||
The initial QBit profile uses a small `.qqq-ci.yml` and a setup entry point; existing direct job callers remain supported.
|
||||
For centrally managed patch adoption and exact-version rollback, see
|
||||
[managed patch updates](docs/managed-patch-updates.md).
|
||||
|
||||
**For:** Teams using CircleCI to build, test, and publish QQQ applications
|
||||
**Status:** Stable (v0.6.x)
|
||||
@@ -87,6 +89,11 @@ real publication, not a dry run, verifies the trust relationship.
|
||||
| `hotfix/1.5.1` | `1.5.1` |
|
||||
| `feature/*` | `1.5.0-feature-abc1234-SNAPSHOT` |
|
||||
|
||||
The Maven version step verifies the effective `project.version`, not only the
|
||||
`revision` property. For older POMs with a literal project version, it uses
|
||||
Maven's version plugin to align project and reactor coordinates with the
|
||||
calculated version. A mismatch after updating fails before publication.
|
||||
|
||||
### Java Version
|
||||
|
||||
Maven jobs run on Ubuntu machine executors with Temurin JDK. Default is Java 21. To use Java 17:
|
||||
@@ -114,6 +121,21 @@ Maven jobs use machine executors with Docker pre-installed. Tests using Testcont
|
||||
|
||||
## Orb Publishing
|
||||
|
||||
### QBit CI maintenance
|
||||
|
||||
The QBit profile runs Maven verification without publishing when a single-parent
|
||||
`ci: ...` or `ci(scope): ...` commit changes only `.qqq-ci.yml`,
|
||||
`.circleci/config.yml`, `.github/workflows/codeql.yml`, or
|
||||
`.github/workflows/release-rc.yml`. This applies on
|
||||
main, develop, release, and hotfix branches. The normal test job still runs,
|
||||
including on branches normally excluded from feature tests, and reports through
|
||||
the required `verify` workflow.
|
||||
|
||||
Tags, merge commits (including release automation), application changes, other
|
||||
files, empty diffs, and unavailable history retain normal publishing behavior.
|
||||
This lets central configuration updates avoid unnecessary application versions
|
||||
without introducing per-repository maintenance workflows.
|
||||
|
||||
The orb auto-publishes via CircleCI:
|
||||
|
||||
| Branch | Action |
|
||||
|
||||
@@ -80,6 +80,14 @@ required-check unknown states, and the lint image/tool/command/caller contract.
|
||||
|
||||
## Batch orb-version rollout
|
||||
|
||||
For a standard QBit without a manifest, start directly on the managed patch
|
||||
track using `python tools/standardize_qbit.py /checkout --orb-version 0.8
|
||||
--default-branch main`. Inspect the preview, then repeat with `--write`.
|
||||
This preserves the inferred publication and branch-filter policy while writing
|
||||
the same track to the manifest and setup caller. Use `rollout_version.py` below
|
||||
for repositories that already have a manifest. Neither command configures
|
||||
repository protection or automatically enrolls newly created repositories.
|
||||
|
||||
Upgrade existing canonical CircleCI consumers with one command:
|
||||
|
||||
```sh
|
||||
@@ -103,3 +111,28 @@ verification and artifact evidence. The requested version must already be publis
|
||||
```sh
|
||||
python3 -m unittest discover -s tests -p test_rollout_version.py
|
||||
```
|
||||
|
||||
## Live organization discovery
|
||||
|
||||
Use `--organization QRun-IO --live` instead of `--inventory inventory.json` to
|
||||
include newly created repositories on each audit. Discovery uses the existing
|
||||
`gh` authentication and all API pages, retaining archived entries for explicit
|
||||
skip reporting. Unknown repositories receive no automatic exemption. Duplicate,
|
||||
empty, malformed or failed discovery aborts instead of reusing a stale inventory.
|
||||
|
||||
```sh
|
||||
python tools/audit_estate.py --organization QRun-IO --live --orb-version 0.8 \
|
||||
--worker-sha <40SHA> --policy observed-checks.json --output audit.json
|
||||
```
|
||||
|
||||
The organization mode has no fixed repository-count ceiling. Supply
|
||||
`--expected-active N` for an independent count check when needed; saved-inventory
|
||||
mode preserves its default of 68. Reports identify the inventory source and
|
||||
credential visibility limit: inaccessible repositories cannot be certified.
|
||||
This is discovery and audit, not automatic enrollment or branch-rule mutation.
|
||||
|
||||
For a qualified batch of canonical orb branches, use the shared
|
||||
[branch-check enforcement command](branch-enforcement.md). It adds the observed
|
||||
CircleCI setup/verify gates while preserving other protections. Source enrollment,
|
||||
scanner transitions and scheduled reconciliation remain separate requirements.
|
||||
Scheduling and authenticated onboarding still need to be configured centrally.
|
||||
@@ -111,8 +111,10 @@ The independent baseline fixture pins job sets, dependency edges, contexts,
|
||||
coverage requirements and actual verification commands across all six workflows.
|
||||
|
||||
Core additionally supports `publish.feature` and `publish.hotfix` (both true by
|
||||
default), preserving `publish*` tag and hotfix branch publication. QBit does not
|
||||
accept these keys. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix
|
||||
default), preserving `publish*` tag and hotfix branch publication. QBit supports
|
||||
both keys as explicit opt-ins (false by default). QBit feature publishing requires
|
||||
a `publish*` tag resolving to the checked-out commit; feature branch pushes remain
|
||||
test-only. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix
|
||||
publication still requires the complete source coverage gate. Cold bootstrap and
|
||||
fresh consumer Maven repositories remain uncached. Shared installer policy replaces
|
||||
local package preparation; preliminary compilation is disabled before clean
|
||||
|
||||
@@ -37,9 +37,17 @@ fail migration rather than silently changing release behavior.
|
||||
|
||||
Use `tools/standardize_qbit.py --write` for the two-file migration. API callers
|
||||
must pass the inferred policy to
|
||||
`canonical_caller(version, manifest["release_tag_policy"])`; the legacy one-argument
|
||||
`canonical_caller(version, manifest["release_tag_policy"], manifest["publish"].get("feature", False))`; the legacy one-argument
|
||||
form is only for manifests without an explicit policy.
|
||||
|
||||
`publish.feature` is false by default. Opting in enables the audited `publish*`
|
||||
tag contract, with the tag required to resolve to the checked-out commit. The
|
||||
canonical setup admits those tags alongside the declared release tag policy.
|
||||
Feature branch pushes remain test-only. Migration accepts Workflows' exact legacy
|
||||
literal `feature/.*` branch selector (not a regular expression); Git forbids `*`
|
||||
in branch names, so that selector cannot publish a branch. Unknown feature
|
||||
filters require a central profile change rather than silently broadening triggers.
|
||||
|
||||
Focused tests cover the immutable inventory, unknown-filter rejection, canonical
|
||||
caller agreement, main opt-in, broad/stable tag selection, HEAD provenance,
|
||||
publication opt-out and test exclusions. The packed generator suite also exercises
|
||||
@@ -51,3 +59,5 @@ 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.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Application-free branch verification
|
||||
|
||||
Use `profile: repository-policy` only on a branch containing repository policies,
|
||||
documentation, workflow configuration and optional unused Maven wrappers. It uses
|
||||
the same canonical setup caller as other profiles and one small Python verification
|
||||
job. It checks tracked YAML/JSON syntax and rejects application manifests, source
|
||||
files, unknown file types and symlinks. It never builds or publishes an application.
|
||||
|
||||
The manifest accepts only `profile`, `orb_version` and `default_branch`. The latter
|
||||
remains the repository's actual default branch. A future application promotion must
|
||||
select its real build profile in the same change; adding source without doing so fails.
|
||||
|
||||
Estate policy can set `branch_profiles: {main: repository-policy}` without changing
|
||||
the default branch's application profile. Require the CircleCI `setup` and `verify`
|
||||
checks on the policy branch. This profile does not establish application release
|
||||
readiness or replace the build/release checks on source-bearing branches.
|
||||
@@ -0,0 +1,49 @@
|
||||
# Shared orb check enforcement
|
||||
|
||||
`tools/enforce_orb_checks.py` replaces repository-specific scripts for the shared
|
||||
CircleCI `setup` and `verify` branch gates. One invocation processes an explicit
|
||||
batch of current `main` and `develop` branches using existing `gh` authentication.
|
||||
|
||||
Create a targets file:
|
||||
|
||||
```json
|
||||
[
|
||||
{"repository": "QRun-IO/qbit-example", "branch": "main"},
|
||||
{"repository": "QRun-IO/qbit-example", "branch": "develop"}
|
||||
]
|
||||
```
|
||||
|
||||
Preview, then apply the same batch:
|
||||
|
||||
```sh
|
||||
python tools/enforce_orb_checks.py --targets targets.json --orb-version 0.8 --output enforcement-plan.json
|
||||
python tools/enforce_orb_checks.py --targets targets.json --orb-version 0.8 --output enforcement-result.json --apply
|
||||
```
|
||||
|
||||
Every branch must already contain the exact canonical caller for its manifest and
|
||||
have successful `setup` and `verify` checks from CircleCI app 18001 at its current
|
||||
commit. Supported profiles are QBit, Core, frontend-core and frontend-material.
|
||||
The complete batch is inspected before any mutation. Source/head/protection drift,
|
||||
unavailable APIs, unknown profiles, and ruleset-managed branches fail closed.
|
||||
|
||||
The tool appends the app-bound checks, enables strict checks and administrator
|
||||
enforcement, and reads the result back. Existing required checks remain required.
|
||||
For protected branches it uses the narrow status-check/admin endpoints, preserving
|
||||
reviews, signatures, linear history, restrictions and other settings. For a
|
||||
previously unprotected branch it creates protection without adding human reviews.
|
||||
It never changes scanner configuration, repository visibility, billing, or source.
|
||||
|
||||
Output records the planned head and original protection, then verification as each
|
||||
branch completes. A batch is not transactional: if an API call fails, inspect the
|
||||
output and rerun; successful protections are retained rather than rolled back.
|
||||
An already-correct branch needs no mutation.
|
||||
|
||||
This command covers the shared orb gate pair only. Continue to run the estate
|
||||
audit for scanner/native-worker requirements and other policy. Automatic repository
|
||||
discovery, source enrollment and scheduled reconciliation remain separate work.
|
||||
|
||||
GitHub API reference: [protected branches](https://docs.github.com/en/rest/branches/branch-protection).
|
||||
|
||||
```sh
|
||||
python -m unittest discover -s tests -p test_enforce_orb_checks.py -v
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
# Managed patch updates
|
||||
|
||||
The canonical caller and manifest accept either an exact stable version such as
|
||||
`0.8.0` or a quoted minor track such as `"0.8"`. CircleCI resolves a minor track
|
||||
to its latest published patch. A major-only version, `latest`, `volatile`, and
|
||||
wildcards are rejected. The caller import, setup parameter, and manifest must
|
||||
still agree exactly.
|
||||
|
||||
Use a minor track after qualifying that release line. Future patch fixes then
|
||||
arrive on the repository's next pipeline without a version-bump PR or an extra
|
||||
fleet-wide build. Existing exact pins remain supported and are not changed by
|
||||
publishing this capability. YAML minor versions must be quoted to remain strings.
|
||||
|
||||
The central batch tool applies the same update to all supplied checkouts:
|
||||
|
||||
```sh
|
||||
python3 tools/rollout_version.py --orb-version 0.8 --write /path/to/repo1 /path/to/repo2
|
||||
```
|
||||
|
||||
This changes only the two canonical CI declarations. Publication policies,
|
||||
contexts, branch/tag filters, and profile options stay unchanged. Normal source
|
||||
and publication checks still run when a pipeline is triggered; this setting does
|
||||
not skip tests. GitHub reusable-worker commit pins are separate and unchanged.
|
||||
|
||||
Automatic patch adoption trades exact-version reproducibility for centrally
|
||||
managed fixes. Keep patch releases backward compatible, qualify central changes
|
||||
before production publication, and use an exact stable pin for a canary or
|
||||
rollback. For example, the same tool can move a consumer from `0.8` back to
|
||||
`0.8.0`. Historical pipeline reruns can resolve a newer patch; choose an exact
|
||||
pin when reproducing an earlier run. Setup and continuation each resolve their
|
||||
orb imports, so patch compatibility also matters when publication overlaps a run.
|
||||
|
||||
Changing minor tracks is an explicit migration. Do not use this feature to push
|
||||
breaking changes into a patch release or to bypass repository checks.
|
||||
|
||||
Reference: [CircleCI orb semantic versioning](https://circleci.com/docs/orbs/use/orb-concepts/).
|
||||
|
||||
@@ -12,8 +12,9 @@ text = source.read_text(encoding="utf-8")
|
||||
start = text.index("# BEGIN PROFILE RESOURCES")
|
||||
end = text.index("# END PROFILE RESOURCES") + len("# END PROFILE RESOURCES")
|
||||
embedded = ["# Generated by scripts/pack_pipeline.py; edit source/resources, then regenerate.", "import base64", "import zlib"]
|
||||
for variable, name in (("CORE_TEMPLATE", "core"), ("MATERIAL_TEMPLATE", "frontend-material"), ("VOYAGE_TEMPLATE", "voyage"), ("NEXT_TEMPLATE", "frontend-next"), ("ALL_TEMPLATE", "all"), ("STARTER_TEMPLATE", "app-starter"), ("ANDROID_TEMPLATE", "android"), ("POLICY_TEMPLATE", "mcp-policy"), ("MARKETING_TEMPLATE", "marketing")):
|
||||
payload = base64.b64encode(zlib.compress((source.parent / "templates" / (name + ".json")).read_bytes(), level=9)).decode("ascii")
|
||||
for variable, name in (("CORE_TEMPLATE", "core"), ("MATERIAL_TEMPLATE", "frontend-material"), ("VOYAGE_TEMPLATE", "voyage"), ("NEXT_TEMPLATE", "frontend-next"), ("ALL_TEMPLATE", "all"), ("STARTER_TEMPLATE", "app-starter"), ("ANDROID_TEMPLATE", "android"), ("POLICY_TEMPLATE", "mcp-policy"), ("REPOSITORY_POLICY_TEMPLATE", "repository-policy"), ("MARKETING_TEMPLATE", "marketing")):
|
||||
resource = (source.parent / "templates" / (name + ".json")).read_text(encoding="utf-8").encode("utf-8")
|
||||
payload = base64.b64encode(zlib.compress(resource, level=9)).decode("ascii")
|
||||
embedded.append(f'{variable} = json.loads(zlib.decompress(base64.b64decode("{payload}")))')
|
||||
packed = text[:start] + "\n".join(embedded) + text[end:]
|
||||
if len(packed.encode("utf-8")) > 100_000:
|
||||
|
||||
@@ -10,6 +10,11 @@ description: >
|
||||
- Collects JUnit XML test results
|
||||
- Stores test results and screenshots
|
||||
- Saves Maven cache for future builds
|
||||
parameters:
|
||||
build_before_test:
|
||||
type: boolean
|
||||
default: true
|
||||
description: "Build the React app first; combined jobs already build it with frontend_build"
|
||||
steps:
|
||||
# Ensure no stale Chrome/Driver is shadowing the PATH (your base image had Chrome 109)
|
||||
- run:
|
||||
@@ -17,7 +22,7 @@ steps:
|
||||
command: <<include(scripts/frontend_test_cleanup.sh)>>
|
||||
|
||||
# Install current Chrome; DO NOT install chromedriver (let Selenium 4 auto-manage it)
|
||||
- browser-tools/install-chrome
|
||||
- install_chrome
|
||||
|
||||
# System libs Chrome needs in headless CI
|
||||
- run:
|
||||
@@ -52,6 +57,8 @@ steps:
|
||||
# GPG signing will happen later in mvn_jar_deploy when deploying to Maven Central.
|
||||
- run:
|
||||
name: Build app, start server, run tests
|
||||
environment:
|
||||
PARAM_BUILD_BEFORE_TEST: << parameters.build_before_test >>
|
||||
command: <<include(scripts/frontend_test_run.sh)>>
|
||||
|
||||
# Always collect and publish test results & screenshots
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
description: Install stable Chrome using only its signed repository and existing Ubuntu dependency indexes.
|
||||
steps:
|
||||
- run:
|
||||
name: Install Google Chrome
|
||||
command: <<include(scripts/install_chrome.sh)>>
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
- when:
|
||||
condition: << parameters.install_browsers >>
|
||||
steps:
|
||||
- browser-tools/install-chrome
|
||||
- install_chrome
|
||||
- browser-tools/install-chromedriver
|
||||
- when:
|
||||
condition: << parameters.compile_before_verify >>
|
||||
|
||||
@@ -27,7 +27,8 @@ steps:
|
||||
- git_full_checkout
|
||||
- mvn_manage_version
|
||||
- frontend_build
|
||||
- frontend_test
|
||||
- frontend_test:
|
||||
build_before_test: false
|
||||
- frontend_package
|
||||
- mvn_jar_deploy
|
||||
- git_operations:
|
||||
|
||||
@@ -23,4 +23,5 @@ steps:
|
||||
node_version: << parameters.node_version >>
|
||||
- git_full_checkout
|
||||
- frontend_build
|
||||
- frontend_test
|
||||
- frontend_test:
|
||||
build_before_test: false
|
||||
@@ -161,7 +161,7 @@ set_version() {
|
||||
##############################################
|
||||
## Use Maven versions plugin to set version ##
|
||||
##############################################
|
||||
mvn versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
|
||||
mvn -f "$POM_FILE" versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
|
||||
|
||||
#######################
|
||||
## Verify the change ##
|
||||
@@ -175,6 +175,26 @@ set_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_project_version() {
|
||||
local expected=$1 actual
|
||||
# A revision property can exist without being used by project.version.
|
||||
# Ask Maven for the effective coordinate, including inherited configuration.
|
||||
actual=$(mvn -f "$POM_FILE" -q -Dstyle.color=never \
|
||||
org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate \
|
||||
-Dexpression=project.version -DforceStdout)
|
||||
if [[ "$actual" != "$expected" ]]; then
|
||||
mvn -f "$POM_FILE" -B versions:set -DnewVersion="$expected" -DgenerateBackupPoms=false
|
||||
actual=$(mvn -f "$POM_FILE" -q -Dstyle.color=never \
|
||||
org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate \
|
||||
-Dexpression=project.version -DforceStdout)
|
||||
fi
|
||||
if [[ "$actual" != "$expected" ]]; then
|
||||
echo "ERROR: Effective project version is $actual; expected $expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Verified effective project version: $actual"
|
||||
}
|
||||
|
||||
#############################################
|
||||
## Branch Detection and Routing Functions ##
|
||||
#############################################
|
||||
@@ -434,6 +454,9 @@ main() {
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
ensure_project_version "$NEW_VERSION"
|
||||
fi
|
||||
echo "=== Version calculation complete ==="
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,20 @@
|
||||
## Output: Installs required system libraries
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
echo "Installing browser dependencies"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
sudo apt-get update
|
||||
ubuntu_sources=/etc/apt/sources.list
|
||||
if [[ ! -s "$ubuntu_sources" ]]; then
|
||||
ubuntu_sources=/etc/apt/sources.list.d/ubuntu.sources
|
||||
fi
|
||||
if [[ ! -s "$ubuntu_sources" ]]; then
|
||||
echo 'Cannot locate Ubuntu package sources' >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update \
|
||||
-o "Dir::Etc::sourcelist=$ubuntu_sources" \
|
||||
-o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev
|
||||
@@ -15,7 +15,9 @@ set -e
|
||||
|
||||
echo "Building app, starting server, running tests"
|
||||
echo "HTTPS=true" >> ./.env
|
||||
npm run build
|
||||
if [[ "${PARAM_BUILD_BEFORE_TEST:-true}" == true ]]; then
|
||||
npm run build
|
||||
fi
|
||||
export REACT_APP_PROXY_LOCALHOST_PORT=8001
|
||||
export PORT=3001
|
||||
npm run start &
|
||||
|
||||
@@ -23,6 +23,7 @@ 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
|
||||
|
||||
@@ -69,7 +70,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", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
@@ -78,7 +79,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", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -88,8 +89,8 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("java_version",)
|
||||
mapping(data, allowed, "manifest")
|
||||
version = data.get("orb_version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+\.\d+|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ManifestError("orb_version must be an explicit stable or development version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ManifestError("orb_version must be a quoted minor track, exact stable pin, or development version")
|
||||
if version != setup_version:
|
||||
raise ManifestError("Manifest orb_version must match the setup job orb_version")
|
||||
default_branch = data.get("default_branch")
|
||||
@@ -111,7 +112,7 @@ def load_manifest(path, setup_version):
|
||||
if profile in ("qbit", "core"):
|
||||
publish_keys += ("asciidoc",)
|
||||
if profile == "qbit":
|
||||
publish_keys += ("hotfix",)
|
||||
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")
|
||||
@@ -139,8 +140,8 @@ 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")
|
||||
and not (profile == "qbit" and key == "hotfix"))
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
for key in publish_keys}}
|
||||
|
||||
|
||||
@@ -175,6 +176,25 @@ 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):
|
||||
@@ -195,15 +215,24 @@ def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
|
||||
def qbit_template(config, branch, tag):
|
||||
"""Profile-owned template; add future profiles as reviewed renderers, not raw YAML."""
|
||||
kind = event_kind(branch, tag, config.get("release_on_main", False), config.get("release_tag_policy", "stable"))
|
||||
if tag.startswith("publish") and config["publish"].get("feature", False):
|
||||
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
|
||||
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
|
||||
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
|
||||
if tagged and tagged == git("rev-parse", "HEAD"):
|
||||
kind = "feature"
|
||||
if not tag and re.fullmatch(r"hotfix/.+", branch) and config["publish"].get("hotfix", False):
|
||||
kind = "hotfix"
|
||||
if kind != "test" and not config["publish"][kind]:
|
||||
kind = "test"
|
||||
maintenance = proven_ci_maintenance(branch, tag)
|
||||
if maintenance:
|
||||
kind = "test"
|
||||
workflow = "test_only" if kind == "test" else "publish_" + kind
|
||||
result = {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]}}
|
||||
filters = ({"branches": {"ignore": "/.*/"}, "tags": {"only": "/.*/"}} if tag else
|
||||
{"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}})
|
||||
if kind == "test" and not tag:
|
||||
if kind == "test" and not tag and not maintenance:
|
||||
ignores = {"all": None, "non-release": "/(develop|release/.*)/",
|
||||
"non-release-no-integration": "/(develop|release/.*|integration.*)/",
|
||||
"feature": "/(develop|main|release/.*|integration.*)/",
|
||||
@@ -214,7 +243,7 @@ def qbit_template(config, branch, tag):
|
||||
ignored = ignores[config.get("test_branch_policy", "all")]
|
||||
if ignored:
|
||||
filters["branches"]["ignore"] = ["automation/qbit-rc-pending", ignored]
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" else False
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" and not maintenance else False
|
||||
if docs_base:
|
||||
# Keep the existing workflow/result identity even when Maven is not needed.
|
||||
result["jobs"] = {"docs_only": {"resource_class": "small", "docker": [{"image": "cimg/base:2026.03"}],
|
||||
@@ -313,7 +342,10 @@ def frontend_template(config, branch, tag):
|
||||
kind = "release"
|
||||
if kind != "test" and not config["publish"][kind]:
|
||||
kind = "test"
|
||||
if kind == "test" and proven_docs_only(config, branch, tag):
|
||||
maintenance = proven_ci_maintenance(branch, tag)
|
||||
if maintenance:
|
||||
kind = "test"
|
||||
if kind == "test" and not maintenance and proven_docs_only(config, branch, tag):
|
||||
result = qbit_template(config, branch, tag)
|
||||
result["workflows"]["test_only"]["jobs"][0]["docs_only"]["name"] = (
|
||||
"qqq-orb/mvn_frontend_test_only" if material else "qqq-orb/node_test_only")
|
||||
@@ -416,7 +448,13 @@ 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}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Machine executors are Ubuntu amd64. Preserve an existing browser for Maven
|
||||
# consumers; frontend_test deliberately removes its stale browser beforehand.
|
||||
if command -v google-chrome >/dev/null 2>&1; then
|
||||
google-chrome --version
|
||||
exit 0
|
||||
fi
|
||||
architecture=$(dpkg --print-architecture)
|
||||
if [[ "$architecture" != amd64 ]]; then
|
||||
echo "Google Chrome requires an amd64 machine executor" >&2
|
||||
exit 1
|
||||
fi
|
||||
curl --fail --silent --show-error --location https://dl.google.com/linux/linux_signing_key.pub \
|
||||
| sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/qqq-google-chrome.gpg
|
||||
printf '%s\n' 'deb [arch=amd64 signed-by=/usr/share/keyrings/qqq-google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main' \
|
||||
| sudo tee /etc/apt/sources.list.d/qqq-google-chrome.list >/dev/null
|
||||
# Ubuntu dependency indexes were refreshed by install_java. Only the newly added
|
||||
# signed Google repository needs refreshing; image PPAs are unrelated to Chrome.
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update \
|
||||
-o Dir::Etc::sourcelist=/etc/apt/sources.list.d/qqq-google-chrome.list \
|
||||
-o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y google-chrome-stable
|
||||
google-chrome --version
|
||||
@@ -20,13 +20,30 @@ sudo install -d /etc/needrestart/conf.d
|
||||
# shellcheck disable=SC2016
|
||||
printf '%s\n' '$nrconf{restart} = "l";' | sudo tee /etc/needrestart/conf.d/99-qqq-ci.conf >/dev/null
|
||||
|
||||
# Retry transient repository downloads within APT, including NodeSource's child process.
|
||||
# Exhausted downloads retain APT's nonzero exit status and fail this build step.
|
||||
printf '%s\n' 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-qqq-download-retries >/dev/null
|
||||
|
||||
# Ubuntu archive carries the same signed security suite; avoid the flaky HTTP mirror.
|
||||
if [[ -f /etc/apt/sources.list ]]; then
|
||||
sudo sed -i 's|http://security.ubuntu.com/ubuntu|https://archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list
|
||||
fi
|
||||
|
||||
# Add Eclipse Temurin repository
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq
|
||||
# Base tools come from Ubuntu, not the unrelated PPAs bundled in machine images.
|
||||
# Support both the 22.04 list and the newer deb822 Ubuntu source file. Preserve
|
||||
# other indexes for later jobs without contacting their repositories here.
|
||||
ubuntu_sources=/etc/apt/sources.list
|
||||
if [[ ! -s "$ubuntu_sources" ]]; then
|
||||
ubuntu_sources=/etc/apt/sources.list.d/ubuntu.sources
|
||||
fi
|
||||
if [[ ! -s "$ubuntu_sources" ]]; then
|
||||
echo 'Cannot locate Ubuntu package sources' >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq \
|
||||
-o "Dir::Etc::sourcelist=$ubuntu_sources" \
|
||||
-o Dir::Etc::sourceparts=- \
|
||||
-o APT::Get::List-Cleanup=0
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y -qq wget apt-transport-https gpg maven curl
|
||||
|
||||
# Add Temurin GPG key
|
||||
@@ -35,8 +52,13 @@ wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo g
|
||||
# Add repository
|
||||
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
|
||||
|
||||
# Install Java
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq
|
||||
# Refresh only the repository just added. Re-fetching unrelated image PPAs here
|
||||
# caused otherwise successful setup to fail on Launchpad 503 responses. Keep
|
||||
# Ubuntu indexes from the first refresh so Java dependencies remain resolvable.
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get update -qq \
|
||||
-o Dir::Etc::sourcelist=/etc/apt/sources.list.d/adoptium.list \
|
||||
-o Dir::Etc::sourceparts=- \
|
||||
-o APT::Get::List-Cleanup=0
|
||||
sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=l apt-get install -y -qq "temurin-${JAVA_VERSION}-jdk"
|
||||
|
||||
# Set JAVA_HOME
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -eo pipefail
|
||||
|
||||
echo "Running PMD static analysis..."
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -eo pipefail
|
||||
|
||||
echo "Running SpotBugs static analysis..."
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import yaml
|
||||
# Generated by scripts/pack_pipeline.py; edit source/resources, then regenerate.
|
||||
import base64
|
||||
import zlib
|
||||
CORE_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtPdl22ziy7/0VuOrM2M6IpPclifvcxHbfeCar48z0nChXByJBiW1uJig7Oonn26cKACmKIiVSluUlTr/IJFAo1F6FAvv7L4Q0LljEncBvPCPr+loTn4Q0oh6L4Tk8/A5P4JkX+N2g3XF8q205tOsHPHbM4XsYEQ9CBn83OkHgMuo3mskLi9m078bwzqYuZ+LxlXz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9pyoGJ6iNx8YLM2+Gnj2+yVPH8NvAqGETtyOkzZBust7Har5cLJcKICr7/ZLl/hvfexA2X+HA5aY0d+bI/xDLine truncated
|
||||
MATERIAL_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNq1lMtugzAQRfd8heV1TNRKlar8QXdVt02EXDMhDthGfqRBiH/vQAmPvKRU6g7PjH3PXI+pI0IoHEEEb6yjK1JjAENlwatvK7OdH2IYTY3IwWLks4+QIdflpeIZYJoqYWMlhTXObH0sjFqOB64OT/HLa/zM9lypig77m/5rE51WzaKl25uvq2CJB+fdFO/UR0swaWBxyjsPpZvRU7EDkZswFp11ZFHDWEgEx8qJVp/OoZof2Md1qViKYqyuSSfhgiJrWnKRo0OsQB/jvTN6TUnTTLTPt9NZZjNZNaNvt9CDvgTWXHUX9Kad50VBUAV0ClpIcGccFK9NcZ225QhEhCSMFZBxUbESwHaE9CEkxw/3rOyV/uwcVvnd9fswKSTKpKEA92+efgRN3oexIwfpAi+IhQyHyEmjye/A3nP5SMa57cof9LebVW693HIxexsTg+avg1kojfXLc6wUxaXmHrmvbvgLWNtQgmaE4h5bW8X6quUNmctfRdREPykCLqM=")))
|
||||
VOYAGE_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtW+tz2zYS/56/AqPJXJKeSUqqHzndqBNbdm1NGzsnObneVDkNREISLBKgAVCWYuv+9lvwpQepV2K1TpoPsUhggV38drEPgLl/hlBhSISknBUqqGyW9nTLDe9IeL2HZ3jrBNR1DMwcQxGp0nbo8bDdp4zMNEEj9XBPNxWCTsBUYJTLxf2KHQhBmCrEZJO9ZApBJA+ETdq2i6VmWnCxgPEpAWFDKjjz9Og5Pm+PP5xdtq/eXTf1KOM3bwSMXntZFlIRX8/8+3Ss3Sf2gAcqZYNmZob+29tbg4uORZlU2HXbN3iI57iHVLq1PUWvUC4VZggm6fNkyiWd2Ruytg3wkTYgoLggy0QRActyZtgLIf5ABO2OEfZ9l9pYgRx7iDJFeiJ8QVphcg/dB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ads(zlib.decompress(base64.b64decode("eNq1T7EOgjAU3PmKpjNI
|
||||
STARTER_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNp1UMGKwkAMvc9XlDmKtejR0yJ42MsKCl5EQnUzZbbTiZ0ZqiL9d1OpWqt7y3t5eS/JRUSRrNB5TVZOo8loPGwYcjvP8MI1o7IsY2aYkLm2mXdEedKSXwCL5QzW8+Xqe/EDIHmkvnkcyeXK0LFjFNAHIGvOD4rJP7plbVocPTrd7KSoLHwab2V7Kg7aIOxQkUPgi7RqZCo1Hod9rQ14Ci+ZnbQirdDGDjPtgzvHe4e/aINmI/ki3/ZslTaBH/m2W3N3mn3iuaMzy/s2n01Gg0T2BLX4Dz3re7UVd1SLWlwByepyJQ==")))
|
||||
ANDROID_TEMPLATE = json.loads(zlib.decompress(base64.b64decode("eNrtWG1v2zYQ/p5fQWgF6rSW3CXYMDhJ13YNkm5rkrrugKEKDFqiZCYUyZBUbC/wfvuO1LvtpmmBAcUwIYAp3vHuuXcqdzsIebdEaSq4N0R7wfd9uyPUVMPrHazhDfNYCRrDhhdRFTES0UG592Iv+CF45vULxjSSfsRoh7Hce7Ef7AV7HvCtnIYr0daQc2p8Q7Spt2CTLEiUG6Fae7DLcUasghJABcTPcDSjnJRQHKvBqeWMSYJzZrySsKo4PG2ItCA+NkeiGYmuRW7aYipNCvAJRfxU4ZgRPwKFbXUNxvaZnDu7dMeIAh1s+5HIMuC1MINBIXiOLOU1meap1zqxqterLdg0vn0YMAC0CaXy6XuQ4rQjsBVcpltSCvc0cLPrmCrkS/T3wFlSnhhc2VgOQp5QHqMA+WYpCUoQ0FOyQKEXPBlMc8ri7qngySJjoYd8G3QUSXS32i4YheFByNdxzWeEu6Rgc7zUn3VbxyMuqBOralJZveEgic3Myu9C+ho9WBma4OjhSgq7P6GqXF3utBRXObFRTxIriLOBYu9WlF5CIWQ+zXBK1lB5NnoWkzaK8rTj9rquhl0R+qACsP/sIBUiZWC1pPpg8dOP3gb0phq/kXLfWs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Cl6c/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+FjQaUsB0wBTX8FC6MlPM7BZOmfUL9BiizBadJ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cWXAHl1AYMVNd5hRKpLvbyWSz2XxF39H7VuHZ/EE2Q7orNBwzb2fFEtZ53Psj6YRBHO2OrUMaxOyJCZV74XRNwmkb9YusjU+6u3OoZU/pAF97DuVyXyv6WnEo9vna7nOdXr8trMqrvDBpv88rKK52XkI/7dVhyoiw6fYJDvv6lXaVTvBtMpn0QOJ5bzI8Fu4jGQb1HojoaPWB+hM4ahP8KL2OlXjg1t+Ym506ASriBbDG64Sr0glN1C9TJ5xyd2ehE07oAK8ThnK51wleJwzFPq8TPtfpXid4nTAYNzt1gmaCEcMw7DvmMbHMKwb/SVZNCv+JzjCuON/vbwbwlhcuZxEfr3K8yjkLqnpJ9BtHyOsnr58ugshVbR/VM/ezuMLhBvcODhzy/8NhuSgd0qmCc63igtrquPby93r+YJYRLv2LvsES1XuKmGFfvJ2KKEXuXrpFNIZckKt+llQ4TGNc4tq+2Q4P/lbJzxWTdv1zpUIqCgP7xvAsqdy0RzH5xLWSGaDdSHcIdhhOlM5ICViCMXjA/2UdqH2StngXvklasNCw0DJJpDXl2LCGh83UxJ3R4zXJxIEFHsEuIwaBKuUb5T+chfEh62tks9Z/qkigP/+63PR6Mvr6Oub/cvR+XeL+e3q0Gf0Hgnpc+w==")))
|
||||
|
||||
|
||||
@@ -69,7 +70,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", "marketing"):
|
||||
if profile not in ("qbit", "core", "frontend-material", "frontend-core", "cli", "voyage", "frontend-next", "all", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
raise ManifestError("Unsupported profile")
|
||||
allowed = ("profile", "orb_version", "default_branch", "docs_only", "publish")
|
||||
if profile in ("qbit", "core"):
|
||||
@@ -78,7 +79,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", "marketing"):
|
||||
elif profile in ("voyage", "frontend-next", "app-starter", "android", "mcp-policy", "repository-policy", "marketing"):
|
||||
allowed = ("profile", "orb_version", "default_branch")
|
||||
elif profile == "all":
|
||||
allowed = ("profile", "orb_version", "default_branch", "publish", "publish_context")
|
||||
@@ -88,8 +89,8 @@ def load_manifest(path, setup_version):
|
||||
allowed += ("java_version",)
|
||||
mapping(data, allowed, "manifest")
|
||||
version = data.get("orb_version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+\.\d+|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ManifestError("orb_version must be an explicit stable or development version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ManifestError("orb_version must be a quoted minor track, exact stable pin, or development version")
|
||||
if version != setup_version:
|
||||
raise ManifestError("Manifest orb_version must match the setup job orb_version")
|
||||
default_branch = data.get("default_branch")
|
||||
@@ -111,7 +112,7 @@ def load_manifest(path, setup_version):
|
||||
if profile in ("qbit", "core"):
|
||||
publish_keys += ("asciidoc",)
|
||||
if profile == "qbit":
|
||||
publish_keys += ("hotfix",)
|
||||
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")
|
||||
@@ -139,8 +140,8 @@ 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")
|
||||
and not (profile == "qbit" and key == "hotfix"))
|
||||
"publish": {key: boolean(publishing, key, key != "asciidoc" and profile not in ("cli", "all", "repository-policy")
|
||||
and not (profile == "qbit" and key in ("hotfix", "feature")))
|
||||
for key in publish_keys}}
|
||||
|
||||
|
||||
@@ -175,6 +176,25 @@ 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):
|
||||
@@ -195,15 +215,24 @@ def event_kind(branch, tag, release_on_main=False, release_tag_policy="stable"):
|
||||
def qbit_template(config, branch, tag):
|
||||
"""Profile-owned template; add future profiles as reviewed renderers, not raw YAML."""
|
||||
kind = event_kind(branch, tag, config.get("release_on_main", False), config.get("release_tag_policy", "stable"))
|
||||
if tag.startswith("publish") and config["publish"].get("feature", False):
|
||||
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
|
||||
if not tagged and git("fetch", "--no-tags", "origin", f"refs/tags/{tag}:refs/tags/{tag}") is not None:
|
||||
tagged = git("rev-parse", "--verify", f"refs/tags/{tag}^{{commit}}")
|
||||
if tagged and tagged == git("rev-parse", "HEAD"):
|
||||
kind = "feature"
|
||||
if not tag and re.fullmatch(r"hotfix/.+", branch) and config["publish"].get("hotfix", False):
|
||||
kind = "hotfix"
|
||||
if kind != "test" and not config["publish"][kind]:
|
||||
kind = "test"
|
||||
maintenance = proven_ci_maintenance(branch, tag)
|
||||
if maintenance:
|
||||
kind = "test"
|
||||
workflow = "test_only" if kind == "test" else "publish_" + kind
|
||||
result = {"version": 2.1, "orbs": {"qqq-orb": "kingsrook/qqq-orb@" + config["orb_version"]}}
|
||||
filters = ({"branches": {"ignore": "/.*/"}, "tags": {"only": "/.*/"}} if tag else
|
||||
{"branches": {"ignore": "automation/qbit-rc-pending"}, "tags": {"ignore": "/.*/"}})
|
||||
if kind == "test" and not tag:
|
||||
if kind == "test" and not tag and not maintenance:
|
||||
ignores = {"all": None, "non-release": "/(develop|release/.*)/",
|
||||
"non-release-no-integration": "/(develop|release/.*|integration.*)/",
|
||||
"feature": "/(develop|main|release/.*|integration.*)/",
|
||||
@@ -214,7 +243,7 @@ def qbit_template(config, branch, tag):
|
||||
ignored = ignores[config.get("test_branch_policy", "all")]
|
||||
if ignored:
|
||||
filters["branches"]["ignore"] = ["automation/qbit-rc-pending", ignored]
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" else False
|
||||
docs_base = proven_docs_only(config, branch, tag) if kind == "test" and not maintenance else False
|
||||
if docs_base:
|
||||
# Keep the existing workflow/result identity even when Maven is not needed.
|
||||
result["jobs"] = {"docs_only": {"resource_class": "small", "docker": [{"image": "cimg/base:2026.03"}],
|
||||
@@ -313,7 +342,10 @@ def frontend_template(config, branch, tag):
|
||||
kind = "release"
|
||||
if kind != "test" and not config["publish"][kind]:
|
||||
kind = "test"
|
||||
if kind == "test" and proven_docs_only(config, branch, tag):
|
||||
maintenance = proven_ci_maintenance(branch, tag)
|
||||
if maintenance:
|
||||
kind = "test"
|
||||
if kind == "test" and not maintenance and proven_docs_only(config, branch, tag):
|
||||
result = qbit_template(config, branch, tag)
|
||||
result["workflows"]["test_only"]["jobs"][0]["docs_only"]["name"] = (
|
||||
"qqq-orb/mvn_frontend_test_only" if material else "qqq-orb/node_test_only")
|
||||
@@ -416,7 +448,13 @@ 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}
|
||||
|
||||
|
||||
@@ -649,7 +649,9 @@
|
||||
"qqq-orb/mvn_publish": {
|
||||
"requires": [
|
||||
"sample_bootstrap_source",
|
||||
"snapshot_esb_broker_conformance"
|
||||
"snapshot_esb_broker_conformance",
|
||||
"snapshot_sample_coverage_gate",
|
||||
"qqq-orb/static_analysis"
|
||||
],
|
||||
"pre-steps": [
|
||||
"configure-package-install"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"version": 2.1,
|
||||
"jobs": {
|
||||
"validate-policy": {
|
||||
"docker": [
|
||||
{
|
||||
"image": "cimg/python:3.12"
|
||||
}
|
||||
],
|
||||
"resource_class": "small",
|
||||
"steps": [
|
||||
"checkout",
|
||||
{
|
||||
"run": {
|
||||
"name": "Install the YAML parser",
|
||||
"command": "python3 -m pip install --disable-pip-version-check PyYAML==6.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": {
|
||||
"name": "Validate the application-free branch",
|
||||
"command": "python3 \\<<'PYTHON'\nimport json\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,6 +45,7 @@ PROFILE_PARAMETERS = {
|
||||
"app-starter": {},
|
||||
"android": {},
|
||||
"mcp-policy": {},
|
||||
"repository-policy": {},
|
||||
"marketing": {},
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ def load_yaml(raw):
|
||||
raise StandardError("Invalid YAML declaration") from error
|
||||
|
||||
|
||||
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None):
|
||||
def canonical_caller(profile, version, explicit_manifest=False, release_tag_policy=None, publish_feature=False):
|
||||
if not isinstance(profile, str) or profile not in PROFILE_PARAMETERS:
|
||||
raise StandardError("Unsupported CI profile")
|
||||
options = {
|
||||
@@ -72,6 +73,9 @@ def canonical_caller(profile, version, explicit_manifest=False, release_tag_poli
|
||||
if release_tag_policy not in tag_filters:
|
||||
raise StandardError("Unsupported QBit release tag policy")
|
||||
options["filters"]["tags"] = tag_filters[release_tag_policy]
|
||||
if publish_feature:
|
||||
options["filters"]["tags"] = {"only": ([tag_filters[release_tag_policy]["only"]]
|
||||
if release_tag_policy != "none" else []) + ["/publish.*/"]}
|
||||
if explicit_manifest:
|
||||
options["manifest"] = ".qqq-ci.yml"
|
||||
parameters = PROFILE_PARAMETERS[profile]
|
||||
@@ -105,12 +109,15 @@ def validate(config_raw, manifest_raw, setup_version):
|
||||
if not isinstance(manifest, dict):
|
||||
raise StandardError("Manifest must be a mapping")
|
||||
version = manifest.get("orb_version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+\.\d+|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise StandardError("Manifest must pin an explicit orb version")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise StandardError("Manifest must select a quoted minor track, exact stable pin, or development version")
|
||||
if version != setup_version:
|
||||
raise StandardError("Manifest and running setup orb versions differ")
|
||||
expected = canonical_caller(manifest.get("profile"), version, release_tag_policy=manifest.get("release_tag_policy"))
|
||||
explicit = canonical_caller(manifest.get("profile"), version, explicit_manifest=True, release_tag_policy=manifest.get("release_tag_policy"))
|
||||
publishing = manifest.get("publish", {})
|
||||
if not isinstance(publishing, dict) or type(publishing.get("feature", False)) is not bool:
|
||||
raise StandardError("Feature publication must be an explicit boolean")
|
||||
expected = canonical_caller(manifest.get("profile"), version, release_tag_policy=manifest.get("release_tag_policy"), publish_feature=publishing.get("feature", False))
|
||||
explicit = canonical_caller(manifest.get("profile"), version, explicit_manifest=True, release_tag_policy=manifest.get("release_tag_policy"), publish_feature=publishing.get("feature", False))
|
||||
if not exact(config, expected) and not exact(config, explicit):
|
||||
raise StandardError("Consumer config must be the canonical setup caller with only its profile's declared and forwarded parameters")
|
||||
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
qqq-orb: kingsrook/qqq-orb@0.6.8
|
||||
|
||||
commands:
|
||||
configure-package-install:
|
||||
steps:
|
||||
- run:
|
||||
name: Keep package installation unattended
|
||||
command: |
|
||||
# These build machines are discarded after the job.
|
||||
sudo install -d /etc/needrestart/conf.d
|
||||
printf '%s\n' '$nrconf{restart} = "l";' | sudo tee /etc/needrestart/conf.d/99-qqq-ci.conf >/dev/null
|
||||
|
||||
workflows:
|
||||
test_only:
|
||||
jobs:
|
||||
- qqq-orb/mvn_test_only:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
filters:
|
||||
branches:
|
||||
ignore: /(develop|main|release/.*|hotfix/.*|integration.*)/
|
||||
tags:
|
||||
only: []
|
||||
|
||||
publish_snapshot:
|
||||
jobs:
|
||||
- qqq-orb/mvn_publish:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
branch_type: snapshot
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
|
||||
publish_feature:
|
||||
jobs:
|
||||
- qqq-orb/mvn_publish:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
branch_type: feature
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- feature/.*
|
||||
tags:
|
||||
only: [/publish.*/]
|
||||
|
||||
publish_release_candidate:
|
||||
jobs:
|
||||
- qqq-orb/mvn_publish:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
branch_type: release_candidate
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- /release\/.*/
|
||||
|
||||
publish_release:
|
||||
jobs:
|
||||
- qqq-orb/mvn_publish:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
branch_type: release
|
||||
filters:
|
||||
branches:
|
||||
ignore: /.*/
|
||||
tags:
|
||||
only: [/^v\d+\.\d+\.\d+$/]
|
||||
|
||||
publish_hotfix_release:
|
||||
jobs:
|
||||
- qqq-orb/mvn_publish:
|
||||
pre-steps:
|
||||
- configure-package-install
|
||||
context: [qqq-maven-registry-credentials]
|
||||
branch_type: hotfix
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- /hotfix\/.*/
|
||||
+141
-1
@@ -1,4 +1,6 @@
|
||||
import importlib.util
|
||||
import json
|
||||
import io
|
||||
import pathlib
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -25,7 +27,124 @@ class Snapshot:
|
||||
return self.required
|
||||
|
||||
|
||||
class InventoryTests(unittest.TestCase):
|
||||
def repo(self, name, archived=False):
|
||||
return {'name': name, 'full_name': 'QRun-IO/' + name,
|
||||
'archived': archived, 'default_branch': 'main'}
|
||||
|
||||
def test_all_pages_include_new_private_and_archived_repositories(self):
|
||||
new = dict(self.repo('new-product'), private=True)
|
||||
pages = [[self.repo('qbit-existing')], [new, self.repo('retired', True)]]
|
||||
with patch.object(audit, 'command', return_value=json.dumps(pages)) as command:
|
||||
entries = audit.discover_inventory('QRun-IO')
|
||||
self.assertEqual([e['name'] for e in entries], ['new-product', 'qbit-existing', 'retired'])
|
||||
self.assertTrue(entries[-1]['isArchived'])
|
||||
self.assertEqual(command.call_args.args[0], ['gh', 'api', '--method', 'GET',
|
||||
'--paginate', '--slurp', 'orgs/QRun-IO/repos?type=all&per_page=100'])
|
||||
|
||||
def test_empty_duplicate_foreign_and_malformed_inventories_fail_closed(self):
|
||||
repo = self.repo('qbit-example')
|
||||
for pages in ([], [[]], {}, [repo], [[repo], [repo]],
|
||||
[[dict(repo, full_name='Other/qbit-example')]],
|
||||
[[dict(repo, archived='false')]], [[dict(repo, default_branch=None)]]):
|
||||
with self.subTest(pages=pages), patch.object(audit, 'command', return_value=json.dumps(pages)):
|
||||
with self.assertRaises(audit.ReadError):
|
||||
audit.discover_inventory('QRun-IO')
|
||||
with patch.object(audit, 'command') as command:
|
||||
with self.assertRaises(audit.ReadError):
|
||||
audit.discover_inventory('QRun-IO/../../other')
|
||||
command.assert_not_called()
|
||||
|
||||
def test_live_cli_count_is_dynamic_but_explicit_expectation_is_enforced(self):
|
||||
for expected, status in ((None, 0), ('1', 0), ('68', 1)):
|
||||
args = ['audit', '--organization', 'QRun-IO', '--live', '--orb-version', '0.8']
|
||||
if expected:
|
||||
args += ['--expected-active', expected]
|
||||
report = {'active_count': 1, 'unique_repository_count': 1,
|
||||
'inventory_count': 1, 'results': [{'status': 'pass'}]}
|
||||
output = io.StringIO()
|
||||
with patch.object(audit.sys, 'argv', args), patch.object(audit.sys, 'stdout', output), \
|
||||
patch.object(audit, 'discover_inventory', return_value=[ENTRY]), \
|
||||
patch.object(audit, 'run', return_value=report):
|
||||
self.assertEqual(audit.main(), status)
|
||||
self.assertEqual(json.loads(output.getvalue())['inventory_source'], 'organization-api')
|
||||
|
||||
def test_discovery_api_failure_never_falls_back_to_old_inventory(self):
|
||||
with patch.object(audit, 'command', side_effect=audit.ReadError('unavailable')):
|
||||
with self.assertRaises(audit.ReadError):
|
||||
audit.discover_inventory('QRun-IO')
|
||||
|
||||
|
||||
class AuditTests(unittest.TestCase):
|
||||
def test_all_scanner_and_release_requirements_follow_branch_profile(self):
|
||||
entry = dict(ENTRY, name='qqq-all', nameWithOwner='QRun-IO/qqq-all')
|
||||
scanner = '.github/workflows/codeql.yml'
|
||||
release = audit.auxiliary.BRIDGES['all-release']['path']
|
||||
for profile in ('all', 'repository-policy'):
|
||||
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': profile, 'orb_version': VERSION, 'default_branch': 'develop'}),
|
||||
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller(profile, VERSION))}
|
||||
policy = dict(POLICY, profile=profile, codeql_worker_sha=SHA)
|
||||
report = audit.audit(entry, Snapshot(files), VERSION, SHA, policy)
|
||||
missing = {f.get('path') for f in report['findings'] if f['code'] == 'missing_native_maintenance_bridge'}
|
||||
self.assertIn(scanner, missing)
|
||||
self.assertEqual(profile == 'all', release in missing)
|
||||
files[scanner] = audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-codeql', SHA), sort_keys=False)
|
||||
if profile == 'all':
|
||||
files[release] = audit.generator.yaml.safe_dump(audit.auxiliary.canonical('all-release', SHA), sort_keys=False)
|
||||
self.assertEqual([], audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings'])
|
||||
files[scanner] = files[scanner].replace(SHA, 'b' * 40)
|
||||
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings']])
|
||||
files[release] = 'jobs: {}'
|
||||
self.assertTrue(any(f['code'] == 'native_maintenance_bridge_drift' and f.get('path') == release for f in audit.audit(entry, Snapshot(files), VERSION, SHA, policy)['findings']))
|
||||
|
||||
def test_schema_drift_bridge_tracks_branch_source_without_exempting_default(self):
|
||||
entry = dict(ENTRY, name='qbit-authentik', nameWithOwner='QRun-IO/qbit-authentik')
|
||||
path = '.github/workflows/schema-drift.yml'
|
||||
cases = [
|
||||
('main', {}, False),
|
||||
('main', {'src/test/java/example/SchemaDriftTest.java': 'class SchemaDriftTest {}'}, True),
|
||||
('develop', {}, True),
|
||||
]
|
||||
for branch, files, required in cases:
|
||||
with self.subTest(branch=branch, files=files):
|
||||
snapshot = Snapshot(files)
|
||||
snapshot.branch, snapshot.default_branch = branch, 'develop'
|
||||
report = audit.audit(entry, snapshot, VERSION, SHA, POLICY)
|
||||
missing = any(f['code'] == 'missing_native_maintenance_bridge' and f.get('path') == path for f in report['findings'])
|
||||
self.assertEqual(required, missing)
|
||||
snapshot = Snapshot({path: 'jobs: {}'})
|
||||
snapshot.branch, snapshot.default_branch = 'main', 'develop'
|
||||
report = audit.audit(entry, snapshot, VERSION, SHA, POLICY)
|
||||
self.assertIn('native_maintenance_bridge_drift', [f['code'] for f in report['findings']])
|
||||
|
||||
def test_placeholder_can_retain_canonical_release_and_scanner_bridges(self):
|
||||
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
|
||||
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': 'repository-policy', 'orb_version': VERSION, 'default_branch': 'develop'}),
|
||||
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('repository-policy', VERSION)),
|
||||
audit.rc_worker.CALLER_PATH: audit.rc_worker.generate(SHA),
|
||||
'.github/workflows/codeql.yml': audit.generator.yaml.safe_dump(audit.auxiliary.canonical('qbit-codeql', SHA), sort_keys=False)}
|
||||
snapshot = Snapshot(files)
|
||||
snapshot.branch = 'main'
|
||||
snapshot.default_branch = 'develop'
|
||||
policy = dict(POLICY, branch_profiles={'main': 'repository-policy'}, rc_worker_sha=SHA, codeql_worker_sha=SHA)
|
||||
self.assertEqual([], audit.audit(entry, snapshot, VERSION, SHA, policy)['findings'])
|
||||
files['.github/workflows/codeql.yml'] = files['.github/workflows/codeql.yml'].replace(SHA, 'b' * 40)
|
||||
self.assertTrue(any(f['code'] == 'native_maintenance_bridge_drift' for f in audit.audit(entry, snapshot, VERSION, SHA, policy)['findings']))
|
||||
|
||||
def test_placeholder_profile_is_scoped_to_selected_branch(self):
|
||||
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
|
||||
files = {'.qqq-ci.yml': audit.generator.yaml.safe_dump({'profile': 'repository-policy', 'orb_version': VERSION, 'default_branch': 'develop'}),
|
||||
'.circleci/config.yml': audit.generator.yaml.safe_dump(audit.standard.canonical_caller('repository-policy', VERSION))}
|
||||
snapshot = Snapshot(files)
|
||||
snapshot.branch = 'main'
|
||||
snapshot.default_branch = 'develop'
|
||||
policy = dict(POLICY, branch_profiles={'main': 'repository-policy'})
|
||||
self.assertEqual([], audit.audit(entry, snapshot, VERSION, SHA, policy)['findings'])
|
||||
snapshot.branch = 'develop'
|
||||
report = audit.audit(entry, snapshot, VERSION, SHA, policy)
|
||||
self.assertEqual('qbit', report['profile'])
|
||||
self.assertTrue(any(f['code'] == 'profile_mismatch' for f in report['findings']))
|
||||
|
||||
def test_qbit_scanner_policy_requires_exact_canonical_worker(self):
|
||||
entry = dict(ENTRY, name='qbit-help', nameWithOwner='QRun-IO/qbit-help')
|
||||
manifest = {'profile': 'qbit', 'orb_version': VERSION, 'default_branch': 'develop',
|
||||
@@ -318,10 +437,31 @@ class AuditTests(unittest.TestCase):
|
||||
audit.audit(other, Snapshot({}, checks=[]), VERSION, SHA, policy)
|
||||
|
||||
def test_invalid_managed_branches_cannot_bypass_policy(self):
|
||||
for managed in [[], ['main', 'main'], ['feature'], 'main', None, [True]]:
|
||||
for managed in [[], ['main', 'main'], ['feature'], 'main', None, [True],
|
||||
['release/*'], ['release/1.2/extra'], ['hotfix/1..2'],
|
||||
['release/1.2', 'release/1.2']]:
|
||||
with self.subTest(managed=managed), self.assertRaises(audit.ReadError):
|
||||
self.native(policy={'managed_branches': managed, 'required_checks': {}})
|
||||
|
||||
def test_release_and_hotfix_enforcement_requires_actual_checks(self):
|
||||
files = {'.github/workflows/build.yml': audit.qctl.generate(SHA)}
|
||||
for branch in ['release/0.1', 'release/4.1.0', 'hotfix/4.0.1']:
|
||||
with self.subTest(branch=branch):
|
||||
snapshot = Snapshot(files)
|
||||
snapshot.branch = branch
|
||||
policy = {'managed_branches': [branch],
|
||||
'required_checks': {branch: ['native / test']}}
|
||||
with patch.object(snapshot, 'checks', wraps=snapshot.checks) as read:
|
||||
report = audit.audit(ENTRY, snapshot, VERSION, SHA, policy)
|
||||
self.assertEqual('pass', report['status'])
|
||||
read.assert_called_once_with(branch)
|
||||
snapshot.required = []
|
||||
report = audit.audit(ENTRY, snapshot, VERSION, SHA, policy)
|
||||
self.assertEqual('missing', report['required_checks'][branch]['state'])
|
||||
self.assertEqual('findings', report['status'])
|
||||
policy['required_checks'] = {}
|
||||
self.assertEqual('unknown', audit.audit(ENTRY, snapshot, VERSION, SHA, policy)['status'])
|
||||
|
||||
def test_gh_is_explicit_get_and_never_changes_settings(self):
|
||||
with patch.object(audit, 'command', return_value='{}') as command:
|
||||
audit.gh('repos/QRun-IO/example')
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Exercise real browser scripts without sudo, package installation or network.
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
mkdir "$scratch/bin"
|
||||
export INSTALL_LOG="$scratch/install.log"
|
||||
cat > "$scratch/bin/sudo" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf '%s\n' "$*" >> "$INSTALL_LOG"
|
||||
if [[ "$*" == *'apt-get update'* ]]; then
|
||||
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || { echo 'unrelated image PPA: 503' >&2; exit 100; }
|
||||
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 91
|
||||
[[ ${REQUIRED_REPO_FAIL:-0} == 0 ]] || exit 100
|
||||
fi
|
||||
if [[ "$1" == tee ]]; then cat >> "$INSTALL_LOG"; fi
|
||||
if [[ "$1" == gpg ]]; then cat >/dev/null; fi
|
||||
STUB
|
||||
chmod +x "$scratch/bin/sudo"
|
||||
export PATH="$scratch/bin:$PATH"
|
||||
bash "$root/src/scripts/frontend_test_dependencies.sh"
|
||||
echo 'PASS: browser dependencies ignore unavailable image PPAs'
|
||||
# Model Chrome presence without depending on the host's installed browsers.
|
||||
export CHROME_MARKER="$scratch/chrome-installed"
|
||||
export BASH_ENV="$scratch/shell-env"
|
||||
cat > "$BASH_ENV" <<'STUB'
|
||||
command() {
|
||||
if [[ "$*" == '-v google-chrome' ]]; then [[ -f "$CHROME_MARKER" ]]; else builtin command "$@"; fi
|
||||
}
|
||||
google-chrome() { [[ -f "$CHROME_MARKER" ]] && echo 'Google Chrome test'; }
|
||||
STUB
|
||||
cat > "$scratch/bin/curl" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf '%s\n' "$*" >> "$INSTALL_LOG"
|
||||
[[ ${KEY_FAIL:-0} == 0 ]] || exit 22
|
||||
printf 'signing-key\n'
|
||||
STUB
|
||||
cat > "$scratch/bin/dpkg" <<'STUB'
|
||||
#!/bin/bash
|
||||
echo amd64
|
||||
STUB
|
||||
# Successful installation makes Chrome available to the final version check.
|
||||
# shellcheck disable=SC2016
|
||||
sed -i '/if \[\[ "$1" == tee/i if [[ "$*" == *"apt-get install -y google-chrome-stable"* ]]; then touch "$CHROME_MARKER"; fi' "$scratch/bin/sudo"
|
||||
chmod +x "$scratch/bin/"*
|
||||
: > "$INSTALL_LOG"
|
||||
bash "$root/src/scripts/install_chrome.sh" >/dev/null
|
||||
grep -q 'Dir::Etc::sourcelist=/etc/apt/sources.list.d/qqq-google-chrome.list' "$INSTALL_LOG"
|
||||
grep -q 'gpg --batch --yes --dearmor -o /usr/share/keyrings/qqq-google-chrome.gpg' "$INSTALL_LOG"
|
||||
grep -q 'signed-by=/usr/share/keyrings/qqq-google-chrome.gpg] https://dl.google.com/linux/chrome/deb/' "$INSTALL_LOG"
|
||||
grep -q 'apt-get install -y google-chrome-stable' "$INSTALL_LOG"
|
||||
: > "$INSTALL_LOG"
|
||||
bash "$root/src/scripts/install_chrome.sh" >/dev/null
|
||||
[[ ! -s "$INSTALL_LOG" ]] # Existing Chrome needs no network/package work.
|
||||
rm "$CHROME_MARKER"
|
||||
for script in install_chrome frontend_test_dependencies; do
|
||||
: > "$INSTALL_LOG"
|
||||
if REQUIRED_REPO_FAIL=1 bash "$root/src/scripts/$script.sh" >/dev/null 2>&1; then
|
||||
echo "Required repository outage accepted: $script" >&2; exit 1
|
||||
fi
|
||||
if grep -q 'apt-get install' "$INSTALL_LOG"; then exit 1; fi
|
||||
done
|
||||
: > "$INSTALL_LOG"
|
||||
if KEY_FAIL=1 bash "$root/src/scripts/install_chrome.sh" >/dev/null 2>&1; then
|
||||
echo 'Signing key failure accepted' >&2; exit 1
|
||||
fi
|
||||
if grep -q 'apt-get' "$INSTALL_LOG"; then exit 1; fi
|
||||
echo 'PASS: Chrome ignores unrelated PPAs; required repositories and signing key fail closed; existing browser reused'
|
||||
@@ -0,0 +1,109 @@
|
||||
"""CI maintenance retains Maven verification and never becomes a release request."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('pipeline', ROOT/'src/scripts/generate_pipeline.py')
|
||||
pipeline = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(pipeline)
|
||||
|
||||
|
||||
class MaintenanceTests(unittest.TestCase):
|
||||
def git_result(self, *args):
|
||||
return {'log': self.subject, 'rev-list': self.parents, 'diff': self.paths}.get(args[0])
|
||||
|
||||
def setUp(self):
|
||||
self.subject = b'ci: use central pipeline\n'
|
||||
self.parents = b'a'*40 + b' ' + b'b'*40 + b'\n'
|
||||
self.paths = b'.qqq-ci.yml\0.circleci/config.yml\0.github/workflows/codeql.yml\0.github/workflows/release-rc.yml\0'
|
||||
|
||||
def test_publishing_branches_keep_unfiltered_maven_tests(self):
|
||||
manifest = {'profile': 'qbit', 'orb_version': '0.7.14', 'default_branch': 'develop',
|
||||
'release_on_main': True, 'test_branch_policy': 'feature-no-hotfix',
|
||||
'publish': {'hotfix': True}}
|
||||
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
config = pipeline.load_manifest('unused', '0.7.14')
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
for branch in ('main', 'develop', 'release/0.1', 'hotfix/1.2.3'):
|
||||
with self.subTest(branch=branch):
|
||||
result = pipeline.qbit_template(config, branch, '')
|
||||
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/mvn_test_only']
|
||||
self.assertEqual(job['filters']['branches'], {'ignore': 'automation/qbit-rc-pending'})
|
||||
self.assertNotIn('branch_type', job)
|
||||
|
||||
def test_nonpublishing_branches_verify_maintenance_but_keep_application_policy(self):
|
||||
manifest = {'profile': 'qbit', 'orb_version': '0.8', 'default_branch': 'main',
|
||||
'release_on_main': False, 'test_branch_policy': 'feature-no-hotfix',
|
||||
'publish': {'snapshot': False, 'release_candidate': False, 'hotfix': False}}
|
||||
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
config = pipeline.load_manifest('unused', '0.8')
|
||||
maintenance_paths = self.paths
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
for branch in ('main', 'develop', 'release/0.1', 'hotfix/1.2.3'):
|
||||
for maintenance in (True, False):
|
||||
with self.subTest(branch=branch, maintenance=maintenance):
|
||||
self.paths = maintenance_paths if maintenance else b'src/Main.java\0'
|
||||
result = pipeline.qbit_template(config, branch, '')
|
||||
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/mvn_test_only']
|
||||
ignored = job['filters']['branches']['ignore']
|
||||
if maintenance:
|
||||
self.assertEqual(ignored, 'automation/qbit-rc-pending')
|
||||
else:
|
||||
self.assertEqual(ignored, ['automation/qbit-rc-pending',
|
||||
'/(develop|main|release/.*|hotfix/.*|integration.*)/'])
|
||||
self.assertNotIn('branch_type', job)
|
||||
|
||||
def test_frontend_maintenance_verifies_without_publishing(self):
|
||||
for profile, prefix in (('frontend-core', 'node_'), ('frontend-material', 'mvn_frontend_')):
|
||||
manifest = {'profile': profile, 'orb_version': '0.8', 'default_branch': 'develop'}
|
||||
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
config = pipeline.load_manifest('unused', '0.8')
|
||||
for branch in ('main', 'develop', 'release/1.0', 'hotfix/1.0.1'):
|
||||
with self.subTest(profile=profile, branch=branch), mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
result = pipeline.frontend_template(config, branch, '')
|
||||
job = result['workflows']['test_only']['jobs'][0]['qqq-orb/' + prefix + 'test_only']
|
||||
self.assertNotIn('branch_type', job)
|
||||
self.assertEqual(job['filters']['branches'], {'ignore': 'automation/qbit-rc-pending'})
|
||||
self.paths = b'package.json\0'
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
result = pipeline.frontend_template(config, 'develop', '')
|
||||
self.assertIn('qqq-orb/' + prefix + 'publish', result['workflows']['publish_snapshot']['jobs'][0])
|
||||
self.paths = b'.qqq-ci.yml\0'
|
||||
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
|
||||
result = pipeline.frontend_template(config, 'main', 'v1.2.3')
|
||||
job = result['workflows']['publish_release']['jobs'][0]['qqq-orb/' + prefix + 'publish']
|
||||
self.assertEqual(job['branch_type'], 'release')
|
||||
|
||||
def test_application_changes_and_unknown_files_publish_normally(self):
|
||||
for paths in (b'pom.xml\0', b'.qqq-ci.yml\0src/Main.java\0', b'.github/workflows/custom-release.yml\0', b'', None):
|
||||
self.paths = paths
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
|
||||
|
||||
def test_schema_caller_migration_is_maintenance_but_schema_inputs_are_not(self):
|
||||
self.paths = b'.github/workflows/schema-drift.yml\0'
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
self.assertTrue(pipeline.proven_ci_maintenance('release/0.1', ''))
|
||||
for path in (b'pom.xml\0', b'src/test/resources/schema.yml\0', b'src/test/java/SchemaDriftTest.java\0'):
|
||||
self.paths = b'.github/workflows/schema-drift.yml\0' + path
|
||||
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
|
||||
|
||||
def test_merge_root_and_unavailable_history_do_not_suppress_release(self):
|
||||
for parents in (None, b'a'*40+b'\n', self.parents.rstrip()+b' '+b'c'*40+b'\n'):
|
||||
self.parents = parents
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
|
||||
|
||||
def test_tags_and_release_requests_do_not_suppress_release(self):
|
||||
with mock.patch.object(pipeline, 'git', side_effect=self.git_result):
|
||||
self.assertFalse(pipeline.proven_ci_maintenance('main', 'v1.2.3'))
|
||||
for subject in (b'Merge develop for next RC\n', b'fix: application\n', None):
|
||||
self.subject = subject
|
||||
self.assertFalse(pipeline.proven_ci_maintenance('release/0.1', ''))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Exercise the real version script and Maven install; never publish remotely."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
NS = {'m': 'http://maven.apache.org/POM/4.0.0'}
|
||||
BASH = os.environ.get('TEST_BASH') or shutil.which('bash')
|
||||
MAVEN = shutil.which('mvn') or shutil.which('mvn.cmd')
|
||||
|
||||
|
||||
def run(args, directory, env=None):
|
||||
subprocess.run(args, cwd=directory, env=env, check=True, timeout=300)
|
||||
|
||||
|
||||
def project(body):
|
||||
return '<project xmlns="http://maven.apache.org/POM/4.0.0">\n<modelVersion>4.0.0</modelVersion>\n' + body + '\n</project>\n'
|
||||
|
||||
|
||||
def main():
|
||||
assert BASH and MAVEN, 'Real Bash, Java and Maven are required'
|
||||
with tempfile.TemporaryDirectory(prefix='qqq-version-') as temporary:
|
||||
base = Path(temporary)
|
||||
for name, version, revision, branch, expected, reactor in (
|
||||
('literal', '0.4.0-SNAPSHOT', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', False),
|
||||
('friendly', '${revision}', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', False),
|
||||
('reactor', '0.4.0-SNAPSHOT', '0.4.0-RC.1', 'release/0.4', '0.4.0-RC.2', True),
|
||||
('unchanged', '0.3.0-SNAPSHOT', '0.4.0-SNAPSHOT', 'develop', '0.4.0-SNAPSHOT', False),
|
||||
):
|
||||
root = base / name
|
||||
root.mkdir()
|
||||
modules = '<modules><module>child</module></modules>' if reactor else ''
|
||||
(root / 'pom.xml').write_text(project(f'''<groupId>example.version</groupId>
|
||||
<artifactId>{name}</artifactId><version>{version}</version><packaging>pom</packaging>
|
||||
<properties>
|
||||
<revision>{revision}</revision>
|
||||
</properties>
|
||||
{modules}'''), encoding='utf-8')
|
||||
if reactor:
|
||||
(root / 'child').mkdir()
|
||||
(root / 'child/pom.xml').write_text(project(f'''<parent><groupId>example.version</groupId>
|
||||
<artifactId>{name}</artifactId><version>{version}</version></parent>
|
||||
<artifactId>child</artifactId><packaging>pom</packaging>'''), encoding='utf-8')
|
||||
run(['git', 'init', '-q'], root)
|
||||
env = dict(os.environ, CIRCLE_BRANCH=branch, CIRCLE_TAG='')
|
||||
run([BASH, str(ROOT / 'src/scripts/calculate_version.sh')], root, env)
|
||||
if name == 'friendly':
|
||||
assert ET.parse(root / 'pom.xml').findtext('m:version', namespaces=NS) == '${revision}'
|
||||
# Install to a temporary repository so the actual artifact coordinate
|
||||
# proves the fix, rather than merely checking the revision property.
|
||||
repository = base / 'repository'
|
||||
run([MAVEN, '-B', '-ntp', '-Dmaven.repo.local=' + str(repository),
|
||||
'-Dflatten.mode=resolveCiFriendliesOnly', '-DupdatePomFile=true',
|
||||
'org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten', 'install'], root)
|
||||
for artifact in ([name, 'child'] if reactor else [name]):
|
||||
installed = repository / 'example/version' / artifact / expected / f'{artifact}-{expected}.pom'
|
||||
assert installed.exists(), installed
|
||||
pom = ET.parse(installed)
|
||||
actual = pom.findtext('m:version', namespaces=NS) or pom.findtext('m:parent/m:version', namespaces=NS)
|
||||
assert actual == expected, (artifact, actual, expected)
|
||||
print(f'PASS: {name} installed at {expected}', flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,92 @@
|
||||
"""Shared enforcement only adds proven gates and preserves unrelated policy."""
|
||||
import copy
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location('enforcement', Path(__file__).resolve().parents[1] / 'tools/enforce_orb_checks.py')
|
||||
enforcement = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(enforcement)
|
||||
|
||||
|
||||
def runs():
|
||||
return [{'id': index, 'name': name, 'app': {'id': 18001}, 'conclusion': 'success'}
|
||||
for index, name in enumerate(('setup', 'verify'), 1)]
|
||||
|
||||
|
||||
class EnforcementTests(unittest.TestCase):
|
||||
def test_preserves_security_gate_and_binds_orb_checks(self):
|
||||
before = {'required_status_checks': {'strict': False, 'contexts': ['security', 'setup'],
|
||||
'checks': [{'context': 'security', 'app_id': 15368}, {'context': 'setup', 'app_id': -1}]}}
|
||||
original = copy.deepcopy(before)
|
||||
result = enforcement.required_checks(before, runs())
|
||||
self.assertEqual(original, before)
|
||||
self.assertEqual(result, {'strict': True, 'checks': [{'context': 'security', 'app_id': 15368}, *enforcement.DESIRED]})
|
||||
|
||||
def test_wrong_app_failed_latest_and_missing_checks_reject(self):
|
||||
cases = [[], [runs()[0]], [dict(run, app={'id': 999}) for run in runs()],
|
||||
runs() + [dict(runs()[1], id=3, conclusion='failure')]]
|
||||
for candidate in cases:
|
||||
with self.subTest(candidate=candidate), self.assertRaises(ValueError):
|
||||
enforcement.required_checks(None, candidate)
|
||||
with self.assertRaises(ValueError):
|
||||
enforcement.required_checks({'required_status_checks': {'checks': [{'context': 'verify', 'app_id': 999}]}}, runs())
|
||||
|
||||
def test_existing_unrestricted_contexts_are_retained(self):
|
||||
result = enforcement.required_checks({'required_status_checks': {'contexts': ['legacy-build']}}, runs())
|
||||
self.assertIn({'context': 'legacy-build', 'app_id': -1}, result['checks'])
|
||||
|
||||
def fixture(self, before):
|
||||
state = {'before': copy.deepcopy(before), 'head': 'a' * 40, 'writes': []}
|
||||
def request(path, method='GET', payload=None):
|
||||
if method != 'GET':
|
||||
state['writes'].append((method, path, payload))
|
||||
if method == 'PUT':
|
||||
state['before'] = {**payload, 'enforce_admins': {'enabled': True}}
|
||||
elif method == 'PATCH':
|
||||
state['before']['required_status_checks'] = copy.deepcopy(payload)
|
||||
elif method == 'POST':
|
||||
state['before']['enforce_admins'] = {'enabled': True}
|
||||
return None
|
||||
if '/rules/' in path:
|
||||
return []
|
||||
if path.endswith('/protection'):
|
||||
return copy.deepcopy(state['before'])
|
||||
return {'commit': {'sha': state['head']}}
|
||||
plan = {'repository': 'QRun-IO/example', 'branch': 'develop', 'head': 'a' * 40,
|
||||
'before': copy.deepcopy(before), 'required_status_checks': enforcement.required_checks(before, runs()), 'changed': True}
|
||||
return plan, request, state
|
||||
|
||||
def test_narrow_updates_preserve_reviews_signatures_and_restrictions(self):
|
||||
before = {'required_status_checks': {'strict': False, 'checks': []}, 'enforce_admins': {'enabled': False},
|
||||
'required_signatures': {'enabled': True}, 'required_linear_history': {'enabled': True},
|
||||
'required_pull_request_reviews': {'required_approving_review_count': 2},
|
||||
'restrictions': {'users': [{'login': 'owner'}]}}
|
||||
plan, request, state = self.fixture(before)
|
||||
enforcement.enforce(plan, request)
|
||||
self.assertEqual(['PATCH', 'POST'], [write[0] for write in state['writes']])
|
||||
for key in ('required_signatures', 'required_linear_history', 'required_pull_request_reviews', 'restrictions'):
|
||||
self.assertEqual(before[key], state['before'][key])
|
||||
|
||||
def test_new_protection_and_idempotent_noop(self):
|
||||
plan, request, state = self.fixture(None)
|
||||
enforcement.enforce(plan, request)
|
||||
self.assertEqual('PUT', state['writes'][0][0])
|
||||
self.assertIsNone(state['before']['required_pull_request_reviews'])
|
||||
plan['before'] = copy.deepcopy(state['before'])
|
||||
plan['changed'] = False
|
||||
state['writes'] = []
|
||||
enforcement.enforce(plan, request)
|
||||
self.assertEqual([], state['writes'])
|
||||
|
||||
def test_head_or_protection_drift_never_mutates(self):
|
||||
for field, value in [('head', 'b' * 40), ('before', {'unexpected': True})]:
|
||||
plan, request, state = self.fixture(None)
|
||||
state[field] = value
|
||||
with self.assertRaises(ValueError):
|
||||
enforcement.enforce(plan, request)
|
||||
self.assertEqual([], state['writes'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Exercise the actual test runner with no server, browser, network or Maven work.
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
mkdir "$scratch/bin"
|
||||
export RUN_LOG="$scratch/calls"
|
||||
cat > "$scratch/bin/npm" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'npm %s\n' "$*" >> "$RUN_LOG"
|
||||
if [[ "$*" == 'run build' && ${BUILD_FAIL:-0} == 1 ]]; then exit 12; fi
|
||||
STUB
|
||||
for tool in mvn dockerize; do
|
||||
# shellcheck disable=SC2016
|
||||
printf '#!/bin/bash\nprintf "%s %%s\\n" "$*" >> "$RUN_LOG"\n' "$tool" > "$scratch/bin/$tool"
|
||||
done
|
||||
chmod +x "$scratch/bin/"*
|
||||
export PATH="$scratch/bin:$PATH"
|
||||
cd "$scratch"
|
||||
PARAM_BUILD_BEFORE_TEST=false bash "$root/src/scripts/frontend_test_run.sh" >/dev/null
|
||||
if grep -qx 'npm run build' "$RUN_LOG"; then
|
||||
echo 'FAIL: combined job rebuilt the already-built React app' >&2; exit 1
|
||||
fi
|
||||
grep -q '^mvn .* -B test$' "$RUN_LOG"
|
||||
echo 'PASS: combined job retains tests without a duplicate build'
|
||||
|
||||
: > "$RUN_LOG"
|
||||
bash "$root/src/scripts/frontend_test_run.sh" >/dev/null
|
||||
grep -qx 'npm run build' "$RUN_LOG"
|
||||
grep -q '^mvn .* -B test$' "$RUN_LOG"
|
||||
: > "$RUN_LOG"
|
||||
if BUILD_FAIL=1 bash "$root/src/scripts/frontend_test_run.sh" >/dev/null 2>&1; then
|
||||
echo 'FAIL: required standalone build failure ignored' >&2; exit 1
|
||||
fi
|
||||
if grep -q '^mvn ' "$RUN_LOG"; then exit 1; fi
|
||||
echo 'PASS: standalone command still builds and fails before tests when its build fails'
|
||||
@@ -202,6 +202,35 @@ class PipelineTests(unittest.TestCase):
|
||||
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"])
|
||||
@@ -212,6 +241,15 @@ class PipelineTests(unittest.TestCase):
|
||||
self.assertTrue(options["check_middleware_api_versions"])
|
||||
self.assertEqual(options["java_version"], "17")
|
||||
|
||||
def test_minor_track_reaches_continuation_without_changing_jobs(self):
|
||||
expected = self.render()
|
||||
expected['orbs']['qqq-orb'] = 'kingsrook/qqq-orb@0.7'
|
||||
self.write_manifest(orb_version='0.7')
|
||||
self.assertEqual(expected, self.render(QQQ_CI_ORB_VERSION='0.7'))
|
||||
if PACKED:
|
||||
self.assertEqual(expected, self.render(packed=True, QQQ_CI_ORB_VERSION='0.7'))
|
||||
self.render(ok=False, QQQ_CI_ORB_VERSION='0.8')
|
||||
|
||||
def test_branch_matrix(self):
|
||||
for branch, workflow in [("develop", "publish_snapshot"), ("release/1.0", "publish_release_candidate"),
|
||||
("main", "test_only"), ("hotfix/fix", "test_only"),
|
||||
@@ -239,6 +277,28 @@ class PipelineTests(unittest.TestCase):
|
||||
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)
|
||||
@@ -369,9 +429,27 @@ class PipelineTests(unittest.TestCase):
|
||||
self.change_docs()
|
||||
self.assertIn("docs_only", self.render()["jobs"])
|
||||
|
||||
def test_core_snapshot_publisher_waits_for_all_acceptance_and_analysis(self):
|
||||
self.write_manifest(profile="core")
|
||||
result = self.render(CIRCLE_BRANCH="develop")
|
||||
jobs = {options.get("name", kind): options
|
||||
for entry in result["workflows"]["verify"]["jobs"]
|
||||
for kind, options in entry.items()}
|
||||
def ancestors(name, path=()):
|
||||
self.assertNotIn(name, path, "Workflow dependencies must be acyclic")
|
||||
required = jobs[name].get("requires", [])
|
||||
return set(required).union(*(ancestors(parent, path + (name,)) for parent in required))
|
||||
self.assertEqual(ancestors("qqq-orb/mvn_publish"), set(jobs) - {"qqq-orb/mvn_publish"})
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="develop"))
|
||||
|
||||
def test_core_workflow_graphs_match_baseline(self):
|
||||
self.write_manifest(profile="core")
|
||||
baseline = yaml.safe_load((ROOT / "tests/fixtures/core_pipeline_baseline.yml").read_text(encoding="utf-8"))
|
||||
# Snapshot publication must now wait for the existing sample and analysis gates.
|
||||
for entry in baseline["workflows"]["publish_snapshot"]["jobs"]:
|
||||
if "qqq-orb/mvn_publish" in entry:
|
||||
entry["qqq-orb/mvn_publish"]["requires"] += ["snapshot_sample_coverage_gate", "qqq-orb/static_analysis"]
|
||||
self.git("tag", "v1.0.0")
|
||||
self.git("tag", "publish-fixture")
|
||||
events = [("feature/test", "", "test_only"), ("develop", "", "publish_snapshot"),
|
||||
@@ -545,6 +623,33 @@ class PipelineTests(unittest.TestCase):
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="main"))
|
||||
|
||||
def test_frontend_ci_only_commits_verify_with_packed_parity(self):
|
||||
for profile, job_name in (("frontend-core", "qqq-orb/node_test_only"),
|
||||
("frontend-material", "qqq-orb/mvn_frontend_test_only")):
|
||||
self.write_manifest(profile=profile)
|
||||
self.git("add", ".qqq-ci.yml")
|
||||
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: adopt managed orb")
|
||||
for branch in ("main", "develop"):
|
||||
with self.subTest(profile=profile, branch=branch):
|
||||
result = self.render(CIRCLE_BRANCH=branch)
|
||||
job = result["workflows"]["verify"]["jobs"][0][job_name]
|
||||
self.assertNotIn("branch_type", job)
|
||||
self.assertEqual(job["filters"]["branches"], {"ignore": "automation/qbit-rc-pending"})
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH=branch))
|
||||
|
||||
def test_nonpublishing_main_ci_change_runs_verification_with_packed_parity(self):
|
||||
self.write_manifest(default_branch="main", release_on_main=False,
|
||||
test_branch_policy="feature")
|
||||
self.git("add", ".qqq-ci.yml")
|
||||
self.git("-c", "commit.gpgsign=false", "commit", "-qm", "ci: use central pipeline")
|
||||
result = self.render(CIRCLE_BRANCH="main")
|
||||
job = result["workflows"]["verify"]["jobs"][0]["qqq-orb/mvn_test_only"]
|
||||
self.assertEqual(job["filters"]["branches"], {"ignore": "automation/qbit-rc-pending"})
|
||||
self.assertNotIn("branch_type", job)
|
||||
if PACKED:
|
||||
self.assertEqual(result, self.render(packed=True, CIRCLE_BRANCH="main"))
|
||||
|
||||
def test_qbit_publication_policy_packed_parity(self):
|
||||
self.write_manifest(release_on_main=True, release_tag_policy="v-prefix",
|
||||
test_branch_policy="feature")
|
||||
|
||||
@@ -6,6 +6,7 @@ scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
mkdir "$scratch/bin"
|
||||
export INSTALL_LOG="$scratch/install.log"
|
||||
export APT_CONFIG_CAPTURE="$scratch/apt.conf"
|
||||
export BASH_ENV="$scratch/bash-env"
|
||||
export QQQ_MAVEN_BIN_DIR="$scratch/maven-bin"
|
||||
: > "$BASH_ENV"
|
||||
@@ -14,6 +15,29 @@ cat > "$scratch/bin/sudo" <<'STUB'
|
||||
printf '%s\n' "$*" >> "$INSTALL_LOG"
|
||||
if [[ "$*" == *apt-get* ]]; then
|
||||
[[ "$1" == env && "$2" == DEBIAN_FRONTEND=noninteractive && "$3" == NEEDRESTART_MODE=l ]] || exit 90
|
||||
[[ -f "$APT_CONFIG_CAPTURE" ]] && grep -qx 'Acquire::Retries "3";' "$APT_CONFIG_CAPTURE" || exit 91
|
||||
[[ ${APT_FAIL:-0} == 0 ]] || exit "$APT_FAIL"
|
||||
if [[ "$*" == *'apt-get update'* ]]; then
|
||||
updates=$(grep -c 'apt-get update' "$INSTALL_LOG")
|
||||
if [[ $updates -eq 1 ]]; then
|
||||
# An unavailable image PPA must not participate in base-tool setup.
|
||||
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || exit 100
|
||||
[[ "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list'* || "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list.d/ubuntu.sources'* ]] || exit 93
|
||||
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 92
|
||||
[[ ${UBUNTU_UPDATE_FAIL:-0} == 0 ]] || exit "$UBUNTU_UPDATE_FAIL"
|
||||
fi
|
||||
if [[ $updates -eq 2 ]]; then
|
||||
# Model a PPA outage after the initial base-package installation. Only
|
||||
# the new signed repository may be contacted; existing indexes survive.
|
||||
[[ "$*" == *'Dir::Etc::sourcelist=/etc/apt/sources.list.d/adoptium.list'* ]] || exit 100
|
||||
[[ "$*" == *'Dir::Etc::sourceparts=-'* ]] || exit 100
|
||||
[[ "$*" == *'APT::Get::List-Cleanup=0'* ]] || exit 92
|
||||
[[ ${TEMURIN_UPDATE_FAIL:-0} == 0 ]] || exit "$TEMURIN_UPDATE_FAIL"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ "$1" == tee && "$2" == /etc/apt/apt.conf.d/80-qqq-download-retries ]]; then
|
||||
cat > "$APT_CONFIG_CAPTURE"; exit 0
|
||||
fi
|
||||
if [[ "$1" == tee || "$1" == gpg || "$1" == -E ]]; then cat >/dev/null; fi
|
||||
STUB
|
||||
@@ -32,9 +56,29 @@ grep -q 'tee /etc/needrestart/conf.d/99-qqq-ci.conf' "$INSTALL_LOG"
|
||||
grep -q 'export JAVA_HOME=' "$BASH_ENV"
|
||||
: > "$INSTALL_LOG"
|
||||
: > "$BASH_ENV"
|
||||
rm "$APT_CONFIG_CAPTURE"
|
||||
PARAM_INSTALL_NODE=true bash "$script_dir/install_java.sh" >/dev/null 2>&1
|
||||
[[ $(grep -c 'apt-get' "$INSTALL_LOG") -eq 5 ]]
|
||||
grep -q 'apt-get install -y -qq nodejs' "$INSTALL_LOG"
|
||||
# An outage of the required repository must still stop before Java installation.
|
||||
: > "$INSTALL_LOG"
|
||||
if UBUNTU_UPDATE_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
|
||||
echo 'required Ubuntu repository failure accepted' >&2; exit 1
|
||||
else
|
||||
[[ $? -eq 100 ]]
|
||||
fi
|
||||
if grep -q 'apt-get install' "$INSTALL_LOG"; then
|
||||
echo 'package installation continued after Ubuntu repository failure' >&2; exit 1
|
||||
fi
|
||||
: > "$INSTALL_LOG"
|
||||
if TEMURIN_UPDATE_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
|
||||
echo 'required Temurin repository failure accepted' >&2; exit 1
|
||||
else
|
||||
[[ $? -eq 100 ]]
|
||||
fi
|
||||
if grep -q 'apt-get install -y -qq temurin-' "$INSTALL_LOG"; then
|
||||
echo 'Java installation continued after repository failure' >&2; exit 1
|
||||
fi
|
||||
# Execute the actual generated selector. Arguments containing spaces stay intact.
|
||||
export SELECTOR_LOG="$scratch/selector.log"
|
||||
cat > "$scratch/bin/mvn" <<'NATIVE'
|
||||
@@ -82,4 +126,9 @@ if PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1;
|
||||
echo 'invalid native Maven accepted' >&2; exit 1
|
||||
fi
|
||||
unset -f mvn
|
||||
if APT_FAIL=100 PARAM_INSTALL_NODE=false bash "$script_dir/install_java.sh" >/dev/null 2>&1; then
|
||||
echo 'persistent apt failure accepted' >&2; exit 1
|
||||
else
|
||||
[[ $? -eq 100 ]]
|
||||
fi
|
||||
printf 'PASS: unattended installation and native/executable/nonexecutable wrapper selection\n'
|
||||
@@ -0,0 +1,73 @@
|
||||
"""Preserve Workflows' audited publish-tag contract without broadening branches."""
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
from test_qbit_hotfix_profile import load, migration, pipeline, selects, ROOT
|
||||
|
||||
standard = load('standard', 'src/scripts/validate_standard.py')
|
||||
|
||||
|
||||
class FeaturePublicationTests(unittest.TestCase):
|
||||
def config(self, manifest):
|
||||
with mock.patch.object(Path, 'read_text', return_value=yaml.safe_dump(manifest)):
|
||||
return pipeline.load_manifest('unused', '0.7.16')
|
||||
|
||||
def test_audited_event_selection_matches_legacy(self):
|
||||
legacy = yaml.safe_load((ROOT / 'tests/fixtures/qbit-feature-publication.yml').read_text())
|
||||
manifest = migration.infer_manifest(legacy, '0.7.16', 'main')
|
||||
self.assertTrue(manifest['publish']['feature'])
|
||||
caller = migration.canonical_caller('0.7.16', manifest['release_tag_policy'], True)
|
||||
standard.validate(yaml.safe_dump(caller), yaml.safe_dump(manifest), '0.7.16')
|
||||
setup = caller['workflows']['setup']['jobs'][0]['qqq-orb/generate_pipeline']
|
||||
cases = [(branch, '') for branch in ['main', 'develop', 'feature/example', 'release/0.3.0', 'hotfix/0.3.1', 'integration-test']]
|
||||
cases += [('', tag) for tag in ['publish', 'publish-example', 'v1.2.3', 'v1.2.3-RC.1', 'other']]
|
||||
for branch, tag in cases:
|
||||
with self.subTest(branch=branch, tag=tag):
|
||||
expected = sorted((job, args.get('branch_type')) for workflow in legacy['workflows'].values()
|
||||
for entry in workflow['jobs'] for job, args in entry.items()
|
||||
if selects(args.get('filters', {}), branch, tag))
|
||||
with mock.patch.object(pipeline, 'git', return_value=b'verified-head\n'):
|
||||
rendered = pipeline.qbit_template(self.config(manifest), branch, tag)
|
||||
actual = sorted((job, args.get('branch_type')) for workflow in rendered['workflows'].values()
|
||||
for entry in workflow['jobs'] for job, args in entry.items()
|
||||
if selects(args.get('filters', {}), branch, tag))
|
||||
if not selects(setup['filters'], branch, tag):
|
||||
actual = []
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_feature_is_opt_in_and_requires_exact_tag_head(self):
|
||||
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main'}
|
||||
self.assertFalse(self.config(manifest)['publish']['feature'])
|
||||
manifest['publish'] = {'feature': True}
|
||||
for tagged in [None, b'wrong-head\n']:
|
||||
def git(*args):
|
||||
return b'head\n' if args == ('rev-parse', 'HEAD') else tagged
|
||||
with self.subTest(tagged=tagged), mock.patch.object(pipeline, 'git', side_effect=git):
|
||||
rendered = pipeline.qbit_template(self.config(manifest), '', 'publish-test')
|
||||
self.assertIn('qqq-orb/mvn_test_only', rendered['workflows']['test_only']['jobs'][0])
|
||||
|
||||
def test_feature_tag_recovery_checks_fetched_commit(self):
|
||||
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main', 'publish': {'feature': True}}
|
||||
with mock.patch.object(pipeline, 'git', side_effect=[None, b'', b'head\n', b'head\n']):
|
||||
rendered = pipeline.qbit_template(self.config(manifest), '', 'publish-test')
|
||||
self.assertEqual('feature', rendered['workflows']['publish_feature']['jobs'][0]['qqq-orb/mvn_publish']['branch_type'])
|
||||
|
||||
def test_setup_preserves_release_policy_and_rejects_drift(self):
|
||||
for policy in ['stable', 'v-prefix', 'none']:
|
||||
manifest = {'profile': 'qbit', 'orb_version': '0.7.16', 'default_branch': 'main',
|
||||
'release_tag_policy': policy, 'publish': {'feature': True}}
|
||||
caller = migration.canonical_caller('0.7.16', policy, True)
|
||||
standard.validate(yaml.safe_dump(caller), yaml.safe_dump(manifest), '0.7.16')
|
||||
self.assertEqual(caller, standard.canonical_caller('qbit', '0.7.16', release_tag_policy=policy, publish_feature=True))
|
||||
with self.assertRaises(standard.StandardError):
|
||||
standard.validate(yaml.safe_dump(migration.canonical_caller('0.7.16', policy)), yaml.safe_dump(manifest), '0.7.16')
|
||||
|
||||
def test_unrecognized_feature_branch_filters_are_rejected(self):
|
||||
for branches in [{'only': ['/feature/.*/']}, {'only': ['main']}, {'ignore': '/.*/'}]:
|
||||
with self.subTest(branches=branches), self.assertRaises(ValueError):
|
||||
migration.publication_filters('feature', {'branches': branches, 'tags': {'only': ['/publish.*/']}})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,89 @@
|
||||
"""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()
|
||||
@@ -68,6 +68,30 @@ class RolloutTests(unittest.TestCase):
|
||||
self.assertFalse(rollout.rollout([root], '0.7.11', write=True)[0]['changed'])
|
||||
self.assertEqual(applied, self.contents(root))
|
||||
|
||||
def test_managed_patch_track_and_exact_pin_rollback_preserve_every_profile(self):
|
||||
roots = [self.checkout(profile, profile=profile, default_branch='main')
|
||||
for profile in rollout.standard.PROFILE_PARAMETERS]
|
||||
originals = [yaml.safe_load((root / '.qqq-ci.yml').read_text()) for root in roots]
|
||||
rollout.rollout(roots, '0.7', write=True)
|
||||
for root, original in zip(roots, originals):
|
||||
self.assertEqual({**original, 'orb_version': '0.7'},
|
||||
yaml.safe_load((root / '.qqq-ci.yml').read_text()))
|
||||
rollout.standard.validate(*(data.decode() for data in self.contents(root)), '0.7')
|
||||
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.7')
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.pipeline.load_manifest(root / '.qqq-ci.yml', '0.8')
|
||||
self.assertTrue(all(not r['changed'] for r in rollout.rollout(roots, '0.7', write=True)))
|
||||
rollout.rollout(roots, '0.7.4', write=True)
|
||||
for root, original in zip(roots, originals):
|
||||
self.assertEqual(original, yaml.safe_load((root / '.qqq-ci.yml').read_text()))
|
||||
|
||||
def test_unquoted_track_is_rejected_as_numeric_yaml(self):
|
||||
root = self.checkout('numeric')
|
||||
manifest = root / '.qqq-ci.yml'
|
||||
manifest.write_text(manifest.read_text().replace('0.7.4', '0.7'))
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.pipeline.load_manifest(manifest, '0.7')
|
||||
|
||||
def test_one_custom_caller_rejects_entire_batch_before_any_write(self):
|
||||
good = self.checkout('good')
|
||||
bad = self.checkout('bad')
|
||||
@@ -97,7 +121,7 @@ class RolloutTests(unittest.TestCase):
|
||||
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']:
|
||||
for version in ['latest', 'volatile', 'dev:test', '0', '0.7.*', '0.7.11\n']:
|
||||
with self.assertRaises(ValueError):
|
||||
rollout.rollout([root], version, write=True)
|
||||
with self.assertRaises(ValueError):
|
||||
|
||||
@@ -76,6 +76,24 @@ class MigrationTests(unittest.TestCase):
|
||||
manifest = migration.infer_manifest(self.config(), "0.7.0", "main")
|
||||
self.assertFalse(any(manifest["publish"].values()))
|
||||
|
||||
def test_managed_track_preserves_policy_and_caller_pins(self):
|
||||
fixtures = json.loads((Path(__file__).parent / "fixtures/qbit-publication-policies.json").read_text(encoding="utf-8"))
|
||||
for fixture in fixtures:
|
||||
with self.subTest(repository=fixture["name"]):
|
||||
expected = migration.infer_manifest(fixture["config"], "0.8.1", fixture["default_branch"])
|
||||
expected["orb_version"] = "0.8"
|
||||
actual = migration.infer_manifest(fixture["config"], "0.8", fixture["default_branch"])
|
||||
self.assertEqual(actual, expected)
|
||||
caller = migration.canonical_caller("0.8", actual["release_tag_policy"], actual["publish"].get("feature", False))
|
||||
self.assertEqual(caller["orbs"]["qqq-orb"], "kingsrook/qqq-orb@0.8")
|
||||
self.assertEqual(caller["workflows"]["setup"]["jobs"][0]["qqq-orb/generate_pipeline"]["orb_version"], "0.8")
|
||||
self.assertEqual(yaml.safe_load(yaml.safe_dump(actual))["orb_version"], "0.8")
|
||||
|
||||
def test_reject_ambiguous_or_invalid_versions(self):
|
||||
for version in (0.8, None, "0", "latest", "volatile", "0.8.*", "0.8.1.2", ""):
|
||||
with self.subTest(version=version), self.assertRaises(ValueError):
|
||||
migration.infer_manifest(self.config(), version, "main")
|
||||
|
||||
def test_snapshot_does_not_enable_rc_or_release(self):
|
||||
manifest = migration.infer_manifest(
|
||||
self.config("qqq-orb/mvn_publish", branch_type="snapshot",
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Maven failures must survive tee without overriding project analysis policy."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPTS = [('mvn_spotbugs.sh', 'SPOTBUGS_FAIL_ON_ERROR', 'spotbugs.failOnError'),
|
||||
('mvn_pmd.sh', 'PMD_FAIL_ON_VIOLATION', 'pmd.failOnViolation')]
|
||||
|
||||
|
||||
class StaticAnalysisExitTests(unittest.TestCase):
|
||||
def invoke(self, script, variable, setting, status):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
binary = root / 'mvn'
|
||||
binary.write_text('#!/bin/sh\nprintf "%s\\n" "$@" > "$ARGUMENT_FILE"\necho analysis-output\nexit "$FAKE_MAVEN_EXIT"\n')
|
||||
binary.chmod(0o755)
|
||||
env = dict(os.environ, PATH=str(root) + os.pathsep + os.environ['PATH'],
|
||||
ARGUMENT_FILE=str(root / 'arguments'), FAKE_MAVEN_EXIT=str(status))
|
||||
env.pop(variable, None)
|
||||
if setting is not None:
|
||||
env[variable] = setting
|
||||
result = subprocess.run(['bash', str(ROOT / 'src/scripts' / script)], cwd=root,
|
||||
env=env, text=True, capture_output=True, timeout=15)
|
||||
return result, (root / 'arguments').read_text().splitlines()
|
||||
|
||||
def test_maven_failure_is_never_hidden_by_successful_tee(self):
|
||||
for script, variable, _ in SCRIPTS:
|
||||
for setting in ('true', 'false'):
|
||||
with self.subTest(script=script, setting=setting):
|
||||
result, _ = self.invoke(script, variable, setting, 17)
|
||||
self.assertEqual(17, result.returncode)
|
||||
self.assertIn('analysis-output', result.stdout)
|
||||
|
||||
def test_success_preserves_explicit_flag_and_project_defaults(self):
|
||||
for script, variable, property_name in SCRIPTS:
|
||||
for setting in ('true', 'false', None):
|
||||
with self.subTest(script=script, setting=setting):
|
||||
result, arguments = self.invoke(script, variable, setting, 0)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
if setting == 'true':
|
||||
self.assertIn('-D' + property_name + '=true', arguments)
|
||||
else:
|
||||
self.assertFalse(any(arg.startswith('-D' + property_name + '=') for arg in arguments))
|
||||
self.assertIn('-DskipTests', arguments)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+62
-10
@@ -66,6 +66,38 @@ def gh(path):
|
||||
return json.loads(command(['gh', 'api', '--method', 'GET', path]))
|
||||
|
||||
|
||||
def discover_inventory(organization):
|
||||
"""Discover every repository visible to existing gh authentication, across all pages."""
|
||||
if not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9-]*', organization):
|
||||
raise ReadError('invalid organization name')
|
||||
pages = json.loads(command(['gh', 'api', '--method', 'GET', '--paginate', '--slurp',
|
||||
f'orgs/{organization}/repos?type=all&per_page=100']))
|
||||
if not isinstance(pages, list) or any(not isinstance(page, list) for page in pages):
|
||||
raise ReadError('invalid organization inventory response')
|
||||
entries, seen = [], set()
|
||||
for page in pages:
|
||||
for repo in page:
|
||||
if not isinstance(repo, dict):
|
||||
raise ReadError('invalid organization repository')
|
||||
name = repo.get('name')
|
||||
full_name = repo.get('full_name')
|
||||
archived = repo.get('archived')
|
||||
branch = repo.get('default_branch')
|
||||
if (not isinstance(name, str) or not re.fullmatch(r'[A-Za-z0-9_.-]+', name)
|
||||
or not isinstance(full_name, str)
|
||||
or full_name.lower() != f'{organization}/{name}'.lower()
|
||||
or type(archived) is not bool
|
||||
or not isinstance(branch, str) or not branch
|
||||
or full_name.lower() in seen):
|
||||
raise ReadError('invalid or duplicate organization repository')
|
||||
seen.add(full_name.lower())
|
||||
entries.append({'name': name, 'nameWithOwner': full_name,
|
||||
'isArchived': archived, 'defaultBranchRef': {'name': branch}})
|
||||
if not entries:
|
||||
raise ReadError('empty organization inventory; coverage is unproven')
|
||||
return sorted(entries, key=lambda entry: entry['nameWithOwner'].lower())
|
||||
|
||||
|
||||
class Snapshot:
|
||||
def __init__(self, entry, live=False):
|
||||
self.repo = entry['nameWithOwner']
|
||||
@@ -175,7 +207,7 @@ def owner_gate_errors(snapshot):
|
||||
|
||||
def audit(entry, snapshot, version, worker_sha, policy):
|
||||
name = entry['name']
|
||||
profile = policy.get('profile') or ('qbit' if name.startswith('qbit-') else PROFILES.get(name))
|
||||
profile = policy.get('branch_profiles', {}).get(snapshot.branch) or 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': {}}
|
||||
@@ -217,7 +249,7 @@ 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 == 'qbit' and (rc_enabled or existing_rc):
|
||||
if profile in ('qbit', 'repository-policy') and (rc_enabled or existing_rc):
|
||||
path = rc_worker.CALLER_PATH
|
||||
raw = rc_source
|
||||
rc_sha = policy.get("rc_worker_sha", worker_sha)
|
||||
@@ -235,13 +267,21 @@ def audit(entry, snapshot, version, worker_sha, policy):
|
||||
for kind, definition in auxiliary.BRIDGES.items():
|
||||
bridge_sha = worker_sha
|
||||
if kind == 'qbit-codeql':
|
||||
if profile != 'qbit' or 'codeql_worker_sha' not in policy:
|
||||
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']:
|
||||
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
|
||||
@@ -310,9 +350,11 @@ 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(branch not in ('main', 'develop') for branch in 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 len(set(managed)) != len(managed)):
|
||||
raise ReadError('managed_branches must be a nonempty unique main/develop list')
|
||||
raise ReadError('managed_branches must be a nonempty unique main/develop or numeric release/hotfix list')
|
||||
result['managed_branches'] = managed
|
||||
for branch in managed:
|
||||
if branch not in branches:
|
||||
@@ -364,22 +406,32 @@ def run(entries, version, worker_sha, policies, live=False, snapshot_factory=Sna
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--inventory', type=Path, required=True)
|
||||
inventory = parser.add_mutually_exclusive_group(required=True)
|
||||
inventory.add_argument('--inventory', type=Path)
|
||||
inventory.add_argument('--organization', help='Discover current repositories using existing gh authentication; requires --live')
|
||||
parser.add_argument('--orb-version', required=True)
|
||||
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('--expected-active', type=int, help='Optional independent coverage check; saved inventories default to 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'))
|
||||
if args.organization and not args.live:
|
||||
parser.error('--organization requires --live')
|
||||
entries = (discover_inventory(args.organization) if args.organization else
|
||||
json.loads(args.inventory.read_text(encoding='utf-8')))
|
||||
expected_active = args.expected_active
|
||||
if expected_active is None and not args.organization:
|
||||
expected_active = 68
|
||||
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['expected_active_count'] = args.expected_active
|
||||
report['coverage_matches_expected'] = (report['active_count'] == args.expected_active
|
||||
report['inventory_source'] = ('organization-api' if args.organization else 'saved-inventory')
|
||||
report['inventory_visibility'] = 'authenticated repositories; inaccessible repositories cannot be certified'
|
||||
report['expected_active_count'] = expected_active
|
||||
report['coverage_matches_expected'] = ((expected_active is None or report['active_count'] == expected_active)
|
||||
and report['unique_repository_count'] == report['inventory_count'])
|
||||
text = json.dumps(report, indent=2) + '\n'
|
||||
if args.output:
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Batch-enforce observed orb checks; dry-run unless --apply. Never changes source."""
|
||||
import argparse
|
||||
import base64
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
from urllib.parse import quote
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('standard', ROOT / 'src/scripts/validate_standard.py')
|
||||
standard = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(standard)
|
||||
DESIRED = [{'context': name, 'app_id': 18001} for name in ('setup', 'verify')]
|
||||
PROFILES = {'qbit', 'core', 'frontend-core', 'frontend-material'}
|
||||
|
||||
|
||||
def api(path, method='GET', payload=None):
|
||||
"""Use existing gh authentication; never expose response bodies on failure."""
|
||||
args = ['gh', 'api', '--method', method, path]
|
||||
if payload is not None:
|
||||
args += ['--input', '-']
|
||||
result = subprocess.run(args, input=None if payload is None else json.dumps(payload),
|
||||
text=True, encoding='utf-8', capture_output=True, timeout=60)
|
||||
if result.returncode:
|
||||
try:
|
||||
error = json.loads(result.stdout)
|
||||
except ValueError:
|
||||
error = {}
|
||||
if method == 'GET' and path.endswith('/protection') and error.get('status') == '404' and error.get('message') == 'Branch not protected':
|
||||
return None
|
||||
raise ValueError('GitHub operation unavailable: ' + method + ' ' + path.split('?')[0])
|
||||
return json.loads(result.stdout) if result.stdout.strip() else None
|
||||
|
||||
|
||||
def required_checks(before, runs):
|
||||
"""Append app-bound gates only after both succeeded; preserve all other gates."""
|
||||
for desired in DESIRED:
|
||||
matches = [run for run in runs if run['name'] == desired['context'] and run['app']['id'] == desired['app_id']]
|
||||
if not matches or max(matches, key=lambda run: run['id'])['conclusion'] != 'success':
|
||||
raise ValueError('Current branch head has no successful CircleCI ' + desired['context'])
|
||||
prior = (before or {}).get('required_status_checks') or {}
|
||||
checks = [dict(check) for check in prior.get('checks', [])]
|
||||
represented = {check['context'] for check in checks}
|
||||
checks += [{'context': name, 'app_id': -1} for name in prior.get('contexts', []) if name not in represented]
|
||||
for desired in DESIRED:
|
||||
matches = [check for check in checks if check['context'] == desired['context']]
|
||||
if any(check.get('app_id') not in (None, -1, desired['app_id']) for check in matches):
|
||||
raise ValueError('Existing gate uses a different app: ' + desired['context'])
|
||||
checks = [check for check in checks if check['context'] != desired['context']]
|
||||
checks.append(dict(desired))
|
||||
return {'strict': True, 'checks': checks}
|
||||
|
||||
|
||||
def inspect(repo, branch, version, request=api):
|
||||
"""Read immutable canonical source, latest check runs, and current protections."""
|
||||
if not re.fullmatch(r'[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', repo) or branch not in ('main', 'develop'):
|
||||
raise ValueError('Targets must name an exact repository and main/develop branch')
|
||||
root = 'repos/' + repo
|
||||
info = request(root)
|
||||
if info['archived']:
|
||||
raise ValueError('Archived repository')
|
||||
prefix = root + '/branches/' + branch
|
||||
head = request(prefix)['commit']['sha']
|
||||
source = []
|
||||
for path in ('.circleci/config.yml', '.qqq-ci.yml'):
|
||||
item = request(root + '/contents/' + quote(path, safe='/') + '?ref=' + head)
|
||||
if item.get('encoding') != 'base64' or item.get('type') != 'file':
|
||||
raise ValueError('Canonical declarations must be regular files')
|
||||
source.append(base64.b64decode(item['content'], validate=False).decode('utf-8'))
|
||||
standard.validate(*source, version)
|
||||
if standard.load_yaml(source[1])['profile'] not in PROFILES:
|
||||
raise ValueError('Profile does not use the shared setup/verify gate pair')
|
||||
rules = request(root + '/rules/branches/' + branch)
|
||||
if rules:
|
||||
raise ValueError('Ruleset-managed branch requires ruleset reconciliation')
|
||||
before = request(prefix + '/protection')
|
||||
runs = []
|
||||
page = 1
|
||||
while True:
|
||||
batch = request(root + '/commits/' + head + '/check-runs?filter=latest&per_page=100&page=' + str(page))['check_runs']
|
||||
runs += batch
|
||||
if len(batch) < 100:
|
||||
break
|
||||
page += 1
|
||||
desired = required_checks(before, runs)
|
||||
current = (before or {}).get('required_status_checks') or {}
|
||||
ready = (current.get('strict') is True and current.get('checks') == desired['checks']
|
||||
and (before or {}).get('enforce_admins', {}).get('enabled') is True)
|
||||
return {'repository': repo, 'branch': branch, 'head': head, 'before': before,
|
||||
'required_status_checks': desired, 'changed': not ready}
|
||||
|
||||
|
||||
def enforce(plan, request=api):
|
||||
"""Recheck drift, use narrow updates, and verify preservation of other settings."""
|
||||
root = 'repos/' + plan['repository']
|
||||
prefix = root + '/branches/' + plan['branch']
|
||||
if request(prefix)['commit']['sha'] != plan['head'] or request(prefix + '/protection') != plan['before']:
|
||||
raise ValueError('Branch or protection changed after preflight')
|
||||
if request(root + '/rules/branches/' + plan['branch']):
|
||||
raise ValueError('Ruleset changed after preflight')
|
||||
if not plan['changed']:
|
||||
return
|
||||
before = plan['before']
|
||||
if before is None:
|
||||
request(prefix + '/protection', 'PUT', {
|
||||
'required_status_checks': plan['required_status_checks'], 'enforce_admins': True,
|
||||
'required_pull_request_reviews': None, 'restrictions': None})
|
||||
else:
|
||||
request(prefix + '/protection/required_status_checks', 'PATCH', plan['required_status_checks'])
|
||||
if not before['enforce_admins']['enabled']:
|
||||
request(prefix + '/protection/enforce_admins', 'POST')
|
||||
after = request(prefix + '/protection')
|
||||
actual = after['required_status_checks']
|
||||
if not actual['strict'] or actual['checks'] != plan['required_status_checks']['checks'] or not after['enforce_admins']['enabled']:
|
||||
raise ValueError('Protection readback did not match requested gates')
|
||||
if before:
|
||||
for key, value in before.items():
|
||||
if key not in ('required_status_checks', 'enforce_admins') and after.get(key) != value:
|
||||
raise ValueError('Unrelated protection changed: ' + key)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--targets', type=Path, required=True, help='JSON list of {repository, branch}')
|
||||
parser.add_argument('--orb-version', required=True)
|
||||
parser.add_argument('--apply', action='store_true')
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
targets = json.loads(args.targets.read_text(encoding='utf-8'))
|
||||
if not isinstance(targets, list) or not targets:
|
||||
raise ValueError('A nonempty explicit target list is required')
|
||||
if len({(row['repository'], row['branch']) for row in targets}) != len(targets):
|
||||
raise ValueError('Duplicate branch target')
|
||||
# Resolve the entire batch before any mutations. Failures never trigger rollback
|
||||
# that would remove successful protections; rerunning converges idempotently.
|
||||
plans = [inspect(row['repository'], row['branch'], args.orb_version) for row in targets]
|
||||
args.output.write_text(json.dumps({'state': 'planned', 'plans': plans}, indent=2), encoding='utf-8')
|
||||
if args.apply:
|
||||
for plan in plans:
|
||||
enforce(plan)
|
||||
plan['verified'] = True
|
||||
args.output.write_text(json.dumps({'state': 'applying', 'plans': plans}, indent=2), encoding='utf-8')
|
||||
args.output.write_text(json.dumps({'state': 'verified', 'plans': plans}, indent=2), encoding='utf-8')
|
||||
print(json.dumps({'targets': len(plans), 'changed': sum(plan['changed'] for plan in plans), 'applied': args.apply}))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -56,8 +56,8 @@ def plan(checkout, version):
|
||||
|
||||
|
||||
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')
|
||||
if not re.fullmatch(r'\d+\.\d+(?:\.\d+)?', version):
|
||||
raise ValueError('Fleet upgrades require a stable minor track or exact patch 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):
|
||||
|
||||
@@ -11,7 +11,7 @@ import re
|
||||
import yaml
|
||||
|
||||
|
||||
def canonical_caller(version, release_tag_policy=None):
|
||||
def canonical_caller(version, release_tag_policy=None, publish_feature=False):
|
||||
caller = {
|
||||
"version": 2.1,
|
||||
"setup": True,
|
||||
@@ -28,6 +28,9 @@ def canonical_caller(version, release_tag_policy=None):
|
||||
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
|
||||
|
||||
|
||||
@@ -43,6 +46,12 @@ 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 not isinstance(branches, dict) or set(branches) != {"only"} or single_filter(branches["only"]) != expected or tags not in (None, {"only": []}):
|
||||
@@ -91,8 +100,8 @@ def test_filters(filters):
|
||||
|
||||
|
||||
def infer_manifest(config, version, default_branch):
|
||||
if not re.fullmatch(r"(?:\d+\.\d+\.\d+|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ValueError("An explicit published orb version is required")
|
||||
if not isinstance(version, str) or not re.fullmatch(r"(?:\d+\.\d+(?:\.\d+)?|dev:[A-Za-z0-9_-]+)", version):
|
||||
raise ValueError("A minor track, exact patch or explicit development orb version is required")
|
||||
if default_branch not in ("main", "develop"):
|
||||
raise ValueError("Unsupported default branch")
|
||||
if set(config) - {"version", "orbs", "commands", "workflows"}:
|
||||
@@ -123,7 +132,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"):
|
||||
if kind not in ("snapshot", "release_candidate", "release", "hotfix", "feature"):
|
||||
raise ValueError("Custom publication contract requires review")
|
||||
if kind in publications:
|
||||
raise ValueError("Duplicate publication jobs require review")
|
||||
@@ -148,6 +157,7 @@ def infer_manifest(config, version, default_branch):
|
||||
"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},
|
||||
}
|
||||
|
||||
@@ -165,7 +175,7 @@ def main():
|
||||
if manifest_path.exists():
|
||||
raise ValueError("Already has a manifest; use tools/rollout_version.py")
|
||||
manifest = infer_manifest(config, args.orb_version, args.default_branch)
|
||||
caller = canonical_caller(args.orb_version, manifest["release_tag_policy"])
|
||||
caller = canonical_caller(args.orb_version, manifest["release_tag_policy"], manifest["publish"].get("feature", False))
|
||||
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