Move linting to Go build

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy 2016-12-21 09:44:45 -08:00
parent b73d2a29a7
commit c8e7a6dd43
13 changed files with 28 additions and 74 deletions

View File

@ -1,2 +1,8 @@
FROM golang:1.7-alpine
RUN apk update && apk add --no-cache build-base git
# Get linting tools
RUN go get -u github.com/golang/lint/golint
# Get the linting script and place in PATH
COPY lint.sh /usr/bin/lint.sh

View File

@ -7,8 +7,8 @@ default: push
hash:
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build -
docker run --rm $(IMAGE):build sh -c 'cat /usr/local/go/bin/go /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > hash
tar cf - Dockerfile lint.sh | docker build --no-cache -t $(IMAGE):build -
docker run --rm $(IMAGE):build sh -c 'cat /usr/local/go/bin/go /lib/apk/db/installed /usr/bin/lint.sh /go/bin/golint | sha1sum' | sed 's/ .*//' > hash
push: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \

View File

@ -2,7 +2,7 @@
set -e
cd /src
cd $1
>&2 echo "gofmt..."
test -z $(gofmt -s -l .| grep -v .pb. | grep -v */vendor/ | tee /dev/stderr)

View File

@ -1,11 +0,0 @@
FROM golang:1.7-alpine
RUN apk update && apk add --no-cache build-base git
# Get linting tools
RUN go get -u github.com/golang/lint/golint
# Get the linting script and make its source dir
COPY lint.sh .
RUN mkdir /src
CMD ["./lint.sh", "/src"]

View File

@ -1,29 +0,0 @@
.PHONY: tag push
BASE=golang:1.7-alpine
IMAGE=alpine-go-lint
default: push
hash:
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build .
docker run --rm $(IMAGE):build sh -c 'cat /go/lint.sh /usr/local/go/bin/go /lib/apk/db/installed /go/bin/golint | sha1sum' | sed 's/ .*//' > hash
push: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
docker push mobylinux/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@ -1,5 +1,5 @@
# Tag: 1ae7bf8ec49a6537a93fba0c90720c65fa1c6ece
FROM mobylinux/alpine-build-go@sha256:5e9aed92363c25349c2845b9be4a5285e0f56376b8b3ce92c7361bb59e6eeb2d
# Tag: d3f266a146a79f35d3bebf252cce62eee25fcfa9
FROM mobylinux/alpine-build-go@sha256:1eca9f912cfa4f59ad817acad76744516b999395c080bc01a50b3a2b3a9a3f5c
COPY *.go /go/src/binfmt/

View File

@ -1,10 +1,12 @@
# Tag: 1ae7bf8ec49a6537a93fba0c90720c65fa1c6ece
FROM mobylinux/alpine-build-go@sha256:5e9aed92363c25349c2845b9be4a5285e0f56376b8b3ce92c7361bb59e6eeb2d
# Tag: d3f266a146a79f35d3bebf252cce62eee25fcfa9
FROM mobylinux/alpine-build-go@sha256:1eca9f912cfa4f59ad817acad76744516b999395c080bc01a50b3a2b3a9a3f5c
COPY ./ /go/src/diagnostics-server/
WORKDIR /go/src/diagnostics-server
RUN lint.sh .
RUN go install --ldflags '-extldflags "-fno-PIC"'
CMD ["tar", "cf", "-", "-C", "/go/bin", "diagnostics-server"]

View File

@ -2,10 +2,7 @@ all: usr/bin/diagnostics-server
DEPS=Dockerfile $(wildcard *.go)
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest lint
usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
[ -n "$$BUILD" ] && \
echo "Built $$BUILD" && \
@ -14,7 +11,4 @@ usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest lint
clean:
rm -f usr/bin/diagnostics-server
lint:
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
.DELETE_ON_ERROR:

View File

@ -1,10 +1,12 @@
# Tag: 1ae7bf8ec49a6537a93fba0c90720c65fa1c6ece
FROM mobylinux/alpine-build-go@sha256:5e9aed92363c25349c2845b9be4a5285e0f56376b8b3ce92c7361bb59e6eeb2d
# Tag: d3f266a146a79f35d3bebf252cce62eee25fcfa9
FROM mobylinux/alpine-build-go@sha256:1eca9f912cfa4f59ad817acad76744516b999395c080bc01a50b3a2b3a9a3f5c
COPY ./ /go/src/proxy/
WORKDIR /go/src/proxy
RUN lint.sh .
RUN go install --ldflags '-extldflags "-fno-PIC"'
CMD ["tar", "cf", "-", "-C", "/go/bin", "proxy"]

View File

@ -2,10 +2,7 @@ all: usr/bin/slirp-proxy sbin/proxy-vsockd
DEPS=Dockerfile $(wildcard *.go libproxy/*.go)
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
proxy: $(DEPS) ../vendor/manifest lint
proxy: $(DEPS) ../vendor/manifest
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
[ -n "$$BUILD" ] && \
echo "Built $$BUILD" && \
@ -22,7 +19,4 @@ sbin/proxy-vsockd: proxy
clean:
rm -rf proxy sbin usr
lint:
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
.DELETE_ON_ERROR:

View File

@ -1,10 +1,12 @@
# Tag: 1ae7bf8ec49a6537a93fba0c90720c65fa1c6ece
FROM mobylinux/alpine-build-go@sha256:5e9aed92363c25349c2845b9be4a5285e0f56376b8b3ce92c7361bb59e6eeb2d
# Tag: d3f266a146a79f35d3bebf252cce62eee25fcfa9
FROM mobylinux/alpine-build-go@sha256:1eca9f912cfa4f59ad817acad76744516b999395c080bc01a50b3a2b3a9a3f5c
COPY ./ /go/src/vsudd/
WORKDIR /go/src/vsudd
RUN lint.sh .
RUN go install --ldflags '-extldflags "-fno-PIC"'
CMD ["tar", "cf", "-", "-C", "/go/bin", "vsudd"]

View File

@ -2,10 +2,7 @@ all: vsudd
DEPS=Dockerfile $(wildcard *.go)
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
vsudd: $(DEPS) ../vendor/manifest lint
vsudd: $(DEPS) ../vendor/manifest
mkdir -p sbin
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
[ -n "$$BUILD" ] && \
@ -15,7 +12,4 @@ vsudd: $(DEPS) ../vendor/manifest lint
clean:
rm -rf sbin
lint:
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
.DELETE_ON_ERROR:

View File

@ -1,6 +1,6 @@
# Will do a Go build in future
# Tag: 1ae7bf8ec49a6537a93fba0c90720c65fa1c6ece
FROM mobylinux/alpine-build-go@sha256:5e9aed92363c25349c2845b9be4a5285e0f56376b8b3ce92c7361bb59e6eeb2d
# Tag: d3f266a146a79f35d3bebf252cce62eee25fcfa9
FROM mobylinux/alpine-build-go@sha256:1eca9f912cfa4f59ad817acad76744516b999395c080bc01a50b3a2b3a9a3f5c
COPY test.sh mksh /tmp/bin/
COPY ca-certificates.crt /tmp/etc/ssl/certs/ca-certificates.crt