Skip to content

Commit 513f699

Browse files
committed
ci: run tests properly
- integration_test.go should only run with -tags=integration - make: simplify "go test" call - make: rename "test-integration" task just "integration" - make: add "test" task to run all non-integration tests - make: add "help" task to identify/describe tasks on CLI
1 parent 23466b2 commit 513f699

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2323

2424
- name: Run tests
25-
run: make test-integration
25+
run: make test
2626

2727
- uses: codecov/codecov-action@v2
2828
with:

Makefile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
FILES_TO_FMT ?= $(shell find . -path ./vendor -prune -o -name '*.go' -print)
1+
FILES_TO_FMT ?= $(shell find . -path ./vendor -prune -o -name '*.go' -print)
2+
3+
.PHONY: help
4+
help: ## Print a short help message
5+
@grep -hE '^[a-zA-Z_-]+:[^:]*?## .*$$' $(MAKEFILE_LIST) | \
6+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-18s\033[0m %s\n", $$1, $$2}'
27

3-
## format: Formats Go code
48
.PHONY: format
5-
format:
9+
format: ## Formats all Go code
610
@echo ">> formatting code"
711
@gofmt -s -w $(FILES_TO_FMT)
812

9-
## test-integration: Run all Go integration tests
10-
.PHONY: test-integration
11-
test-integration:
12-
echo 'mode: atomic' > coverage.out
13-
go list ./... | xargs -I{} sh -c 'go test -race -tags=integration -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.out || exit 255'
14-
rm coverage.tmp
13+
.PHONY: lint
14+
lint: ## Runs golangci-lint on source files
15+
golangci-lint run
16+
17+
.PHONY: test
18+
test: ## Run all Go tests (excluding integration tests)
19+
go test -race -covermode=atomic -coverprofile=coverage.out ./...
20+
21+
.PHONY: integration
22+
integration: ## Run Go tests (integration tests only)
23+
go test -race -tags=integration -covermode=atomic -coverprofile=coverage.out ./...

integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !integration
2-
// +build !integration
1+
//go:build integration
2+
// +build integration
33

44
package at
55

0 commit comments

Comments
 (0)