Skip to content

Commit

Permalink
ci: improve linting speed
Browse files Browse the repository at this point in the history
  • Loading branch information
kuisathaverat committed Oct 22, 2020
1 parent daed8f9 commit be932d7
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 11 deletions.
30 changes: 24 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,29 @@ pipeline {
environment {
GOFLAGS = '-mod=readonly'
}
steps {
withGithubNotify(context: 'Lint') {
withBeatsEnv(archive: false, id: 'lint') {
dumpVariables()
cmd(label: 'make check', script: 'make check')
matrix {
axes {
axis {
name MAKE_TARGET
values (
'-C deploy/kubernetes all',
'-C dev-tools check',
'check-python',
'check-go'
)
}
}
stages {
stage('Run lint'){
steps {
withGithubNotify(context: "Lint: ${MAKE_TARGET}") {
withBeatsEnv(archive: false, id: "lint-${MAKE_TARGET}") {
dumpVariables()
cmd(label: "make ${MAKE_TARGET}", script: "make ${MAKE_TARGET}")
cmd(label: "Check for changes", script: "make check-no-changes")
}
}
}
}
}
}
Expand Down Expand Up @@ -489,7 +507,7 @@ def terraformApply(String directory) {
}

/**
* Tear down the terraform environments, by looking for all terraform states in directory
* Tear down the terraform environments, by looking for all terraform states in directory
* then it runs terraform destroy for each one.
* It uses terraform states previously stashed by startCloudTestEnv.
*/
Expand Down
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,33 @@ clean: mage
.PHONY: check
check: python-env
@$(foreach var,$(PROJECTS) dev-tools $(PROJECTS_XPACK_MAGE),$(MAKE) -C $(var) check || exit 1;)
@$(FIND) -name *.py -name *.py -not -path "*/build/*" -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)
@$(FIND) -name *.py -not -path "*/build/*" | xargs $(PYTHON_ENV)/bin/pylint --py3k -E || (echo "Code is not compatible with Python 3" && false)
$(MAKE) check-python
# check if vendor folder does not exists
[ ! -d vendor ]
@# Validate that all updates were committed
# Validate that all updates were committed
@$(MAKE) update
@$(MAKE) check-headers
go mod tidy
@$(MAKE) check-go
@$(MAKE) check-no-changes

## ccheck-go : Check there is no changes in Go modules.
.PHONY: check-go
check-go:
@go mod tidy

## ccheck-no-changes : Check there is no local changes.
.PHONY: check-no-changes
check-no-changes:
@git diff | cat
@git update-index --refresh
@git diff-index --exit-code HEAD --

## check-python : Python Linting.
.PHONY: check-python
check-python:
@$(FIND) -name *.py -name *.py -not -path "*/build/*" -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)
@$(FIND) -name *.py -not -path "*/build/*" | xargs $(PYTHON_ENV)/bin/pylint --py3k -E || (echo "Code is not compatible with Python 3" && false)

## check-headers : Check the license headers.
.PHONY: check-headers
check-headers: mage
Expand Down
5 changes: 5 additions & 0 deletions auditbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions filebeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
6 changes: 5 additions & 1 deletion heartbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down Expand Up @@ -67,4 +72,3 @@ stages:
- "windows-2012"
branches: true ## for all the branches
tags: true ## for all the tags

5 changes: 5 additions & 0 deletions journalbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions libbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions metricbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
unitTest:
mage: "mage build unitTest"
goIntegTest:
Expand Down
5 changes: 5 additions & 0 deletions packetbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions winlogbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
crosscompile:
make: "make -C winlogbeat crosscompile"
windows:
Expand Down
5 changes: 5 additions & 0 deletions x-pack/auditbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions x-pack/dockerlogbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C ../.. check-no-changes;
build:
mage: "mage build test"
withModule: true ## run the ITs only if the changeset affects a specific module.
5 changes: 5 additions & 0 deletions x-pack/elastic-agent/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions x-pack/filebeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions x-pack/functionbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions x-pack/libbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C .. check-no-changes;
arm:
mage: "mage build unitTest"
platforms: ## override default label in this specific stage.
Expand Down
5 changes: 5 additions & 0 deletions x-pack/metricbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C ../.. check-no-changes;
build:
cloud: "mage build test"
withModule: true ## run the ITs only if the changeset affects a specific module.
Expand Down
6 changes: 6 additions & 0 deletions x-pack/packetbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ when:
tags: true ## for all the tags
platform: "linux && ubuntu-18" ## default label for all the stages
stages:
# TODO confirm this works
Lint:
make: |
make check;
make update;
make -C ../.. check-no-changes;
windows:
mage: "mage build unitTest"
withModule: true
Expand Down
5 changes: 5 additions & 0 deletions x-pack/winlogbeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ when:
tags: true ## for all the tags
platform: "windows-2019" ## default label for all the stages
stages:
Lint:
make: |
make check;
make update;
make -C ../.. check-no-changes;
build:
mage: "mage build unitTest"
withModule: true
Expand Down

0 comments on commit be932d7

Please sign in to comment.