Create codecov.yml to enforce 100% (#95)
Create codecov.yml to enforce 100%
This commit is contained in:
parent
c8d1f5f704
commit
144cab8174
3 changed files with 8 additions and 31 deletions
6
.codecov.yml
Normal file
6
.codecov.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: 100%
|
||||
threshold: 0%
|
||||
8
.github/workflows/go.yml
vendored
8
.github/workflows/go.yml
vendored
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue