mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 18:41:37 +00:00
Add lint docker image for golang linting and testing to individual package subdirs
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
parent
51088ee491
commit
b73d2a29a7
10
Makefile
10
Makefile
@ -37,14 +37,6 @@ hyperkit.git/build/com.docker.hyperkit: hyperkit.git
|
||||
hyperkit: hyperkit.sh hyperkit.git/build/com.docker.hyperkit alpine/initrd.img alpine/kernel/x86_64/vmlinuz64
|
||||
sudo ./hyperkit.sh
|
||||
|
||||
lint:
|
||||
# gofmt
|
||||
@test -z "$$(gofmt -s -l .| grep -v .pb. | grep -v */vendor/ | tee /dev/stderr)"
|
||||
# govet
|
||||
@test -z "$$(go tool vet -printf=false . 2>&1 | grep -v */vendor/ | tee /dev/stderr)"
|
||||
# golint
|
||||
@test -z "$(shell find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*" -exec golint {} \; | tee /dev/stderr)"
|
||||
|
||||
test: Dockerfile.test alpine/initrd-test.img alpine/kernel/x86_64/vmlinuz64
|
||||
$(MAKE) -C alpine
|
||||
BUILD=$$( tar cf - $^ | docker build -f Dockerfile.test -q - ) && \
|
||||
@ -101,7 +93,7 @@ ci:
|
||||
$(MAKE) AUFS=1 test
|
||||
$(MAKE) AUFS=1 media
|
||||
|
||||
ci-pr: lint
|
||||
ci-pr:
|
||||
$(MAKE) clean
|
||||
$(MAKE) all
|
||||
$(MAKE) test
|
||||
|
11
alpine/base/alpine-go-lint/Dockerfile
Normal file
11
alpine/base/alpine-go-lint/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
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"]
|
29
alpine/base/alpine-go-lint/Makefile
Normal file
29
alpine/base/alpine-go-lint/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
.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:
|
16
alpine/base/alpine-go-lint/lint.sh
Executable file
16
alpine/base/alpine-go-lint/lint.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd /src
|
||||
|
||||
>&2 echo "gofmt..."
|
||||
test -z $(gofmt -s -l .| grep -v .pb. | grep -v */vendor/ | tee /dev/stderr)
|
||||
|
||||
>&2 echo "govet..."
|
||||
test -z $(go tool vet -printf=false . 2>&1 | grep -v */vendor/ | tee /dev/stderr)
|
||||
|
||||
>&2 echo "golint..."
|
||||
test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*" -exec golint {} \; | tee /dev/stderr)
|
||||
|
||||
>&2 echo "Successful lint check!"
|
@ -2,7 +2,10 @@ all: usr/bin/diagnostics-server
|
||||
|
||||
DEPS=Dockerfile $(wildcard *.go)
|
||||
|
||||
usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest
|
||||
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
|
||||
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
|
||||
|
||||
usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest lint
|
||||
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
@ -11,4 +14,7 @@ usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest
|
||||
clean:
|
||||
rm -f usr/bin/diagnostics-server
|
||||
|
||||
lint:
|
||||
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -2,7 +2,10 @@ all: usr/bin/slirp-proxy sbin/proxy-vsockd
|
||||
|
||||
DEPS=Dockerfile $(wildcard *.go libproxy/*.go)
|
||||
|
||||
proxy: $(DEPS) ../vendor/manifest
|
||||
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
|
||||
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
|
||||
|
||||
proxy: $(DEPS) ../vendor/manifest lint
|
||||
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
@ -19,4 +22,7 @@ sbin/proxy-vsockd: proxy
|
||||
clean:
|
||||
rm -rf proxy sbin usr
|
||||
|
||||
lint:
|
||||
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -2,7 +2,10 @@ all: vsudd
|
||||
|
||||
DEPS=Dockerfile $(wildcard *.go)
|
||||
|
||||
vsudd: $(DEPS) ../vendor/manifest
|
||||
# Tag: 02a04b2dc262195773b29125daebca0eebd97845
|
||||
LINT_IMAGE=mobylinux/alpine-go-lint@sha256:3009197c25294d87a7e81a53493666de47ed2b55a5bd283eabad4b876ea64559
|
||||
|
||||
vsudd: $(DEPS) ../vendor/manifest lint
|
||||
mkdir -p sbin
|
||||
BUILD=$$( tar cf - $(DEPS) -C .. vendor | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
@ -12,4 +15,7 @@ vsudd: $(DEPS) ../vendor/manifest
|
||||
clean:
|
||||
rm -rf sbin
|
||||
|
||||
lint:
|
||||
docker run --rm -v $(PWD):/src $(LINT_IMAGE)
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
Loading…
Reference in New Issue
Block a user