Skip to content

Commit 4a36a9d

Browse files
author
Michael Ng
authored
chore(ci): Add makefile to simplify commands. (#181)
1 parent 14b8686 commit 4a36a9d

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

.travis.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
include:
1414
- stage: 'Lint'
1515
env: GIMME_GO_VERSION=1.12.x GIMME_OS=linux GIMME_ARCH=amd64
16-
before_script:
17-
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.19.0
1816
script:
19-
- $GOPATH/bin/golangci-lint run --out-format=tab --tests=false pkg/...
17+
- make install lint
18+
2019
- &test
2120
stage: 'Unit test'
2221
env: GIMME_GO_VERSION=master GIMME_OS=linux GIMME_ARCH=amd64
2322
script:
24-
- go test -v -race ./... -coverprofile=profile.cov
23+
- make cover
24+
2525
- <<: *test
2626
stage: 'Unit test'
2727
env: GIMME_GO_VERSION=1.8.x
@@ -34,14 +34,16 @@ jobs:
3434
# This pkg not in go 1.8
3535
- go get github.com/stretchr/testify
3636
# -coverprofile was not introduced in 1.8
37-
- go test -v -race ./...
37+
- make test
38+
3839
- <<: *test
3940
stage: 'Unit test'
4041
env: GIMME_GO_VERSION=1.12.x
4142
before_script:
4243
- go get github.com/mattn/goveralls
4344
after_success:
4445
- $GOPATH/bin/goveralls -coverprofile=profile.cov -service=travis-ci
46+
4547
- stage: 'Integration tests'
4648
env: GIMME_GO_VERSION=1.12.x FSC_PATH="/tmp/fsc-repo"
4749
before_script:
@@ -51,6 +53,7 @@ jobs:
5153
- eval "$(gimme)"
5254
script:
5355
- ./scripts/run-fsc-tests.sh -f "$FSC_PATH/features/" -d "$FSC_PATH/features/support/datafiles/" -t "$TAGS"
56+
5457
- stage: 'Source clear'
5558
env: GIMME_GO_VERSION=master GIMME_OS=linux GIMME_ARCH=amd64
5659
language: go

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# The name of the executable (default is current directory name)
2+
TARGET := $(shell basename "$(PWD)")
3+
.DEFAULT_GOAL := help
4+
5+
# Go parameters
6+
GO111MODULE:=on
7+
GOCMD=go
8+
GOPATH=$(shell $(GOCMD) env GOPATH)
9+
GOBUILD=$(GOCMD) build
10+
GOCLEAN=$(GOCMD) clean
11+
GOTEST=$(GOCMD) test
12+
GOGET=$(GOCMD) get
13+
GOLINT=golangci-lint
14+
15+
# Make is verbose in Linux. Make it silent.
16+
MAKEFLAGS += --silent
17+
18+
clean: ## runs `go clean` and removes the bin/ dir
19+
GO111MODULE=$(GO111MODULE) $(GOCLEAN) --modcache
20+
rm -rf $(GOBIN)
21+
22+
cover: ## run unit tests with coverage
23+
GO111MODULE=$(GO111MODULE) $(GOTEST) -race ./pkg/... -coverprofile=profile.cov
24+
25+
install: ## installs dev and ci dependencies
26+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.19.0
27+
28+
lint: ## runs `golangci-lint` linters defined in `.golangci.yml` file
29+
$(GOLINT) run --out-format=tab --tests=false pkg/...
30+
31+
test: ## recursively test source code in pkg without coverage
32+
GO111MODULE=$(GO111MODULE) $(GOTEST) ./pkg/...
33+
34+
help: ## help
35+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)