Skip to content

Commit 2c66f55

Browse files
authored
Increased the code coverage gating threshold
1 parent 4487374 commit 2c66f55

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

.github/workflows/github-actions.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137

138138
- name: Install dependencies
139139
run: |
140-
go install github.com/t-yuki/gocover-cobertura@latest
140+
go install github.com/boumenot/gocover-cobertura@latest
141141
# ToDo: run tests in /cmd directory
142142
- name: Run the tests (not on Windows)
143143
run: |
@@ -152,10 +152,12 @@ jobs:
152152
"storage/external_test" # Test code, excluded from production
153153
"ontap/api/azgo" # Auto-generated code for ONTAP API (AZGO)
154154
"ontap/api/rest" # Auto-generated code for ONTAP REST API
155+
"astrads/api/v1alpha1" # Exclude deprecated AstraDS
155156
"fake" # Mock code for testing purposes
156157
"github.com/netapp/trident/mocks/" # Mock code for unit tests
157-
"github.com/netapp/trident/operator/controllers/provisioner" # Auto-generated operator code
158+
"github.com/netapp/trident/operator/controllers/provisioner" # Auto-generated operator code
158159
"github.com/netapp/trident/operator/controllers/provisioner/apis/netapp/v1" # Auto-generated API definitions
160+
"github.com/netapp/trident/storage_drivers/astrads/api/v1beta1" # Exclude deprecated AstraDS
159161
)
160162
161163
# Build regex pattern from exclusion list
@@ -164,13 +166,25 @@ jobs:
164166
# Run tests excluding the specified packages
165167
echo mkdir ${{ runner.temp }}/${{ runner.os }}-coverage-binary.out
166168
mkdir ${{ runner.temp }}/${{ runner.os }}-coverage-binary.out
167-
go test $(go list ./... | grep -v -E "$EXCLUDE_REGEX") -covermode=count -test.gocoverdir=${{ runner.temp }}/${{ runner.os }}-coverage-binary.out
168-
go tool covdata textfmt -i=${{ runner.temp }}/${{ runner.os }}-coverage-binary.out -o ${{ runner.os }}-coverage.out
169+
go test $(go list ./... | grep -Ev "$EXCLUDE_REGEX") -v -coverprofile=${{ runner.os }}-coverage.out
170+
grep -v "zz_generated.deepcopy.go" ${{ runner.os }}-coverage.out > ${{ runner.os }}-coverage_filtered.out
171+
172+
# Display coverage using go tool cover (same as Makefile)
173+
OVERALL_COVERAGE=$(go tool cover -func=${{ runner.os }}-coverage_filtered.out | grep total | awk '{print $3}')
174+
echo "Overall coverage (go tool cover): $OVERALL_COVERAGE"
169175
170176
- name: Convert Go coverage to Cobertura XML
171177
run: |
172-
gocover-cobertura < ${{ runner.os }}-coverage.out > cobertura-coverage.xml
173-
178+
# Use the more actively maintained gocover-cobertura fork with file exclusions
179+
# Exclude patterns: auto-generated files, mocks, test utilities
180+
gocover-cobertura \
181+
-ignore-files '.*zz_generated.*\.go$' \
182+
-ignore-files '.*\/fake\/.*\.go$' \
183+
-ignore-files '.*\/mocks\/.*\.go$' \
184+
-ignore-files '.*_test\.go$' \
185+
-ignore-files '.*\/testutils\/.*\.go$' \
186+
< ${{ runner.os }}-coverage_filtered.out > cobertura-coverage.xml
187+
174188
- name: Summarize code coverage
175189
uses: irongut/[email protected]
176190
with:
@@ -181,7 +195,7 @@ jobs:
181195
hide_complexity: true
182196
indicators: false
183197
output: both
184-
thresholds: '69 100'
198+
thresholds: '75 100'
185199

186200
- name: Add coverage PR comment
187201
uses: marocchino/sticky-pull-request-comment@v2
@@ -196,7 +210,7 @@ jobs:
196210
with:
197211
name: code-coverage
198212
path: |
199-
${{ runner.os }}-coverage.out
213+
${{ runner.os }}-coverage_filtered.out
200214
cobertura-coverage.xml
201215
code-coverage-results.md
202216
retention-days: 5

0 commit comments

Comments
 (0)