Skip to content

Commit

Permalink
ci: Coverage gate? 👷
Browse files Browse the repository at this point in the history
  • Loading branch information
guisea committed Jul 31, 2024
1 parent 520c8e1 commit 0e32a2c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ jobs:
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest

# Run tests with nice formatting. Save the original log in /tmp/gotest.log
- name: Run tests
- name: Run tests and Check Coverage
run: |
set -euo pipefail
go test -json -race -covermode=atomic -coverprofile=coverage.out ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
COVERAGE=$(cat /tmp/gotest.log | sed -nr "s/.*coverage:.([0-9.]+).*/\1/p" | uniq)
echo "COVERAGE=${COVERAGE}" >> $GITHUB_ENV
echo "Coverage is: ${COVERAGE}%"
- name: Check coverage tolerance
if: ${{ env.COVERAGE < 80 }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Coverage test below tolerance')
- name: Update coverage badge
uses: cybercinch/dynamic-badges-action@master
Expand Down

0 comments on commit 0e32a2c

Please sign in to comment.