Skip to content

Commit

Permalink
dev-tools: run golint/reviewdog in Jenkins (#3832)
Browse files Browse the repository at this point in the history
* dev-tools: run golint/reviewdog in Jenkins

* jenkins_ci: map github plugin vars to reviewdog

* Make lint target available in other beats

* Run reviewdog directly

* Introduce dummy warning to test reviewdog

* Rename -ci option to "common" (that is apparently what jenkins falls into)

* Remove dummy warning
  • Loading branch information
7AC authored and andrewkroh committed Apr 4, 2017
1 parent bfa3128 commit c0c7b4a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ SNAPSHOT?=yes
PYTHON_ENV?=${BUILD_DIR}/python-env
VIRTUALENV_PARAMS?=
FIND=find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*"
GOLINT=golint
GOLINT_REPO=github.com/golang/lint/golint
REVIEWDOG=reviewdog
REVIEWDOG_OPTIONS?=-diff "git diff master"
REVIEWDOG_REPO=github.com/haya14busa/reviewdog/cmd/reviewdog

# Runs complete testsuites (unit, system, integration) for all beats with coverage and race detection.
# Also it builds the docs and the generators
Expand Down Expand Up @@ -72,14 +77,19 @@ check: python-env
.PHONY: misspell
misspell:
go get github.com/client9/misspell
${FIND} -name '*' -exec misspell -w {} \;
$(FIND) -name '*' -exec misspell -w {} \;

.PHONY: fmt
fmt: python-env
$(foreach var,$(PROJECTS),$(MAKE) -C $(var) fmt || exit 1;)
# Cleans also python files which are not part of the beats
find . -type f -name *.py -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" -exec autopep8 --in-place --max-line-length 120 {} \;

.PHONY: lint
lint:
@go get $(GOLINT_REPO) $(REVIEWDOG_REPO)
$(REVIEWDOG) $(REVIEWDOG_OPTIONS)

# Collects all dashboards and generates dashboard folder for https://github.com/elastic/beats-dashboards/tree/master/dashboards
.PHONY: beats-dashboards
beats-dashboards:
Expand Down
10 changes: 10 additions & 0 deletions dev-tools/jenkins_ci
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,21 @@ parse_args() {
fi
}

lint() {
if [ -z $ghprbPullId ]; then
return
fi
export REVIEWDOG_OPTIONS="-ci common"
IFS='/' read -a repo <<< "$ghprbGhRepository"
CI_PULL_REQUEST=$ghprbPullId CI_COMMIT=$ghprbActualCommit CI_REPO_OWNER=${repo[0]} CI_REPO_NAME=${repo[1]} make lint
}

build() {
make check
make testsuite
make coverage-report
make docs
lint
}

cleanup() {
Expand Down
10 changes: 10 additions & 0 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ COVERAGE_DIR=${BUILD_DIR}/coverage
COVERAGE_TOOL=${BEAT_GOPATH}/bin/gotestcover
COVERAGE_TOOL_REPO=github.com/elastic/beats/vendor/github.com/pierrre/gotestcover
TESTIFY_TOOL_REPO=github.com/elastic/beats/vendor/github.com/stretchr/testify
GOLINT=golint
GOLINT_REPO=github.com/golang/lint/golint
REVIEWDOG=reviewdog -conf ${ES_BEATS}/reviewdog.yml
REVIEWDOG_OPTIONS?=-diff "git diff master"
REVIEWDOG_REPO=github.com/haya14busa/reviewdog/cmd/reviewdog
PROCESSES?= 4
TIMEOUT?= 90
NOSETESTS_OPTIONS?=--process-timeout=$(TIMEOUT) --with-timer ## @testing the options to pass when calling nosetests
Expand Down Expand Up @@ -96,6 +101,11 @@ fmt: python-env ## @build Runs `gofmt -s -l -w` and `autopep8`on the project's s
gofmt -s -l -w ${GOFILES_NOVENDOR}
${FIND} -name *.py -exec autopep8 --in-place --max-line-length 120 {} \;

.PHONY: lint
lint:
@go get $(GOLINT_REPO) $(REVIEWDOG_REPO)
$(REVIEWDOG) $(REVIEWDOG_OPTIONS)

.PHONY: clean
clean:: ## @build Cleans up all files generated by the build steps
rm -rf build
Expand Down
3 changes: 3 additions & 0 deletions reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runner:
golint:
cmd: golint $(go list ./... | grep -v /vendor/)

0 comments on commit c0c7b4a

Please sign in to comment.