diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..4c05019e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,33 @@ +version: 2 + +# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ +defaults: &defaults + docker: + - image: quay.io/weaveworks/build-golang:1.10.0-stretch + working_directory: /go/src/github.com/weaveworks/common + +workflows: + version: 2 + test-build-deploy: + jobs: + - lint + - test + +jobs: + lint: + <<: *defaults + steps: + - checkout + - run: + name: Lint + command: "make BUILD_IN_CONTAINER=false lint" + + test: + <<: *defaults + steps: + - checkout + - run: + name: Test + command: | + dep ensure && + make BUILD_IN_CONTAINER=false test diff --git a/Makefile b/Makefile index 85660136..f65d4286 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ IMAGE_PREFIX := weaveworks IMAGE_TAG := $(shell ./tools/image-tag) UPTODATE := .uptodate +BUILD_IMAGE=quay.io/weaveworks/build-golang:1.10.0-stretch # Building Docker images is now automated. The convention is every directory # with a Dockerfile in it builds an image calls quay.io/weaveworks/. @@ -23,8 +24,6 @@ DOCKER_IMAGE_DIRS=$(patsubst %/Dockerfile,%,$(DOCKERFILES)) all: $(UPTODATE_FILES) -common-build/$(UPTODATE): common-build/* - # All the boiler plate for building golang follows: SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER := true @@ -41,22 +40,22 @@ NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ ifeq ($(BUILD_IN_CONTAINER),true) -lint test shell: common-build/$(UPTODATE) +lint test shell: @mkdir -p $(shell pwd)/.pkg $(SUDO) docker run $(RM) -ti \ -v $(shell pwd)/.pkg:/go/pkg \ -v $(shell pwd):/go/src/github.com/weaveworks/common \ - $(IMAGE_PREFIX)/common-build $@ + $(BUILD_IMAGE) $@ else -lint: common-build/$(UPTODATE) +lint: ./tools/lint -notestpackage -ignorespelling queriers -ignorespelling Queriers . -test: common-build/$(UPTODATE) +test: ./tools/test -no-go-get -netgo -shell: common-build/$(UPTODATE) +shell: bash endif diff --git a/circle.yml b/circle.yml deleted file mode 100644 index c0ed0092..00000000 --- a/circle.yml +++ /dev/null @@ -1,32 +0,0 @@ -machine: - services: - - docker - environment: - REPO_ROOT: ${HOME}/.go_workspace/src/github.com/weaveworks/common - -dependencies: - cache_directories: - - "~/docker" - post: - # Get the dependencies - - mkdir -p ${HOME}/.go_workspace/src/github.com/weaveworks && cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME}/ ${REPO_ROOT} - - # Don't use master dep until https://github.com/weaveworks/common/pull/36 is fixed - #- go get -u github.com/golang/dep/cmd/dep && cd ${REPO_ROOT}/${CIRCLE_PROJECT_REPONAME} && dep ensure -v - # This version is 54b4235, built by Tom. - - | - curl -fsSLo dep 'https://drive.google.com/uc?export=download&id=0BwqTw528sZRIUzExY29ZMm5LVTQ' && \ - echo "f006f1e41b177e84df36116e08d23f364b7f2d7549c45221c6c7e90b2148cb7f dep" | sha256sum -c && \ - chmod +x dep && mkdir -p ${HOME}/.go_workspace/bin/ && mv dep ${HOME}/.go_workspace/bin/ && \ - cd ${REPO_ROOT}/ && dep ensure -v - - # Cache the build image - - | - cd ${REPO_ROOT}/common-build && \ - ../tools/rebuild-image weaveworks/common-build . build.sh Dockerfile && \ - touch .uptodate - -test: - override: - - cd ${REPO_ROOT}; make RM= lint - - cd ${REPO_ROOT}; make RM= test diff --git a/common-build/Dockerfile b/common-build/Dockerfile deleted file mode 100644 index af5cca48..00000000 --- a/common-build/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM golang:1.8.1 -RUN apt-get update && apt-get install -y file && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN go clean -i net && \ - go install -tags netgo std && \ - go install -race -tags netgo std -RUN go get -tags netgo \ - github.com/fzipp/gocyclo \ - github.com/golang/lint/golint \ - github.com/kisielk/errcheck \ - github.com/mjibson/esc \ - github.com/client9/misspell/cmd/misspell \ - mvdan.cc/sh/cmd/shfmt -COPY build.sh / -ENTRYPOINT ["/build.sh"] diff --git a/common-build/build.sh b/common-build/build.sh deleted file mode 100755 index 1e45f8a7..00000000 --- a/common-build/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -eu - -SRC_PATH=$GOPATH/src/github.com/weaveworks/common - -# If we run make directly, any files created on the bind mount -# will have awkward ownership. So we switch to a user with the -# same user and group IDs as source directory. We have to set a -# few things up so that sudo works without complaining later on. -uid=$(stat --format="%u" $SRC_PATH) -gid=$(stat --format="%g" $SRC_PATH) -echo "weave:x:$uid:$gid::$SRC_PATH:/bin/sh" >>/etc/passwd -echo "weave:*:::::::" >>/etc/shadow -echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers - -su weave -c "PATH=$PATH make -C $SRC_PATH BUILD_IN_CONTAINER=false $*"