Skip to content

Commit

Permalink
build(fix): [#69] Merge unit and integration test code coverage (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbp-bvanb authored Sep 23, 2024
1 parent ac7c23e commit e10746d
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ 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 "${{ inputs.code_coverage_expected }} > ${code_coverage_actual}" | 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 All @@ -117,18 +105,25 @@ runs:
-v \
$(go list ./... | grep -v '${{ inputs.golang-unit-tests-exclusions }}')
#
# Both unit and integration tests including code coverage.
# Unit & integration tests including code coverage.
#
- name: unit & integrations tests and code coverage
shell: bash
run: |
go test \
--tags=integration \
-cover \
-covermode=atomic \
-coverprofile=coverage.txt \
-coverpkg=./... \
-coverprofile=profile.cov \
-p ${{ inputs.golang-number-of-tests-in-parallel }} \
-race \
-short \
--tags=integration \
-v \
$(go list ./... | grep -v '${{ inputs.golang-unit-tests-exclusions }}')
code_coverage_actual=$(go tool cover -func profile.cov |\
grep total: |\
awk '{print $3}' |\
sed 's/%//')
if (( $(echo "${{ inputs.code_coverage_expected }} > ${code_coverage_actual}" | bc -l) )); then
echo "The actual code coverage: '${code_coverage_actual}' is too low. Expected: '${{ inputs.code_coverage_expected }}'."
exit 1
fi

0 comments on commit e10746d

Please sign in to comment.