Skip to content

Commit 0548155

Browse files
varungup90ModiCodeCraftsman
authored andcommitted
Add race condition check in unit-test CI and add test-coverage cmd in Makefile (vllm-project#1169)
Signed-off-by: Varun Gupta <[email protected]> Signed-off-by: Modi Tamam <[email protected]>
1 parent c7b4648 commit 0548155

File tree

7 files changed

+34
-5
lines changed

7 files changed

+34
-5
lines changed

.github/.testcoverage.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ profile: cover.out
1111
threshold:
1212
# (optional; default 0)
1313
# Minimum coverage percentage required for individual files.
14-
file: 90
14+
file: 0
1515

1616
# (optional; default 0)
1717
# Minimum coverage percentage required for each package.
18-
package: 90
18+
package: 0
1919

2020
# (optional; default 0)
2121
# Minimum overall project coverage percentage required.
22-
total: 90
22+
total: 25
2323

2424
# # Holds regexp rules which will override thresholds for matched files or packages
2525
# # using their paths.
@@ -38,9 +38,16 @@ threshold:
3838
exclude:
3939
# Exclude files or packages matching their paths
4040
paths:
41-
- \.pb\.go$ # excludes all protobuf generated files
42-
- ^pkg/client # exclude package `pkg/client`
41+
- \.pb\.go$ # excludes all protobuf generated files
42+
- ^api/ # exclude package `api/`
43+
- ^cmd/ # exclude package `cmd/`
44+
- ^pkg/cert # exclude package `pkg/cert`
45+
- ^pkg/client # exclude package `pkg/client`
46+
- ^pkg/config # exclude package `pkg/config`
47+
- ^pkg/constants # exclude package `pkg/constants`
48+
- ^pkg/features # exclude package `pkg/features`
4349
- ^pkg/webhook # exclude package `pkg/webhook`
50+
- ^test # exclude package `test/`
4451

4552
# File name of go-test-coverage breakdown file, which can be used to
4653
# analyze coverage difference.

.github/workflows/lint-and-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ jobs:
8989
path: cover.out
9090
if-no-files-found: error
9191
retention-days: 1
92+
93+
- name: Run Race Condition Tests
94+
run: make test-race-condition
9295

9396
- name: Run Integration Tests
9497
run: make test-integration

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ vet: ## Run go vet against code.
9090
test: manifests generate fmt vet envtest ## Run tests.
9191
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
9292

93+
.PHONY: test-code-coverage
94+
test-code-coverage: test
95+
$(GO_TEST_COVERAGE) --config=./.github/.testcoverage.yml
96+
9397
.PHONY: test-race-condition
9498
test-race-condition: manifests generate fmt vet envtest ## Run tests with race detection enabled.
9599
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race $$(go list ./... | grep -v /e2e)
@@ -295,12 +299,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
295299
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
296300
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
297301
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
302+
GO_TEST_COVERAGE = $(LOCALBIN)/go-test-coverage-$(GO_TEST_COVERAGE_VERSION)
298303

299304
## Tool Versions
300305
KUSTOMIZE_VERSION ?= v5.3.0
301306
CONTROLLER_TOOLS_VERSION ?= v0.16.1
302307
ENVTEST_VERSION ?= release-0.17
303308
GOLANGCI_LINT_VERSION ?= v1.57.2
309+
GO_TEST_COVERAGE_VERSION ?= v2.14.3
304310

305311
.PHONY: kustomize
306312
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -322,6 +328,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
322328
$(GOLANGCI_LINT): $(LOCALBIN)
323329
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
324330

331+
.PHONY: go-test-coverage
332+
go-test-coverage: $(GO_TEST_COVERAGE) ## Download go-test-coverage locally if necessary.
333+
$(GO_TEST_COVERAGE): $(LOCALBIN)
334+
$(call go-install-tool,$(GO_TEST_COVERAGE),github.com/vladopajic/go-test-coverage/v2,${GO_TEST_COVERAGE_VERSION})
335+
325336
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
326337
# $1 - target path with name of binary (ideally with version)
327338
# $2 - package url which can be installed

pkg/cache/trace_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !race
2+
13
/*
24
Copyright 2024 The Aibrix Team.
35

pkg/types/types_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !race
2+
13
/*
24
Copyright 2024 The Aibrix Team.
35

pkg/utils/prefixcacheindexer/tree_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !race
2+
13
/*
24
Copyright 2024 The Aibrix Team.
35

pkg/utils/utils_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !race
2+
13
/*
24
Copyright 2024 The Aibrix Team.
35

0 commit comments

Comments
 (0)