Skip to content

Commit

Permalink
ci: Manage lint decision in travis.yml
Browse files Browse the repository at this point in the history
Rather than hard-coding the Go version we lint against in the Makefile,
this switches to managing that in the .travis.yml -- the same place we
manage the versions we're testing against.
  • Loading branch information
abhinav committed Oct 30, 2019
1 parent 8ed5ac4 commit 39ba1b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
@@ -1,17 +1,23 @@
language: go
sudo: false
go:
- 1.12.x
- 1.13.x

go_import_path: go.uber.org/zap
env:
global:
- TEST_TIMEOUT_SCALE=10
- GO111MODULE=on

matrix:
include:
- go: 1.12.x
- go: 1.13.x
env: LINT=1

script:
- make lint
- test -z "$LINT" || make lint
- make test
- make bench

after_success:
- make cover
- bash <(curl -s https://codecov.io/bash)
14 changes: 0 additions & 14 deletions Makefile
Expand Up @@ -13,22 +13,11 @@ GO_FILES := $(shell \
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
-o -name '*.go' -print | cut -b3-)

# The linting tools evolve with each Go version, so run them only on the
# latest stable release.
GO_VERSION := $(shell go version | cut -d " " -f 3)
GO_MINOR_VERSION := $(word 2,$(subst ., ,$(GO_VERSION)))
LINTABLE_MINOR_VERSIONS := 13

ifneq ($(filter $(LINTABLE_MINOR_VERSIONS),$(GO_MINOR_VERSION)),)
SHOULD_LINT := true
endif

.PHONY: all
all: lint test

.PHONY: lint
lint: $(GOLINT)
ifdef SHOULD_LINT
@rm -rf lint.log
@echo "Checking formatting..."
@gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log
Expand All @@ -41,9 +30,6 @@ ifdef SHOULD_LINT
@echo "Checking for license headers..."
@./checklicense.sh | tee -a lint.log
@[ ! -s lint.log ]
else
@echo "Skipping linters on" $(GO_VERSION)
endif

$(GOLINT):
go install golang.org/x/lint/golint
Expand Down

0 comments on commit 39ba1b2

Please sign in to comment.