Skip to content

Commit

Permalink
chore(ci): general ci and tooling improvement (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvrach authored May 30, 2024
1 parent d823765 commit 1b83f9a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 32 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ updates:
- "go.opentelemetry.io/collector*"
- "github.com/open-telemetry/o*-collector-contrib/*"
- "go.opentelemetry.io/contrib/instrumentation/*"
frequent:
patterns:
- "github.com/aws/aws-sdk-go"
- "google.golang.org/api"
- "cloud.google.com/go/*"
all:
patterns:
- "*"
update-types:
- "minor"
- "patch"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
8 changes: 2 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: '~1.21.0'
check-latest: true
cache: true

go-version-file: 'go.mod'
- run: go version
- run: go mod download # Not required, used to segregate module download vs test times
- run: make test exclude="(kafkaclient|testhelper)"
Expand All @@ -38,8 +35,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '~1.21'
check-latest: true
go-version-file: 'go.mod'
- run: go version
- run: go mod download
- name: Test package [ ${{ matrix.package }} ]
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
check-latest: true
cache: true
go-version: '~1.21.0'
go-version-file: 'go.mod'
- run: go version

- run: go mod tidy
Expand All @@ -47,10 +45,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.21.0'
check-latest: true
cache: true
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
version: v1.57.1
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-file: 'go.mod'
go-package: ./...
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
run:
timeout: 5m
go: '1.21'

linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
Expand All @@ -14,7 +12,6 @@ linters:
- unused
- unparam
- unconvert
- varcheck
- bodyclose
- decorder
- makezero
Expand Down
26 changes: 18 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ GO=go
LDFLAGS?=-s -w
TESTFILE=_testok

# go tools versions
GOLANGCI=github.com/golangci/golangci-lint/cmd/[email protected]
gofumpt=mvdan.cc/gofumpt@latest
govulncheck=golang.org/x/vuln/cmd/govulncheck@latest
goimports=golang.org/x/tools/cmd/goimports@latest
mockgen=github.com/golang/mock/[email protected]
gotestsum=gotest.tools/[email protected]
protoc-gen-go=google.golang.org/protobuf/cmd/[email protected]
protoc-gen-go-grpc=google.golang.org/grpc/cmd/[email protected]

default: lint

generate: install-tools
Expand Down Expand Up @@ -54,17 +64,17 @@ help: ## Show the available commands
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

install-tools:
go install github.com/golang/mock/[email protected]
go install mvdan.cc/gofumpt@latest
go install gotest.tools/[email protected]
go install golang.org/x/tools/cmd/goimports@latest
bash ./internal/scripts/install-golangci-lint.sh v1.55.2
$(GO) install $(gotestsum)
$(GO) install $(mockgen)
$(GO) install $(protoc-gen-go)
$(GO) install $(protoc-gen-go-grpc)

.PHONY: lint
lint: fmt ## Run linters on all go files
golangci-lint run -v --timeout 5m
$(GO) run $(GOLANGCI) run -v

.PHONY: fmt
fmt: install-tools ## Formats all go files
gofumpt -l -w -extra .
find . -type f -name '*.go' -exec grep -L -E 'Code generated by .*\. DO NOT EDIT.' {} + | xargs goimports -format-only -w -local=github.com/rudderlabs
$(GO) run $(govulncheck) ./...
$(GO) run $(gofumpt) -l -w -extra .
find . -type f -name '*.go' -exec grep -L -E 'Code generated by .*\. DO NOT EDIT.' {} + | xargs $(GO) run $(goimports) -format-only -w -local=github.com/rudderlabs
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rudderlabs/rudder-go-kit

go 1.21
go 1.22.3

require (
cloud.google.com/go/storage v1.41.0
Expand Down
7 changes: 0 additions & 7 deletions internal/scripts/install-golangci-lint.sh

This file was deleted.

0 comments on commit 1b83f9a

Please sign in to comment.