Add golint as a non-voting gate

Change-Id: I9850528a720ff517a3f400553fa8ab66bf4b1b3b
Closes: #253
This commit is contained in:
Ian Howell 2020-05-28 15:34:44 -05:00
parent 88542a66b5
commit 7243176e44
5 changed files with 65 additions and 6 deletions

View File

@ -83,12 +83,6 @@ lint: $(LINTER)
@echo "Performing linting step..."
@./tools/whitespace_linter
@./$(LINTER) run --config $(LINTER_CONFIG)
@# NOTE(howell): golangci-lint uses and embedded golint, but if we use it, it
@# will cause gate failures. For now, we'll install golint alongside
@# golangci-lint. Once all of golint's suggestions have been fulfilled, we'll
@# remove this and simply use the golint that's embedded in golangci-lint.
@go install golang.org/x/lint/golint
@golint ./...
@echo "Linting completed successfully"
.PHONY: tidy
@ -97,6 +91,10 @@ tidy:
@./tools/gomod_check
@echo "go.mod is up to date"
.PHONY: golint
golint:
@./tools/golint
.PHONY: images
images: docker-image
@ -145,6 +143,11 @@ docker-image-lint: DOCKER_MAKE_TARGET = lint
docker-image-lint: DOCKER_TARGET_STAGE = builder
docker-image-lint: docker-image
.PHONY: docker-image-golint
docker-image-golint: DOCKER_MAKE_TARGET = golint
docker-image-golint: DOCKER_TARGET_STAGE = builder
docker-image-golint: docker-image
.PHONY: clean
clean:
@rm -fr $(BINDIR)

View File

@ -0,0 +1,20 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- hosts: primary
tasks:
- name: Run Auxiliary Linter
block:
- name: "make docker-image-golint"
make:
chdir: "{{ zuul.project.src_dir }}"
target: docker-image-golint

28
tools/golint Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Our primary linter (golangci-lint) uses an embedded variant golint. This
# embedded version will catch the most egregious of the issues that the
# standard golint will catch, but it will fail to catch missing documentation.
# The purpose of this script is to produce a nonzero return code if the
# standard golint detects any issues.
go install golang.org/x/lint/golint
issues="$(golint ./...)"
if [[ -n "$issues" ]]; then
printf "ERROR: issues found when running 'golint ./...':\n"
printf "%s\n" "$issues"
exit 1
fi

View File

@ -15,6 +15,13 @@
run: tests/ansible/role-test-runner.yaml
nodeset: airship-airshipctl-single-node
- job:
name: airship-airshipctl-golint
pre-run: playbooks/airship-airshipctl-deploy-docker.yaml
run: playbooks/airship-airshipctl-golint.yaml
nodeset: airship-airshipctl-single-node
voting: false
- job:
name: airship-airshipctl-lint-unit
pre-run: playbooks/airship-airshipctl-deploy-docker.yaml

View File

@ -20,6 +20,7 @@
- "roles/*"
- openstack-tox-docs
- airship-airshipctl-lint-unit
- airship-airshipctl-golint
- airship-airshipctl-build-image
# - airship-airshipctl-functional-existing-k8s TODO: Enable this when functional tests exist, and a cluster is up
- airship-airshipctl-gate-test