Skip to content

Commit

Permalink
feat: [#63] Enforce a minimum code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbp-bvanb committed Aug 30, 2024
1 parent 2f63fc2 commit db554be
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: mcvs-golang-action
description: |
The Mission Critical Vulnerability Scanner (MCVS) Golang action.
inputs:
code_coverage_expected:
description: |
The minimum code coverage.
default: "80"
golang-unit-tests-exclusions:
description: |
The Golang paths that should be excluded from unit testing.
Expand Down Expand Up @@ -91,6 +95,18 @@ runs:
#
# Unit tests.
#
- name: code coverage
shell: bash
run: |
go test -v -coverpkg=./... -coverprofile=profile.cov ./...
code_coverage_actual=$(go tool cover -func profile.cov |\
grep total: |\
awk '{print $3}' |\
sed 's/%//')
if (( $(echo "${code_coverage_actual} > ${{ inputs.code_coverage_expected }}" | bc -l) )); then
echo "The actual code coverage: '${code_coverage_actual}' is too low. Expected: '${{ inputs.code_coverage_expected }}'"
exit 1
fi
- name: unit tests
shell: bash
run: |
Expand Down

0 comments on commit db554be

Please sign in to comment.