From b3e77e81ea775c1929fa0287a6a2d1757c6c6e76 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 29 Jul 2018 13:33:55 +0000 Subject: [PATCH] Split into several jobs Run build, lint and unit-test steps in a container, using a pre-built image to save rebuilding at CircleCI Move a couple of scripts up to config.yml for clarity --- .circleci/config.yml | 73 +++++++++++++++++++++++++++++------- bin/circle-dependencies-post | 13 ------- bin/circle-deploy-master | 2 +- bin/circle-test-unit | 7 ---- 4 files changed, 61 insertions(+), 34 deletions(-) delete mode 100755 bin/circle-dependencies-post delete mode 100755 bin/circle-test-unit diff --git a/.circleci/config.yml b/.circleci/config.yml index e668db4d..9095fa57 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,39 @@ version: 2 +defaults: &defaults + docker: + - image: weaveworks/weavebuild:circle20-50a4e941 + working_directory: /go/src/github.com/weaveworks/weave + jobs: + lint: + <<: *defaults + steps: + - checkout + - run: git submodule update --init + - run: make DEBUG=1 BUILD_IN_CONTAINER=false lint + + unit-test: + <<: *defaults + parallelism: 2 + steps: + - checkout + - run: COVERDIR=test/coverage make BUILD_IN_CONTAINER=false tests + build: + <<: *defaults + steps: + - checkout + - setup_remote_docker + - run: git submodule update --init + - run: make COVERAGE=true BUILD_IN_CONTAINER=false SUDO= exes all + - persist_to_workspace: + root: . + paths: + - weave.tar.gz + - tools/runner/runner + - test/tls/tls + + smoke-tests: machine: image: circleci/classic:201709-01 environment: @@ -13,23 +46,16 @@ jobs: - run: mkdir $CIRCLE_ARTIFACTS # copy source dir and submodule update --init - run: bin/circle-dependencies-post-sources - - restore_cache: - key: v1-cache-{{ checksum "build/Dockerfile" }}-{{ checksum "build/build.sh" }} + - attach_workspace: + at: /home/circleci/src/github.com/weaveworks/weave # kick off creation of test VMs - run: command: bin/provision_test_vms.sh background: true - # create build image and make all - - run: bin/circle-dependencies-post - - save_cache: - key: v1-cache-{{ checksum "build/Dockerfile" }}-{{ checksum "build/build.sh" }} - paths: - - "~/docker" # when VMs are ready, copy built software to them - run: command: bin/circle-test-pre background: true - - run: bin/circle-test-unit - run: command: bin/circle-test-smoke no_output_timeout: 360s @@ -44,8 +70,29 @@ jobs: command: $SRCDIR/bin/circle-teardown-pre - store_artifacts: path: /tmp/artifacts + + deploy: + <<: *defaults + steps: + - setup_remote_docker + # Rebuild without coverage and push to dockerhub + - deploy: bin/circle-deploy-master + +workflows: + version: 2 + build_test: + jobs: + - lint + - unit-test + - build + - smoke-tests: + requires: + - lint + - unit-test + - build - deploy: - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - bin/circle-deploy-master - fi + requires: + - smoke-tests + filters: + branches: + only: master diff --git a/bin/circle-dependencies-post b/bin/circle-dependencies-post deleted file mode 100755 index e196ca3f..00000000 --- a/bin/circle-dependencies-post +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -e - -cd "$SRCDIR" -git submodule update --init -cd "$SRCDIR/build" -../tools/rebuild-image weaveworks/weavebuild . Dockerfile build.sh -touch "$SRCDIR/.build.uptodate" -sudo chown -R ubuntu /usr/local/go -cd "$SRCDIR" -make testrunner -make COVERAGE=true RM= exes all diff --git a/bin/circle-deploy-master b/bin/circle-deploy-master index b969bde3..5a8dc346 100755 --- a/bin/circle-deploy-master +++ b/bin/circle-deploy-master @@ -6,4 +6,4 @@ docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS cd $SRCDIR make clean-bin # CircleCI doesn't let us install the qemu module to do ARM docker builds -make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only +make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only SUDO= BUILD_IN_CONTAINER=false diff --git a/bin/circle-test-unit b/bin/circle-test-unit deleted file mode 100755 index f6a0433b..00000000 --- a/bin/circle-test-unit +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -cd $SRCDIR -make DEBUG=1 lint -COVERDIR=test/coverage make RM= tests