Compare commits
3 commits
master
...
INFRANG-68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afc64495df | ||
|
|
822596f61d | ||
|
|
7adbf7c723 |
5 changed files with 82 additions and 39 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
working_directory: /go/src/github.com/Clever/amazon-kinesis-client-go
|
working_directory: ~/go/src/github.com/Clever/amazon-kinesis-client-go
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.13-stretch
|
- image: cimg/go:1.24
|
||||||
- image: circleci/mongo:3.2.20-jessie-ram
|
- image: circleci/mongo:3.2.20-jessie-ram
|
||||||
environment:
|
environment:
|
||||||
GOPRIVATE: github.com/Clever/*
|
GOPRIVATE: github.com/Clever/*
|
||||||
|
|
|
||||||
5
Makefile
5
Makefile
|
|
@ -2,10 +2,9 @@ include golang.mk
|
||||||
.DEFAULT_GOAL := test # override default goal set in library makefile
|
.DEFAULT_GOAL := test # override default goal set in library makefile
|
||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
PKG := github.com/Clever/amazon-kinesis-client-go
|
|
||||||
PKGS := $(shell go list ./... | grep -v /vendor )
|
PKGS := $(shell go list ./... | grep -v /vendor )
|
||||||
.PHONY: download_jars run build
|
.PHONY: download_jars run build
|
||||||
$(eval $(call golang-version-check,1.13))
|
$(eval $(call golang-version-check,1.24))
|
||||||
|
|
||||||
CONSUMER ?= consumer
|
CONSUMER ?= consumer
|
||||||
TMP_DIR := ./tmp-jars
|
TMP_DIR := ./tmp-jars
|
||||||
|
|
@ -43,7 +42,7 @@ download_jars:
|
||||||
all: test build
|
all: test build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 go build -installsuffix cgo -o build/$(CONSUMER) $(PKG)/cmd/$(CONSUMER)
|
CGO_ENABLED=0 go build -installsuffix cgo -o build/$(CONSUMER) ./cmd/$(CONSUMER)
|
||||||
|
|
||||||
run: build download_jars
|
run: build download_jars
|
||||||
command -v java >/dev/null 2>&1 || { echo >&2 "Java not installed. Install java!"; exit 1; }
|
command -v java >/dev/null 2>&1 || { echo >&2 "Java not installed. Install java!"; exit 1; }
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ func TestKayveeDecoding(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, spec := range specs {
|
for _, spec := range specs {
|
||||||
t.Run(fmt.Sprintf(spec.Title), func(t *testing.T) {
|
t.Run(fmt.Sprint(spec.Title), func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
fields, err := FieldsFromKayvee(spec.Input)
|
fields, err := FieldsFromKayvee(spec.Input)
|
||||||
if spec.ExpectedError != nil {
|
if spec.ExpectedError != nil {
|
||||||
|
|
@ -217,7 +217,7 @@ func TestSyslogDecoding(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, spec := range specs {
|
for _, spec := range specs {
|
||||||
t.Run(fmt.Sprintf(spec.Title), func(t *testing.T) {
|
t.Run(fmt.Sprint(spec.Title), func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
fields, err := FieldsFromSyslog(spec.Input)
|
fields, err := FieldsFromSyslog(spec.Input)
|
||||||
if spec.ExpectedError != nil {
|
if spec.ExpectedError != nil {
|
||||||
|
|
@ -542,7 +542,7 @@ select sleep(2);`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, spec := range specs {
|
for _, spec := range specs {
|
||||||
t.Run(fmt.Sprintf(spec.Title), func(t *testing.T) {
|
t.Run(fmt.Sprint(spec.Title), func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
fields, err := ParseAndEnhance(spec.Line, "deploy-env")
|
fields, err := ParseAndEnhance(spec.Line, "deploy-env")
|
||||||
if spec.ExpectedError != nil {
|
if spec.ExpectedError != nil {
|
||||||
|
|
|
||||||
21
go.mod
21
go.mod
|
|
@ -1,21 +1,28 @@
|
||||||
module github.com/amazon-kinesis-client-go
|
module github.com/amazon-kinesis-client-go
|
||||||
|
|
||||||
go 1.13
|
go 1.24
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Clever/amazon-kinesis-client-go v1.0.0
|
github.com/Clever/amazon-kinesis-client-go v1.0.0
|
||||||
github.com/Clever/syslogparser v0.0.0-20170816194131-fb28ad3e4340
|
github.com/Clever/syslogparser v0.0.0-20170816194131-fb28ad3e4340
|
||||||
github.com/a8m/kinesis-producer v0.2.0
|
github.com/a8m/kinesis-producer v0.2.0
|
||||||
github.com/aws/aws-sdk-go v1.35.28 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/jeromer/syslogparser v0.0.0-20190429161531-5fbaaf06d9e7 // indirect
|
|
||||||
github.com/jpillora/backoff v0.0.0-20170918002102-8eab2debe79d // indirect
|
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
|
||||||
github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7 // indirect
|
|
||||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
||||||
gopkg.in/Clever/kayvee-go.v6 v6.24.1
|
gopkg.in/Clever/kayvee-go.v6 v6.24.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/aws/aws-sdk-go v1.35.28 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/jeromer/syslogparser v0.0.0-20190429161531-5fbaaf06d9e7 // indirect
|
||||||
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
|
github.com/jpillora/backoff v0.0.0-20170918002102-8eab2debe79d // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
|
github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7 // indirect
|
||||||
|
google.golang.org/protobuf v1.26.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.3.1-0.20200602174213-b893565b90ca // indirect
|
gopkg.in/yaml.v2 v2.3.1-0.20200602174213-b893565b90ca // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
|
||||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
|
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
|
||||||
|
|
|
||||||
85
golang.mk
85
golang.mk
|
|
@ -1,7 +1,7 @@
|
||||||
# This is the default Clever Golang Makefile.
|
# This is the default Clever Golang Makefile.
|
||||||
# It is stored in the dev-handbook repo, github.com/Clever/dev-handbook
|
# It is stored in the dev-handbook repo, github.com/Clever/dev-handbook
|
||||||
# Please do not alter this file directly.
|
# Please do not alter this file directly.
|
||||||
GOLANG_MK_VERSION := 1.0.0
|
GOLANG_MK_VERSION := 1.3.1
|
||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
SYSTEM := $(shell uname -a | cut -d" " -f1 | tr '[:upper:]' '[:lower:]')
|
SYSTEM := $(shell uname -a | cut -d" " -f1 | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
@ -11,7 +11,7 @@ SYSTEM := $(shell uname -a | cut -d" " -f1 | tr '[:upper:]' '[:lower:]')
|
||||||
export TZ=UTC
|
export TZ=UTC
|
||||||
|
|
||||||
# go build flags for use across all commands which accept them
|
# go build flags for use across all commands which accept them
|
||||||
GO_BUILD_FLAGS := "-mod=vendor"
|
export GOFLAGS := -mod=vendor $(GOFLAGS)
|
||||||
|
|
||||||
# if the gopath includes several directories, use only the first
|
# if the gopath includes several directories, use only the first
|
||||||
GOPATH=$(shell echo $$GOPATH | cut -d: -f1)
|
GOPATH=$(shell echo $$GOPATH | cut -d: -f1)
|
||||||
|
|
@ -39,7 +39,7 @@ endef
|
||||||
# so we're defended against it breaking or changing in the future.
|
# so we're defended against it breaking or changing in the future.
|
||||||
FGT := $(GOPATH)/bin/fgt
|
FGT := $(GOPATH)/bin/fgt
|
||||||
$(FGT):
|
$(FGT):
|
||||||
go get github.com/GeertJohan/fgt@262f7b11eec07dc7b147c44641236f3212fee89d
|
go install -mod=readonly github.com/GeertJohan/fgt@262f7b11eec07dc7b147c44641236f3212fee89d
|
||||||
|
|
||||||
golang-ensure-curl-installed:
|
golang-ensure-curl-installed:
|
||||||
@command -v curl >/dev/null 2>&1 || { echo >&2 "curl not installed. Please install curl."; exit 1; }
|
@command -v curl >/dev/null 2>&1 || { echo >&2 "curl not installed. Please install curl."; exit 1; }
|
||||||
|
|
@ -47,9 +47,11 @@ golang-ensure-curl-installed:
|
||||||
# Golint is a tool for linting Golang code for common errors.
|
# Golint is a tool for linting Golang code for common errors.
|
||||||
# We pin its version because an update could add a new lint check which would make
|
# We pin its version because an update could add a new lint check which would make
|
||||||
# previously passing tests start failing without changing our code.
|
# previously passing tests start failing without changing our code.
|
||||||
|
# this package is deprecated and frozen
|
||||||
|
# Infra recommendation is to eventually move to https://github.com/golangci/golangci-lint so don't fail on linting error for now
|
||||||
GOLINT := $(GOPATH)/bin/golint
|
GOLINT := $(GOPATH)/bin/golint
|
||||||
$(GOLINT):
|
$(GOLINT):
|
||||||
go get golang.org/x/lint/golint@738671d3881b9731cc63024d5d88cf28db875626
|
go install -mod=readonly golang.org/x/lint/golint@738671d3881b9731cc63024d5d88cf28db875626
|
||||||
|
|
||||||
# golang-fmt-deps requires the FGT tool for checking output
|
# golang-fmt-deps requires the FGT tool for checking output
|
||||||
golang-fmt-deps: $(FGT)
|
golang-fmt-deps: $(FGT)
|
||||||
|
|
@ -74,14 +76,6 @@ endef
|
||||||
# golang-lint-deps-strict requires the golint tool for golang linting.
|
# golang-lint-deps-strict requires the golint tool for golang linting.
|
||||||
golang-lint-deps-strict: $(GOLINT) $(FGT)
|
golang-lint-deps-strict: $(GOLINT) $(FGT)
|
||||||
|
|
||||||
# golang-lint-strict calls golint on all golang files in the pkg and fails if any lint
|
|
||||||
# errors are found.
|
|
||||||
# arg1: pkg path
|
|
||||||
define golang-lint-strict
|
|
||||||
@echo "LINTING $(1)..."
|
|
||||||
@PKG_PATH=$$(go list -f '{{.Dir}}' $(1)); find $${PKG_PATH}/*.go -type f | grep -v gen_ | xargs $(FGT) $(GOLINT)
|
|
||||||
endef
|
|
||||||
|
|
||||||
# golang-test-deps is here for consistency
|
# golang-test-deps is here for consistency
|
||||||
golang-test-deps:
|
golang-test-deps:
|
||||||
|
|
||||||
|
|
@ -89,7 +83,7 @@ golang-test-deps:
|
||||||
# arg1: pkg path
|
# arg1: pkg path
|
||||||
define golang-test
|
define golang-test
|
||||||
@echo "TESTING $(1)..."
|
@echo "TESTING $(1)..."
|
||||||
@go test $(GO_BUILD_FLAGS) -v $(1)
|
@go test -v $(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# golang-test-strict-deps is here for consistency
|
# golang-test-strict-deps is here for consistency
|
||||||
|
|
@ -99,7 +93,22 @@ golang-test-strict-deps:
|
||||||
# arg1: pkg path
|
# arg1: pkg path
|
||||||
define golang-test-strict
|
define golang-test-strict
|
||||||
@echo "TESTING $(1)..."
|
@echo "TESTING $(1)..."
|
||||||
@go test -v $(GO_BUILD_FLAGS) -race $(1)
|
@go test -v -race $(1)
|
||||||
|
endef
|
||||||
|
|
||||||
|
# golang-test-strict-cover-deps is here for consistency
|
||||||
|
golang-test-strict-cover-deps:
|
||||||
|
|
||||||
|
# golang-test-strict-cover uses the Go toolchain to run all tests in the pkg with the race and cover flag.
|
||||||
|
# appends coverage results to coverage.txt
|
||||||
|
# arg1: pkg path
|
||||||
|
define golang-test-strict-cover
|
||||||
|
@echo "TESTING $(1)..."
|
||||||
|
@go test -v -race -cover -coverprofile=profile.tmp -covermode=atomic $(1)
|
||||||
|
@if [ -f profile.tmp ]; then \
|
||||||
|
cat profile.tmp | tail -n +2 >> coverage.txt; \
|
||||||
|
rm profile.tmp; \
|
||||||
|
fi;
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# golang-vet-deps is here for consistency
|
# golang-vet-deps is here for consistency
|
||||||
|
|
@ -109,7 +118,7 @@ golang-vet-deps:
|
||||||
# arg1: pkg path
|
# arg1: pkg path
|
||||||
define golang-vet
|
define golang-vet
|
||||||
@echo "VETTING $(1)..."
|
@echo "VETTING $(1)..."
|
||||||
@go vet $(GO_BUILD_FLAGS) $(1)
|
@go vet $(1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# golang-test-all-deps installs all dependencies needed for different test cases.
|
# golang-test-all-deps installs all dependencies needed for different test cases.
|
||||||
|
|
@ -132,24 +141,52 @@ golang-test-all-strict-deps: golang-fmt-deps golang-lint-deps-strict golang-test
|
||||||
# arg1: pkg path
|
# arg1: pkg path
|
||||||
define golang-test-all-strict
|
define golang-test-all-strict
|
||||||
$(call golang-fmt,$(1))
|
$(call golang-fmt,$(1))
|
||||||
$(call golang-lint-strict,$(1))
|
$(call golang-lint,$(1))
|
||||||
$(call golang-vet,$(1))
|
$(call golang-vet,$(1))
|
||||||
$(call golang-test-strict,$(1))
|
$(call golang-test-strict,$(1))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# golang-build: builds a golang binary. ensures CGO build is done during CI. This is needed to make a binary that works with a Docker alpine image.
|
# golang-test-all-strict-cover-deps: installs all dependencies needed for different test cases.
|
||||||
|
golang-test-all-strict-cover-deps: golang-fmt-deps golang-lint-deps-strict golang-test-strict-cover-deps golang-vet-deps
|
||||||
|
|
||||||
|
# golang-test-all-strict-cover calls fmt, lint, vet and test on the specified pkg with strict and cover
|
||||||
|
# requirements that no errors are thrown while linting.
|
||||||
|
# arg1: pkg path
|
||||||
|
define golang-test-all-strict-cover
|
||||||
|
$(call golang-fmt,$(1))
|
||||||
|
$(call golang-lint,$(1))
|
||||||
|
$(call golang-vet,$(1))
|
||||||
|
$(call golang-test-strict-cover,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# golang-build: builds a golang binary
|
||||||
# arg1: pkg path
|
# arg1: pkg path
|
||||||
# arg2: executable name
|
# arg2: executable name
|
||||||
define golang-build
|
define golang-build
|
||||||
@echo "BUILDING..."
|
@echo "BUILDING $(2)..."
|
||||||
@if [ -z "$$CI" ]; then \
|
@CGO_ENABLED=0 go build -o bin/$(2) $(1);
|
||||||
go build $(GO_BUILD_FLAGS) -o bin/$(2) $(1); \
|
|
||||||
else \
|
|
||||||
echo "-> Building CGO binary"; \
|
|
||||||
CGO_ENABLED=0 go build $(GO_BUILD_FLAGS) -installsuffix cgo -o bin/$(2) $(1); \
|
|
||||||
fi;
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# golang-debug-build: builds a golang binary with debugging capabilities
|
||||||
|
# arg1: pkg path
|
||||||
|
# arg2: executable name
|
||||||
|
define golang-debug-build
|
||||||
|
@echo "BUILDING $(2) FOR DEBUG..."
|
||||||
|
@CGO_ENABLED=0 go build -gcflags="all=-N -l" -o bin/$(2) $(1);
|
||||||
|
endef
|
||||||
|
|
||||||
|
# golang-cgo-build: builds a golang binary with CGO
|
||||||
|
# arg1: pkg path
|
||||||
|
# arg2: executable name
|
||||||
|
define golang-cgo-build
|
||||||
|
@echo "BUILDING $(2) WITH CGO ..."
|
||||||
|
@CGO_ENABLED=1 go build -installsuffix cgo -o bin/$(2) $(1);
|
||||||
|
endef
|
||||||
|
|
||||||
|
# golang-setup-coverage: set up the coverage file
|
||||||
|
golang-setup-coverage:
|
||||||
|
@echo "mode: atomic" > coverage.txt
|
||||||
|
|
||||||
# golang-update-makefile downloads latest version of golang.mk
|
# golang-update-makefile downloads latest version of golang.mk
|
||||||
golang-update-makefile:
|
golang-update-makefile:
|
||||||
@wget https://raw.githubusercontent.com/Clever/dev-handbook/master/make/golang-v1.mk -O /tmp/golang.mk 2>/dev/null
|
@wget https://raw.githubusercontent.com/Clever/dev-handbook/master/make/golang-v1.mk -O /tmp/golang.mk 2>/dev/null
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue