Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
RyaWcksn committed Oct 20, 2023
1 parent d83acc4 commit ef404e3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ jobs:
token: ${{secrets.CODECOV_TOKEN}}
file: ./cov.txt
fail_ci_if_error: false

- name: Run tests and calculate coverage
run: |
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out > coverage.txt
shell: bash

- name: Check coverage
run: ./check_coverage.sh
shell: bash



- name: Release
run: npx semantic-release
Expand Down
16 changes: 16 additions & 0 deletions check_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Check if coverage.out file exists
if [ ! -f "coverage.out" ]; then
echo "coverage.out file not found."
exit 1
fi

# Calculate test coverage percentage
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')

# Check if coverage is less than 50%
if (( $(echo "$coverage < 50" | bc -l) )); then
echo "Error: Coverage is less than 50%: $coverage%"
exit 1
fi

0 comments on commit ef404e3

Please sign in to comment.