Skip to content

Commit

Permalink
chore: add CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jan 18, 2019
1 parent 0fc926d commit 267c0a9
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .golangci.toml
Original file line number Diff line number Diff line change
@@ -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
]
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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:
repo: ldez/motoko
tags: true
condition: $TRAVIS_GO_VERSION =~ ^1\.x$
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.PHONY: all

GOFILES := $(shell go list -f '{{range $$index, $$element := .GoFiles}}{{$$.Dir}}/{{$$element}}{{"\n"}}{{end}}' ./... | grep -v '/vendor/')

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: check-fmt
golangci-lint run

check-fmt: SHELL := /bin/bash
check-fmt:
diff -u <(echo -n) <(gofmt -d $(GOFILES))

0 comments on commit 267c0a9

Please sign in to comment.