forked from cleveragents/cleveragents-core
40 lines
1011 B
YAML
40 lines
1011 B
YAML
# Example: Required validation (standalone)
|
|
# A custom validation that checks test coverage meets a threshold.
|
|
|
|
name: qa/coverage-check
|
|
description: Verify test coverage meets the required threshold
|
|
source: custom
|
|
mode: required
|
|
code: |
|
|
import json
|
|
report = json.loads(inputs["coverage_json"])
|
|
total = report.get("totals", {}).get("percent_covered", 0)
|
|
passed = total >= inputs.get("threshold", 80)
|
|
return {
|
|
"passed": passed,
|
|
"data": {"coverage_percent": total},
|
|
"message": f"Coverage {total}% {'meets' if passed else 'below'} threshold"
|
|
}
|
|
|
|
input_schema:
|
|
type: object
|
|
required:
|
|
- coverage_json
|
|
properties:
|
|
coverage_json:
|
|
type: string
|
|
description: JSON string of the coverage report
|
|
threshold:
|
|
type: number
|
|
description: Minimum coverage percentage required
|
|
default: 80
|
|
|
|
resource_slots:
|
|
- name: project_repo
|
|
resource_type: git-checkout
|
|
access: read_only
|
|
description: Repository under test
|
|
binding: contextual
|
|
|
|
timeout: 120
|