Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ '1.20', '1.21' ]
name: Go ${{ matrix.version }}
name: Go test
outputs:
pr_number: ${{ github.event.number }}
steps:
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.version }}
- uses: actions/checkout@v2
go-version: '1.21.4'
- uses: actions/checkout@v4
- run: make test
call-dependabot-pr-workflow:
needs: test
Expand Down
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,45 @@

.DEFAULT_GOAL = help

GO-VERSION = 1.21.4
GO-VER = go$(GO-VERSION)

GO=go
GOFMT=gofmt

.PHONY: help

help: ## list Makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

###### Targets ################################################################

test: version download fmt vet ginkgo ## Runs all build, static analysis, and test steps
test: deps-go-binary download fmt vet ginkgo ## Runs all build, static analysis, and test steps

download: ## Download dependencies
go mod download
${GO} mod download

vet: ## Run static code analysis
go vet ./...
go run honnef.co/go/tools/cmd/staticcheck ./...
${GO} vet ./...
${GO} run honnef.co/go/tools/cmd/staticcheck ./...

ginkgo: ## Run tests using Ginkgo
go run github.com/onsi/ginkgo/v2/ginkgo -r
${GO} run github.com/onsi/ginkgo/v2/ginkgo -r

fmt: ## Checks that the code is formatted correctly
@@if [ -n "$$(gofmt -s -e -l -d .)" ]; then \
@@if [ -n "$$(${GOFMT} -s -e -l -d .)" ]; then \
echo "gofmt check failed: run 'gofmt -d -e -l -w .'"; \
exit 1; \
fi

generate: ## Generates the fakes using counterfeiter
go generate ./...

version: ## Display the version of Go
@@go version
${GO} generate ./...

.PHONY: deps-go-binary
deps-go-binary:
ifeq ($(SKIP_GO_VERSION_CHECK),)
@@if [ "$$($(GO) version | awk '{print $$3}')" != "${GO-VER}" ]; then \
echo "Go version does not match: expected: ${GO-VER}, got $$($(GO) version | awk '{print $$3}')"; \
exit 1; \
fi
endif