chore: adds makefile and linter.

This commit is contained in:
Fernandez Ludovic 2019-02-11 05:28:35 +01:00
parent 3f2c5c961d
commit 6536db26d4
3 changed files with 93 additions and 0 deletions

40
.golangci.toml Normal file
View File

@ -0,0 +1,40 @@
[run]
deadline = "2m"
skip-files = []
[linters-settings]
[linters-settings.govet]
check-shadowing = true
[linters-settings.gocyclo]
min-complexity = 12.0
[linters-settings.maligned]
suggest-new = true
[linters-settings.goconst]
min-len = 3.0
min-occurrences = 3.0
[linters-settings.misspell]
locale = "US"
[linters]
enable-all = true
disable = [
"maligned",
"lll",
"gas",
"dupl",
"prealloc",
"scopelint",
]
[issues]
exclude-use-default = false
max-per-linter = 0
max-same = 0
exclude = [
"`(version|commit|date)` is a global variable", # version.go
]

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
language: go
go:
- 1.11.x
- 1.x
sudo: false
env:
- GO111MODULE=on
notifications:
email:
on_success: never
on_failure: change
before_install:
# Install linters and misspell
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.12.5
- golangci-lint --version
install:
- echo "TRAVIS_GO_VERSION=$TRAVIS_GO_VERSION"
deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_GO_VERSION =~ ^1\.x$

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
.PHONY: default clean checks test build
TAG_NAME := $(shell git tag -l --contains HEAD)
SHA := $(shell git rev-parse --short HEAD)
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
default: clean checks test build
test: clean
go test -v -cover ./...
clean:
rm -rf dist/ cover.out
build: clean
@echo Version: $(VERSION) $(BUILD_DATE)
go build -v -ldflags '-X "main.version=${VERSION}" -X "main.commit=${SHA}" -X "main.date=${BUILD_DATE}"'
checks:
golangci-lint run