musichoard/.gitea/scripts/coverage.py
Wojciech Kozlowski d7384476d4
All checks were successful
Cargo CI / Build and Test (push) Successful in 58s
Cargo CI / Lint (push) Successful in 42s
Cargo CI / Build and Test (pull_request) Successful in 1m0s
Cargo CI / Lint (pull_request) Successful in 42s
Add a code coverage check to the CI pipeline (#84)
Closes #83

Reviewed-on: #84
2024-01-06 19:49:41 +01:00

24 lines
751 B
Python

import argparse
import json
def main(coverage_file, fail_under):
with open(coverage_file, encoding="utf-8") as f:
coverage_json = json.load(f)
coverage = float(coverage_json["message"][:-1])
return coverage >= fail_under
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check coverage output by grcov")
parser.add_argument("--coverage-file", type=str, required=True,
help="Path to the coverage.json file output by grcov")
parser.add_argument("--fail-under", type=float, default=100.,
help="Threshold under which coverage is insufficient")
args = parser.parse_args()
if not main(args.coverage_file, args.fail_under):
exit(2)