diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..86bdc6cc6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,55 @@ +version: 2 +jobs: + build: + working_directory: /go/src/github.com/linuxkit/linuxkit + docker: + - image: circleci/golang:1.9-stretch + steps: + - checkout + - run: mkdir -p ./bin + - run: + name: Versions + command: | + set -x + go version + cat /etc/os-release + - run: + name: Dependencies + command: | + go get -u github.com/golang/lint/golint + go get -u github.com/gordonklaus/ineffassign + - run: + name: Lint + command: make local-check + - run: + name: Build amd64/linux + environment: + GOOS: linux + GOARCH: amd64 + command: make LOCAL_TARGET=bin/linuxkit-$GOOS-$GOARCH local-build + - run: + name: Build arm64/linux + environment: + GOOS: linux + GOARCH: arm64 + command: make LOCAL_TARGET=bin/linuxkit-$GOOS-$GOARCH local-build + - run: + name: Build amd64/darwin + environment: + GOOS: darwin + GOARCH: amd64 + command: make LOCAL_TARGET=bin/linuxkit-$GOOS-$GOARCH local-build + - run: + name: Build amd64/windows + environment: + GOOS: windows + GOARCH: amd64 + command: make LOCAL_TARGET=bin/linuxkit-$GOOS-$GOARCH local-build + - run: + name: Test + command: make local-test + - run: + name: Checksum + command: cd bin && sha256sum linuxkit-*-* > SHA256SUM + - store_artifacts: + path: ./bin diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d8a43b9e..000000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: go - -go: - - 1.9.x - -env: - - TRAVIS_GOOS=linux - - TRAVIS_GOOS=darwin - - TRAVIS_GOOS=windows - -script: -# We want native versions of the tools. - - go get -u github.com/golang/lint/golint - - go get -u github.com/gordonklaus/ineffassign - - export GOOS=$TRAVIS_GOOS -# FIXME: For non-linux GOOS, without running `go build -i`, vet fails with `vet: import failed: can't find import: fmt`... -# Note that `go build -i` requires write permission to GOROOT. (So it is not called in Makefile) - - go build -i github.com/linuxkit/linuxkit/src/cmd/linuxkit - - make local-check - - make local-build - - if [ "$GOOS" = "linux" ]; then make local-test ; fi diff --git a/Makefile b/Makefile index bdf988ced..17154ce1e 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,14 @@ test-cross: $(MAKE) -j 3 GOOS=linux tmp_moby_bin.tar tmp_rtf_bin.tar tmp_mt_bin.tar tmp_linuxkit_bin.tar $(MAKE) clean +ifeq ($(GOARCH)-$(GOOS),amd64-linux) +LOCAL_BUILDMODE?=pie +endif +LOCAL_BUILDMODE?=default + +LOCAL_LDFLAGS += -s -w -extldflags \"-static\" -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION) +LOCAL_TARGET ?= bin/linuxkit + .PHONY: local-check local-build local-test local local-check: $(LINUXKIT_DEPS) @echo gofmt... && o=$$(gofmt -s -l $(filter %.go,$(LINUXKIT_DEPS))) && if [ -n "$$o" ] ; then echo $$o ; exit 1 ; fi @@ -80,7 +88,7 @@ local-check: $(LINUXKIT_DEPS) @echo ineffassign... && ineffassign $(filter %.go,$(LINUXKIT_DEPS)) local-build: $(LINUXKIT_DEPS) | bin - go build -o bin/linuxkit --ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" github.com/linuxkit/linuxkit/src/cmd/linuxkit + go build -o $(LOCAL_TARGET) --buildmode $(LOCAL_BUILDMODE) --ldflags "$(LOCAL_LDFLAGS)" github.com/linuxkit/linuxkit/src/cmd/linuxkit local-test: $(LINUXKIT_DEPS) go test $(shell go list github.com/linuxkit/linuxkit/src/cmd/linuxkit/... | grep -v ^github.com/linuxkit/linuxkit/src/cmd/linuxkit/vendor/)