From f9a314eebf93c6f00031846b5f22b776c9927caf Mon Sep 17 00:00:00 2001 From: sbp-bvanb Date: Fri, 20 Sep 2024 17:21:56 +0200 Subject: [PATCH] build(fix): [#69] Merge unit and integration test code coverage --- action.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/action.yml b/action.yml index deaa0ed..24df7b8 100644 --- a/action.yml +++ b/action.yml @@ -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: | @@ -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