Skip to content

Commit

Permalink
feat(build): use golangci-lint for all linting
Browse files Browse the repository at this point in the history
Also move the tool installing from Travis config to the Makefile.
Also, deps requires dep to already be installed, so use a separate call to
install-devtools.

Fixes #61
  • Loading branch information
moorereason authored and xcoulon committed Oct 17, 2018
1 parent aeef974 commit b07c3a7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
18 changes: 6 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ dist: trusty
sudo: false

install:
# dep is used to manage dependencies
- go get -u github.com/golang/dep/cmd/dep
- dep ensure
# pigeon is used to generate the parser
- go get -u github.com/mna/pigeon
# ginkgo and gomega are used to run the tests
- go get -v github.com/onsi/ginkgo/ginkgo
- go get -v github.com/onsi/gomega
- go get github.com/modocache/gover
- make install-devtools
- make deps

language: go

Expand All @@ -26,15 +19,16 @@ matrix:
fast_finish: true
allow_failures:
- go: tip
script:

script:
# verify that the commit code for the parser was optimized during the code generation
- make verify-parser
# verify that the library builds completly
# verify that the library builds completely
- make build
# run the tests
- export CI=travis-ci
- make test

after_success:
- gover . coverage.txt
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
39 changes: 29 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ SOURCE_DIR ?= .
SOURCES := $(shell find $(SOURCE_DIR) -path $(SOURCE_DIR)/vendor -prune -o -name '*.go' -print)
COVERPKGS := $(shell go list ./... | grep -v vendor | paste -sd "," -)

DEVTOOLS=\
github.com/golang/dep/cmd/dep \
github.com/mna/pigeon \
github.com/modocache/gover \
github.com/onsi/ginkgo/ginkgo \
github.com/onsi/gomega

ifeq ($(OS),Windows_NT)
BINARY_PATH=$(INSTALL_PREFIX)/libasciidoc.exe
else
Expand Down Expand Up @@ -58,12 +65,17 @@ help:/
} \
}' $(MAKEFILE_LIST)

.PHONY: deps
.PHONY: install-devtools
## Install development tools.
install-devtools:
@go get -u -v $(DEVTOOLS)

.PHONY: deps
## Download build dependencies.
deps: $(VENDOR_DIR)
deps: $(VENDOR_DIR)

$(VENDOR_DIR):
$(DEP_BIN) ensure
$(VENDOR_DIR):
$(DEP_BIN) ensure

$(INSTALL_PREFIX):
# Build artifacts dir
Expand All @@ -73,8 +85,8 @@ $(TMP_PATH):
@mkdir -p $(TMP_PATH)

.PHONY: prebuild-checks
prebuild-checks: $(TMP_PATH) $(INSTALL_PREFIX)
## Check that all tools where found
prebuild-checks: $(TMP_PATH) $(INSTALL_PREFIX)
ifndef GIT_BIN
$(error The "$(GIT_BIN_NAME)" executable could not be found in your PATH)
endif
Expand Down Expand Up @@ -102,7 +114,7 @@ generate-optimized:


.PHONY: test
## run all tests except in the 'vendor' package
## run all tests except in the 'vendor' package
test: deps generate-optimized
@echo $(COVERPKGS)
@ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --trace --race --compilers=2 --cover -coverpkg $(COVERPKGS)
Expand All @@ -122,19 +134,26 @@ build: $(INSTALL_PREFIX) deps generate-optimized
cmd/libasciidoc/*.go


PARSER_DIFF_STATUS :=
.PHONY: lint
## run golangci-lint against project
lint:
@go get -v github.com/golangci/golangci-lint/cmd/golangci-lint
@golangci-lint run -E gofmt,golint,megacheck,misspell ./...


PARSER_DIFF_STATUS :=

.PHONY: verify-parser
## verify that the parser was built with the latest version of pigeon, using the `optimize-grammar` option
verify-parser: prebuild-checks
ifneq ($(shell git diff --quiet pkg/parser/asciidoc_parser.go; echo $$?), 0)
$(error "parser was generated with an older version of 'mna/pigeon' or without the '-optimize' option(s).")
else
else
@echo "parser is ok"
endif


.PHONY: install
## installs the binary executable in the $GOPATH/bin directory
install: build
@cp $(BINARY_PATH) $(GOPATH)/bin
@cp $(BINARY_PATH) $(GOPATH)/bin

0 comments on commit b07c3a7

Please sign in to comment.