mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Improve makefile and circleci config
Use gometalinter for linting put build artifact in dist/ store artifacts in circleci Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
b23d883ca5
commit
e009b670f3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/moby
|
||||
dist/
|
||||
|
47
Makefile
47
Makefile
@ -1,47 +1,38 @@
|
||||
VERSION="0.0" # dummy for now
|
||||
GIT_COMMIT=$(shell git rev-list -1 HEAD)
|
||||
|
||||
default: moby
|
||||
default: all
|
||||
|
||||
DEPS=$(wildcard cmd/moby/*.go src/moby/*.go src/initrd/*.go src/pad4/*.go) vendor.conf Makefile
|
||||
PREFIX?=/usr/local
|
||||
|
||||
GOLINT:=$(shell command -v golint 2> /dev/null)
|
||||
INEFFASSIGN:=$(shell command -v ineffassign 2> /dev/null)
|
||||
GOMETALINTER:=$(shell command -v gometalinter 2> /dev/null)
|
||||
|
||||
moby: $(DEPS)
|
||||
go build --ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" -o $@ github.com/moby/tool/cmd/moby
|
||||
dist/moby dist/moby-$(GOOS): $(DEPS)
|
||||
go build \
|
||||
--ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" \
|
||||
-o $@ ./cmd/moby
|
||||
|
||||
.PHONY:
|
||||
.PHONY: lint
|
||||
lint:
|
||||
ifndef GOLINT
|
||||
$(error "Please install golint! go get -u github.com/tool/lint")
|
||||
endif
|
||||
ifndef INEFFASSIGN
|
||||
$(error "Please install ineffassign! go get -u github.com/gordonklaus/ineffassign")
|
||||
endif
|
||||
# golint
|
||||
@test -z "$(shell find . -type f -name "*.go" -not -path "./vendor/*" -not -name "*.pb.*" -exec golint {} \; | tee /dev/stderr)"
|
||||
# gofmt
|
||||
@test -z "$$(gofmt -s -l .| grep -v .pb. | grep -v vendor/ | tee /dev/stderr)"
|
||||
# ineffassign
|
||||
@test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*" -exec ineffassign {} \; | tee /dev/stderr)
|
||||
ifeq ($(GOOS),)
|
||||
# govet
|
||||
@test -z "$$(go tool vet -printf=false . 2>&1 | grep -v vendor/ | tee /dev/stderr)"
|
||||
ifndef GOMETALINTER
|
||||
$(error "Please install gometalinter! go get -u github.com/alecthomas/gometalinter")
|
||||
endif
|
||||
gometalinter --config gometalinter.json ./...
|
||||
|
||||
test: lint moby
|
||||
# go test
|
||||
@go test github.com/moby/tool/src/moby
|
||||
test: dist/moby
|
||||
@go test $(shell go list ./... | grep -vE '/vendor/')
|
||||
# test build
|
||||
./moby build -format tar test/test.yml
|
||||
rm moby test.tar
|
||||
dist/moby build -format tar test/test.yml
|
||||
rm dist/moby test.tar
|
||||
|
||||
.PHONY: all
|
||||
all: lint test moby
|
||||
|
||||
.PHONY: install
|
||||
install: moby
|
||||
install: dist/moby
|
||||
cp -a $^ $(PREFIX)/bin/
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f moby
|
||||
rm -f dist
|
||||
|
31
circle.yml
31
circle.yml
@ -7,8 +7,29 @@ jobs:
|
||||
working_directory: $GOPATH/src/github.com/moby/tool
|
||||
steps:
|
||||
- checkout
|
||||
- run: go get github.com/golang/lint/golint
|
||||
- run: go get github.com/gordonklaus/ineffassign
|
||||
- run: cd $GOPATH/src/github.com/moby/tool && make test
|
||||
- run: cd $GOPATH/src/github.com/moby/tool && make clean && make GOOS=darwin lint moby
|
||||
- run: cd $GOPATH/src/github.com/moby/tool && make clean && make GOOS=windows lint moby
|
||||
- run:
|
||||
name: "Lint"
|
||||
command: |
|
||||
GOMETALINTER_SHA=7f9672e7ea538b8682e83395d50b12f09bb17b91
|
||||
go get -d github.com/alecthomas/gometalinter
|
||||
cd $GOPATH/src/github.com/alecthomas/gometalinter
|
||||
git checkout -q "$GOMETALINTER_SHA"
|
||||
go build -v -o $GOPATH/bin/gometalinter .
|
||||
export PATH=$GOPATH/bin:$PATH
|
||||
gometalinter --install
|
||||
cd $GOPATH/src/github.com/moby/tool
|
||||
make lint
|
||||
- run:
|
||||
name: "Test"
|
||||
command: |
|
||||
cd $GOPATH/src/github.com/moby/tool
|
||||
make test
|
||||
- run:
|
||||
name: "Build"
|
||||
command: |
|
||||
cd $GOPATH/src/github.com/moby/tool
|
||||
make GOOS=darwin dist/moby-darwin
|
||||
make GOOS=windows dist/moby-windows
|
||||
make GOOS=linux dist/moby-linux
|
||||
- store_artifacts:
|
||||
path: ./dist
|
||||
|
26
gometalinter.json
Normal file
26
gometalinter.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"Vendor": true,
|
||||
"Deadline": "2m",
|
||||
"Sort": ["linter", "severity", "path", "line"],
|
||||
"EnableGC": true,
|
||||
"WarnUnmatchedDirective": true,
|
||||
|
||||
"DisableAll": true,
|
||||
"Enable": [
|
||||
"deadcode",
|
||||
"gofmt",
|
||||
"goimports",
|
||||
"golint",
|
||||
"gosimple",
|
||||
"ineffassign",
|
||||
"interfacer",
|
||||
"lll",
|
||||
"misspell",
|
||||
"unconvert",
|
||||
"unparam",
|
||||
"unused",
|
||||
"vet"
|
||||
],
|
||||
|
||||
"LineLength": 160
|
||||
}
|
Loading…
Reference in New Issue
Block a user