diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0f8fcb33..c5414868 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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 diff --git a/Makefile b/Makefile index de2670d0..295f7f8e 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,12 @@ .DEFAULT_GOAL = help +GO-VERSION = 1.21.4 +GO-VER = go$(GO-VERSION) + +GO=go +GOFMT=gofmt + .PHONY: help help: ## list Makefile targets @@ -9,26 +15,32 @@ help: ## list Makefile targets ###### 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