Skip to content

Commit

Permalink
Add golint as a non-voting gate
Browse files Browse the repository at this point in the history
Change-Id: I9850528a720ff517a3f400553fa8ab66bf4b1b3b
Closes: #253
  • Loading branch information
ian-howell committed May 29, 2020
1 parent 88542a6 commit 7243176
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions playbooks/airship-airshipctl-golint.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 0 deletions tools/golint
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions zuul.d/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7243176

Please sign in to comment.