-
Notifications
You must be signed in to change notification settings - Fork 1
ci: de-duplicate invariant gates across the test matrix #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
codeforester
wants to merge
2
commits into
main
Choose a base branch
from
ci/312-20260918-deduplicate-invariant-gates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+182
−99
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,134 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Authoritative local validation entry point for the Base manifest. | ||
| # Composable validation gates. The default command remains the authoritative | ||
| # local aggregate; CI selects only the gate groups appropriate to each job. | ||
| set -euo pipefail | ||
|
|
||
| required_commands=(python ruff mypy bandit pip-audit) | ||
| for command in "${required_commands[@]}"; do | ||
| command -v "$command" >/dev/null 2>&1 || { | ||
| printf 'Missing validation tool: %s. Install the dev and quality extras first.\n' "$command" >&2 | ||
| exit 1 | ||
| } | ||
| done | ||
|
|
||
| ./tests/validate.sh | ||
| python -m pytest --cov=base_cli --cov-report=term-missing --cov-report=json:coverage.json --cov-fail-under=80 | ||
| python -m mypy --strict examples/typed_consumer.py | ||
| python -m mypy --strict lib/python/base_cli | ||
| ruff format --check lib/python/base_cli scripts examples tests | ||
| ruff check lib/python/base_cli scripts examples tests | ||
| python scripts/validate_docs.py | ||
| python scripts/validate_changelog.py | ||
| python scripts/validate_schemas.py | ||
| python scripts/validate_contract_fixtures.py | ||
| if command -v node >/dev/null 2>&1; then | ||
| node scripts/validate_contract_fixtures.mjs | ||
| gate="all" | ||
| node_contracts_missing=0 | ||
| if [[ $# -gt 0 ]]; then | ||
| if [[ $# -ne 2 || "$1" != "--gate" ]]; then | ||
| printf 'Usage: %s [--gate baseline|runtime|coverage|typing|style|contracts|benchmark|security]\n' "$0" >&2 | ||
| exit 2 | ||
| fi | ||
| gate="$2" | ||
| fi | ||
| python scripts/generate_compatibility_dashboard.py --check | ||
| python scripts/benchmark_runtime.py --check | ||
| python -m compileall -q examples | ||
| python scripts/validate_coverage.py coverage.json | ||
|
|
||
| bandit -q -r lib/python/base_cli scripts -lll -iii | ||
|
|
||
| # Audit the resolved third-party environment without asking pip-audit to | ||
| # resolve the unpublished editable checkout itself. `sed` keeps this safe | ||
| # under `set -o pipefail` even when the environment contains no other package. | ||
| audit_requirements="$(mktemp)" | ||
| trap 'rm -f "$audit_requirements"' EXIT | ||
| python -m pip freeze \ | ||
| | sed -E '/(^-e .*#egg=base[_-]cli|^base[_-]cli([[:space:]=@]|$))/Id' \ | ||
| > "$audit_requirements" | ||
| pip-audit --strict -r "$audit_requirements" | ||
|
|
||
| validation_result="${BASE_CLI_VALIDATION_RESULT:-${TMPDIR:-/tmp}/base-cli-validation-result.json}" | ||
| if command -v node >/dev/null 2>&1; then | ||
|
|
||
| require_commands() { | ||
| local command | ||
| for command in "$@"; do | ||
| command -v "$command" >/dev/null 2>&1 || { | ||
| printf 'Missing validation tool: %s. Install the required development extras first.\n' "$command" >&2 | ||
| exit 1 | ||
| } | ||
| done | ||
| } | ||
|
|
||
| run_baseline() { | ||
| bash ./tests/validate.sh | ||
| } | ||
|
|
||
| run_runtime() { | ||
| require_commands python | ||
| python -m pytest | ||
| } | ||
|
|
||
| run_coverage() { | ||
| require_commands python | ||
| python -m pytest --cov=base_cli --cov-report=term-missing --cov-report=json:coverage.json --cov-fail-under=80 | ||
| python scripts/validate_coverage.py coverage.json | ||
| } | ||
|
|
||
| run_typing() { | ||
| require_commands python mypy | ||
| python -m mypy --strict examples/typed_consumer.py | ||
| python -m mypy --strict lib/python/base_cli | ||
| } | ||
|
|
||
| run_style() { | ||
| require_commands ruff | ||
| ruff format --check lib/python/base_cli scripts examples tests | ||
| ruff check lib/python/base_cli scripts examples tests | ||
| } | ||
|
|
||
| run_contracts() { | ||
| require_commands python | ||
| python scripts/validate_docs.py | ||
| python scripts/validate_changelog.py | ||
| python scripts/validate_schemas.py | ||
| python scripts/validate_contract_fixtures.py | ||
| if command -v node >/dev/null 2>&1; then | ||
| node scripts/validate_contract_fixtures.mjs | ||
| else | ||
| node_contracts_missing=1 | ||
| printf 'Node.js is unavailable; the cross-language contract gate is incomplete.\n' >&2 | ||
| fi | ||
| python scripts/generate_compatibility_dashboard.py --check | ||
| python -m compileall -q examples | ||
| if ((node_contracts_missing)) && [[ "$gate" != "all" ]]; then | ||
| printf 'Install Node.js to complete the cross-language contract gate.\n' >&2 | ||
| return 2 | ||
| fi | ||
| } | ||
|
|
||
| run_benchmark() { | ||
| require_commands python | ||
| python scripts/benchmark_runtime.py --check | ||
| } | ||
|
|
||
| run_security() { | ||
| require_commands bandit pip-audit python | ||
| bandit -q -r lib/python/base_cli scripts -lll -iii | ||
|
|
||
| # Audit third-party packages without asking pip-audit to resolve the | ||
| # unpublished editable checkout itself. | ||
| local audit_requirements | ||
| audit_requirements="$(mktemp)" | ||
| # Keep the path in a global shell variable so the EXIT trap still sees it | ||
| # when errexit terminates the script from inside this function. | ||
| SECURITY_AUDIT_REQUIREMENTS="$audit_requirements" | ||
| cleanup_security_audit() { rm -f -- "$SECURITY_AUDIT_REQUIREMENTS"; } | ||
| trap cleanup_security_audit EXIT | ||
| python -m pip freeze \ | ||
| | sed -E '/(^-e .*#egg=base[_-]cli|^base[_-]cli([[:space:]=@]|$))/Id' \ | ||
| > "$audit_requirements" | ||
| pip-audit --strict -r "$audit_requirements" | ||
| } | ||
|
|
||
| write_validation_result() { | ||
| local validation_result | ||
| validation_result="${BASE_CLI_VALIDATION_RESULT:-${TMPDIR:-/tmp}/base-cli-validation-result.json}" | ||
| if ((node_contracts_missing)); then | ||
| printf '%s\n' '{"status":"partial","skipped":["node contract validator"]}' > "$validation_result" | ||
| printf 'Validation result: partial; Node.js contract validation was skipped (%s).\n' "$validation_result" | ||
| return 2 | ||
| fi | ||
| printf '%s\n' '{"status":"full","skipped":[]}' > "$validation_result" | ||
| printf 'Validation result: full (%s)\n' "$validation_result" | ||
| else | ||
| printf '%s\n' '{"status":"partial","skipped":["node contract validator"]}' > "$validation_result" | ||
| printf 'Validation result: partial; Node.js contract validation was skipped (%s).\n' "$validation_result" | ||
| printf 'This result is non-authoritative; install Node.js for the full gate.\n' | ||
| exit 2 | ||
| fi | ||
| } | ||
|
|
||
| printf 'Full base-cli validation passed.\n' | ||
| case "$gate" in | ||
| baseline) run_baseline ;; | ||
| runtime) run_runtime ;; | ||
| coverage) run_coverage ;; | ||
| typing) run_typing ;; | ||
| style) run_style ;; | ||
| contracts) run_contracts ;; | ||
| benchmark) run_benchmark ;; | ||
| security) run_security ;; | ||
| all) | ||
| run_baseline | ||
| run_coverage | ||
| run_typing | ||
| run_style | ||
| run_contracts | ||
| run_benchmark | ||
| run_security | ||
| write_validation_result | ||
| printf 'Full base-cli validation passed.\n' | ||
| ;; | ||
| *) | ||
| printf 'Unknown validation gate: %s\n' "$gate" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed behavior: dropped user-facing guidance on the partial-result path
The pre-refactor script's node-missing branch printed three lines, the last of which was:
printf 'This result is non-authoritative; install Node.js for the full gate.\n'write_validation_result()keeps the JSON-status line and the 'Validation result: partial…' line but drops this one. A developer running./tests/full_validate.sh(no args) on a machine without Node.js now sees the partial-result line and a bareexit 2, without the explicit remediation hint that used to accompany it. Low severity, but it's a real message loss with no equivalent added elsewhere — worth restoring the printf so the "how do I fix this" hint survives the refactor.