Skip to content

Commit

Permalink
Update CI and Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed May 2, 2024
1 parent c3756d1 commit 9904dc2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.19.x
GO_VERSION: stable
jobs:
gorelease:
runs-on: ubuntu-latest
steps:
- name: Install Go stable
if: env.GO_VERSION != 'tip'
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: stable
- name: Checkout code
uses: actions/checkout@v4
- name: Build artifacts
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
go-version: [ 1.16.x, 1.17.x, 1.19.x, 1.20.x, 1.21.x ] # Lowest supported and current stable versions.
go-version: [ 1.16.x, 1.17.x, oldstable, stable ] # Lowest supported and current stable versions.
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand All @@ -29,10 +29,10 @@ jobs:
- name: Run gofmt
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
- name: Run staticcheck
if: matrix.go-version == '1.20.x'
if: matrix.go-version == 'stable'
uses: dominikh/[email protected]
with:
version: "2023.1.3"
version: "latest"
install-go: false
cache-key: ${{ matrix.go }}

Expand All @@ -49,7 +49,7 @@ jobs:
go install ./cmd/godog
godog -f progress --strict
- name: Report on code coverage
if: matrix.go-version == '1.17.x'
if: matrix.go-version == 'stable'
uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

VERS ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)

FOUND_GO_VERSION := $(shell go version)
EXPECTED_GO_VERSION = 1.17
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 16
GO_VERSION_VALIDATION_ERR_MSG = Go version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)

.PHONY: check-go-version
check-go-version:
@$(if $(findstring ${EXPECTED_GO_VERSION}, ${FOUND_GO_VERSION}),(exit 0),(echo Wrong go version! Please install ${EXPECTED_GO_VERSION}; exit 1))
@if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
exit 0 ;\
elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi

test: check-go-version
@echo "running all tests"
@go install ./...
@go fmt ./...
@go run honnef.co/go/tools/cmd/staticcheck@v0.2.2 github.com/cucumber/godog
@go run honnef.co/go/tools/cmd/staticcheck@v0.2.2 github.com/cucumber/godog/cmd/godog
@go run honnef.co/go/tools/cmd/staticcheck@v0.4.7 github.com/cucumber/godog
@go run honnef.co/go/tools/cmd/staticcheck@v0.4.7 github.com/cucumber/godog/cmd/godog
go vet ./...
go test -race ./...
godog -f progress -c 4
go run ./cmd/godog -f progress -c 4

gherkin:
@if [ -z "$(VERS)" ]; then echo "Provide gherkin version like: 'VERS=commit-hash'"; exit 1; fi
Expand Down

0 comments on commit 9904dc2

Please sign in to comment.