hololake-system-architecture/product-source/hololake-platform/guanghu-os/scripts/test-guanghu-native-quality-gate-contract.sh

32 lines
1.3 KiB
Shell
Executable file

#!/usr/bin/env bash
set -euo pipefail
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
protocol=${source_root}/world-seed/world/services/code-channel/QUALITY-GATE.hldp
runner=${source_root}/world-seed/scripts/run-guanghu-native-quality-gate.sh
grep -Fxq 'schema: guanghu.native-code-quality-gate/v1' "${protocol}"
grep -Fxq 'id: GLS-0844' "${protocol}"
grep -Fxq 'acronym: GHNQG' "${protocol}"
grep -Fxq ' allowed_scores:' "${protocol}"
grep -Fxq ' - 0' "${protocol}"
grep -Fxq ' - 100' "${protocol}"
grep -Fxq ' pass_score: 100' "${protocol}"
grep -Fxq ' partial_acceptance: false' "${protocol}"
grep -Fxq ' aggregate_rule: ALL_REQUIRED_GATES_100_OR_TOTAL_0' "${protocol}"
grep -Fxq ' external_observers_are_blocking: false' "${protocol}"
grep -Fxq ' required_score: 100' "${protocol}"
grep -Fxq ' native_target: GOSK_CODE_CHANNEL_QUALITY_EXECUTOR' "${protocol}"
grep -Fq -- '--fail-under-lines 100' "${runner}"
grep -Fq -- '--fail-under-functions 100' "${runner}"
grep -Fq -- '--test broadcast_library' "${runner}"
grep -Fq 'GHNQG_PASS_100' "${runner}"
grep -Fq 'GHNQG_FAIL_0' "${runner}"
grep -Fq 'total_score: ${total_score}' "${runner}"
if grep -Eiq 'codescene|codacy' "${runner}"; then
echo "external analysis product leaked into the Guanghu native quality executor" >&2
exit 1
fi
echo "GUANGHU_NATIVE_QUALITY_GATE_CONTRACT_OK"