-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflows, use golangci-lint
- Loading branch information
Showing
6 changed files
with
162 additions
and
61 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @bai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: CI | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
name: Go ${{ matrix.go-version }} on Ubuntu | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go-version: [1.12.x, 1.13.x] | ||
platform: [ubuntu-latest] | ||
|
||
env: | ||
KAFKA_PEERS: localhost:9091,localhost:9092,localhost:9093,localhost:9094,localhost:9095 | ||
TOXIPROXY_ADDR: http://localhost:8474 | ||
KAFKA_INSTALL_ROOT: /home/runner/kafka | ||
KAFKA_HOSTNAME: localhost | ||
DEBUG: true | ||
KAFKA_VERSION: 2.3.0 | ||
KAFKA_SCALA_VERSION: 2.12 | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
# See https://github.com/actions/setup-go/issues/14 | ||
- name: Setup env | ||
run: | | ||
echo "::set-env name=GOPATH::$(go env GOPATH)" | ||
echo "::add-path::$(go env GOPATH)/bin" | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.1 | ||
export REPOSITORY_ROOT=${GITHUB_WORKSPACE} | ||
vagrant/install_cluster.sh | ||
vagrant/boot_cluster.sh | ||
vagrant/create_topics.sh | ||
vagrant/run_java_producer.sh | ||
- name: Run test suite | ||
run: make test | ||
|
||
- name: Run linter | ||
run: make lint | ||
|
||
- name: Teardown | ||
run: vagrant/halt_cluster.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
run: | ||
timeout: 5m | ||
deadline: 10m | ||
|
||
linters-settings: | ||
govet: | ||
check-shadowing: false | ||
golint: | ||
min-confidence: 0 | ||
gocyclo: | ||
min-complexity: 95 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
misspell: | ||
locale: US | ||
goimports: | ||
local-prefixes: github.com/Shopify/sarama | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- wrapperFunc | ||
- ifElseChain | ||
funlen: | ||
lines: 300 | ||
statements: 300 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
# - deadcode | ||
- depguard | ||
- dogsled | ||
# - dupl | ||
# - errcheck | ||
- funlen | ||
# - gocritic | ||
- gocyclo | ||
- gofmt | ||
# - goimports | ||
# - golint | ||
# - gosec | ||
# - gosimple | ||
- govet | ||
# - ineffassign | ||
# - interfacer | ||
# - misspell | ||
# - nakedret | ||
# - scopelint | ||
# - staticcheck | ||
# - structcheck | ||
# - stylecheck | ||
- typecheck | ||
# - unconvert | ||
# - unused | ||
# - varcheck | ||
- whitespace | ||
# - goconst | ||
# - gochecknoinits | ||
|
||
issues: | ||
exclude: | ||
- consider giving a name to these results | ||
- include an explanation for nolint directive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,27 @@ | ||
export GO111MODULE=on | ||
default: fmt get update test lint | ||
|
||
default: fmt vet errcheck test lint | ||
GO := GO111MODULE=on GOPRIVATE=github.com/linkedin GOSUMDB=off go | ||
GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG) | ||
GOTEST := $(GO) test -gcflags='-l' -p 3 -v -race -timeout 6m -coverprofile=profile.out -covermode=atomic | ||
|
||
# Taken from https://github.com/codecov/example-go#caveat-multiple-files | ||
.PHONY: test | ||
test: | ||
echo "mode: atomic" > coverage.txt | ||
for d in `go list ./...`; do \ | ||
go test -p 1 -v -timeout 6m -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \ | ||
if [ -f profile.out ]; then \ | ||
tail +2 profile.out >> coverage.txt; \ | ||
rm profile.out; \ | ||
fi \ | ||
done | ||
|
||
GOLINT := $(shell command -v golint) | ||
FILES := $(shell find . -name '*.go' -type f -not -name '*.pb.go' -not -name '*_generated.go' -not -name '*_test.go') | ||
TESTS := $(shell find . -name '*.go' -type f -not -name '*.pb.go' -not -name '*_generated.go' -name '*_test.go') | ||
|
||
.PHONY: lint | ||
lint: | ||
ifndef GOLINT | ||
go get golang.org/x/lint/golint | ||
endif | ||
go list ./... | xargs golint | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
get: | ||
$(GO) get ./... | ||
$(GO) mod verify | ||
$(GO) mod tidy | ||
|
||
ERRCHECK := $(shell command -v errcheck) | ||
# See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg | ||
.PHONY: errcheck | ||
errcheck: | ||
ifndef ERRCHECK | ||
go get github.com/kisielk/errcheck | ||
endif | ||
errcheck -ignorepkg fmt github.com/Shopify/sarama/... | ||
update: | ||
$(GO) get -u -v all | ||
$(GO) mod verify | ||
$(GO) mod tidy | ||
|
||
.PHONY: fmt | ||
fmt: | ||
@if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi | ||
gofmt -s -l -w $(FILES) $(TESTS) | ||
|
||
.PHONY : install_dependencies | ||
install_dependencies: get | ||
|
||
.PHONY: get | ||
get: | ||
go get -v ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
go clean ./... | ||
lint: | ||
golangci-lint run | ||
|
||
.PHONY: tidy | ||
tidy: | ||
go mod tidy -v | ||
test: | ||
$(GOTEST) ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters