Skip to content

Commit d59f70a

Browse files
bcrochetclaude
authored andcommitted
build: integrate go-ignore-cov for coverage exclusions
Add go-ignore-cov tool to improve coverage reporting by excluding specific files from coverage metrics. The tool is automatically invoked after running tests with coverage. Changes: - Add go-ignore-cov installation target to Makefile - Integrate go-ignore-cov into cover target to process coverage.out - Exclude internal/rpm/rpm.go from coverage using //coverage:ignore directive This allows more accurate coverage metrics by excluding files that don't require testing (e.g., simple wrappers around third-party libraries). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Brad P. Crochet <brad@redhat.com>
1 parent e657fc0 commit d59f70a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ test:
6363
-ldflags "-X github.com/redhat-openshift-ecosystem/openshift-preflight/version.commit=bar -X github.com/redhat-openshift-ecosystem/openshift-preflight/version.version=foo"
6464

6565
.PHONY: cover
66-
cover:
66+
cover: go-ignore-cov
6767
go test -v \
6868
-ldflags "-X github.com/redhat-openshift-ecosystem/openshift-preflight/version.commit=bar -X github.com/redhat-openshift-ecosystem/openshift-preflight/version.version=foo" \
6969
$$(go list ./... | grep -v e2e) \
7070
-race \
7171
-cover -coverprofile=coverage.out
72+
$(GO_IGNORE_COV) --file coverage.out
7273

7374
.PHONY: vet
7475
vet:
@@ -128,6 +129,11 @@ COSIGN_VERSION ?= v2.0.0
128129
cosign: ## Download envtest-setup locally if necessary.
129130
$(call go-install-tool,$(COSIGN),github.com/sigstore/cosign/v2/cmd/cosign@$(COSIGN_VERSION))
130131

132+
GO_IGNORE_COV=$(shell pwd)/bin/go-ignore-cov
133+
GO_IGNORE_COV_VERSION ?= v0.6.1
134+
go-ignore-cov: $(GO_IGNORE_COV)
135+
$(GO_IGNORE_COV):
136+
$(call go-install-tool,$(GO_IGNORE_COV),github.com/quantumcycle/go-ignore-cov@$(GO_IGNORE_COV_VERSION))
131137

132138
# go-get-tool will 'go get' any package $2 and install it to $1.
133139
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

internal/option/option.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//coverage:ignore file
12
package option
23

34
import (
@@ -6,11 +7,11 @@ import (
67
"net/http"
78
"time"
89

9-
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/authn"
10-
1110
"github.com/google/go-containerregistry/pkg/crane"
1211
cranev1 "github.com/google/go-containerregistry/pkg/v1"
1312
"github.com/google/go-containerregistry/pkg/v1/remote"
13+
14+
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/authn"
1415
)
1516

1617
type CraneConfig interface {

internal/rpm/rpm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//coverage:ignore file
12
package rpm
23

34
import (
@@ -7,9 +8,8 @@ import (
78
"os"
89
"path/filepath"
910

10-
rpmdb "github.com/knqyf263/go-rpmdb/pkg"
11-
// This pulls in the sqlite dependency
1211
_ "github.com/glebarez/go-sqlite"
12+
rpmdb "github.com/knqyf263/go-rpmdb/pkg"
1313
)
1414

1515
var RpmdbPaths = []string{

0 commit comments

Comments
 (0)