-
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 (#1012)
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_in_docker.sh' intended to be run inside the Dockerfile-check container that runs `make checks` which in turn runs a variety of go code checks against packages passed in. Checks are reordered so more severe issues (e.g. functional) are resolved before less severe ones (e.g. formatting). Some checks are upated to be simpler and faster because the command accept multiple directories and recurse automatically. Drive-by: * removed some trailing whitespace * added more exclusions in dockerignore * variables for go check commands not needed, they are only referenced once and require a visual lookup to find what the command actually is Signed-off-by: Chris Plock <chrisplo@cisco.com>
- Loading branch information
Showing
4 changed files
with
54 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# we want to get the git commit SHA but not all the binary repo data | ||
.git/objects/pack | ||
bin/ | ||
.vagrant | ||
vagrant/ | ||
docs/ | ||
scripts/gobgp | ||
*.tar | ||
*.bz2 | ||
# export from a docker container, no need to copy into any docker containers | ||
install/v2plugin/rootfs | ||
vagrant/k8s/export/netctl |
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,10 @@ | ||
FROM golang:1.7.6 | ||
|
||
ENV GOPATH=/go | ||
|
||
WORKDIR /go/src/github.com/contiv/netplugin/ | ||
|
||
RUN go get github.com/golang/lint/golint \ | ||
github.com/client9/misspell/cmd/misspell | ||
|
||
CMD ["make", "checks"] |
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,27 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
PKG_DIRS=$* | ||
|
||
docker build -f Dockerfile-check -t contiv/netplugin-checks . | ||
|
||
# create container, stdout is the created container id | ||
container_id=$(docker create --name netplugin-checks \ | ||
contiv/netplugin-checks) | ||
|
||
# when there is an exit, remove the container | ||
function remove_container { | ||
docker rm ${container_id} | ||
} | ||
trap remove_container EXIT | ||
|
||
NETPLUGIN_DIR=/go/src/github.com/contiv/netplugin | ||
# copy Makefile and go packages to be checked | ||
docker cp Makefile ${container_id}:${NETPLUGIN_DIR}/ | ||
for pkg in ${PKG_DIRS}; do | ||
docker cp $pkg ${container_id}:${NETPLUGIN_DIR}/ | ||
done | ||
|
||
# run the checks | ||
docker start --attach ${container_id} |