-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go code checks can be run locally in container
Before the only option was to spin up a VM to run code checks, which is expensive in terms of time. Add Dockerfile-check to provide a container build for a runtime environment that supports go tool vet, gofmt, and golint Add script 'code_checks.sh' intended to be run inside the Dockerfile-check container that runs 'go tool vet', 'gofmt', misspell, and 'golint' against packages directories passed in. This script runs the checks in a different order than the Makefile, to deal with the more severe issues first, and deal with pretty print formatting last. Makefile updated to build the docker container and run it against the go pakages for netplugin. Drive-by: * Fix comment in Dockerfile * http_proxy and https_proxy are not useful as args when not referenced * add GOPATH environment var to Dockerfile for general use Signed-off-by: Chris Plock <chrisplo@cisco.com>
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ARG TAG=latest | ||
|
||
FROM golang:1.7.6 | ||
|
||
ENV GOPATH=/go | ||
|
||
WORKDIR /go/src/github.com/contiv/netplugin/ | ||
ENTRYPOINT ["/code_checks.sh"] | ||
|
||
RUN go get github.com/tools/godep github.com/aktau/github-release \ | ||
github.com/contiv/modelgen \ | ||
&& go get -u github.com/golang/lint/golint \ | ||
github.com/client9/misspell/cmd/misspell | ||
|
||
COPY scripts/code_checks.sh / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
PKG_DIRS=$* | ||
|
||
############# CORRECTNESS CHECKING ######### | ||
echo -e "\nChecking correctness for $PKG_DIRS ...\n" | ||
go tool vet $PKG_DIRS | ||
|
||
############# LINT CHECKING ################ | ||
echo -e "\nChecking lint for $PKG_DIRS ...\n" | ||
golint -set_exit_status $PKG_DIRS | ||
|
||
############# FORMAT CHECKING ############# | ||
echo -e "\nChecking format for $PKG_DIRS ...\n" | ||
gofmt -s -d $PKG_DIRS | ||
|
||
misspell -locale US -error $PKG_DIRS |