Create codecov.yml to enforce 100% (#95)

Create codecov.yml to enforce 100%
This commit is contained in:
Onur Cinar 2023-06-22 15:38:18 -07:00 committed by GitHub
commit 144cab8174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 31 deletions

6
.codecov.yml Normal file
View file

@ -0,0 +1,6 @@
coverage:
status:
project:
default:
target: 100%
threshold: 0%

View file

@ -39,14 +39,10 @@ jobs:
run: go build -v ./...
- name: Go test
run: go test -v -coverprofile=coverage.out ./...
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Go coverage
env:
CODE_COVERAGE_THRESHOLD: 100
run: ./scripts/coverage.sh

View file

@ -1,25 +0,0 @@
#!/bin/bash
COVERAGE_FILE=coverage.out
if [ -z "$CODE_COVERAGE_THRESHOLD" ]
then
echo "No code coverage threshold is set."
exit 0
fi
echo "Code coverage threshold ${CODE_COVERAGE_THRESHOLD}%"
if [ ! -e "$COVERAGE_FILE" ]
then
echo "Coverage file ${COVERAGE_FILE} is not found."
exit 1
fi
CODE_COVERAGE=$(go tool cover -func=coverage.out | grep "total:" | grep -E -o '[0-9]+\.[0-9]+')
if awk "BEGIN { exit !($CODE_COVERAGE < $CODE_COVERAGE_THRESHOLD)}"
then
echo "Current code coverage ${CODE_COVERAGE}% is below the ${CODE_COVERAGE_THRESHOLD}% threshold."
exit 1
fi