Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit dcaf77a

Browse files
authored
Merge pull request #3270 from weaveworks/circle20
Convert CI build to CircleCI 2.0 Fix #3255
2 parents e669ac6 + e64656d commit dcaf77a

19 files changed

+195
-218
lines changed

.circleci/config.yml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: weaveworks/weavebuild:circle20-2e6504d3
5+
working_directory: /go/src/github.com/weaveworks/weave
6+
7+
jobs:
8+
lint:
9+
<<: *defaults
10+
steps:
11+
- checkout
12+
- run: git submodule update --init
13+
- run: make DEBUG=1 BUILD_IN_CONTAINER=false lint
14+
15+
unit-test:
16+
<<: *defaults
17+
parallelism: 2
18+
steps:
19+
- checkout
20+
- run: COVERDIR=test/coverage make BUILD_IN_CONTAINER=false tests
21+
- persist_to_workspace:
22+
root: .
23+
paths:
24+
- test/coverage
25+
26+
build:
27+
<<: *defaults
28+
steps:
29+
- checkout
30+
- setup_remote_docker
31+
- run: git submodule update --init
32+
- run: make COVERAGE=true BUILD_IN_CONTAINER=false SUDO= exes all
33+
- persist_to_workspace:
34+
root: .
35+
paths:
36+
- weave.tar.gz
37+
- tools/runner/runner
38+
- test/tls/tls
39+
40+
smoke-tests:
41+
machine:
42+
image: circleci/classic:201709-01
43+
working_directory: /home/circleci/src/github.com/weaveworks/weave
44+
environment:
45+
SRCDIR: /home/circleci/src/github.com/weaveworks/weave
46+
CIRCLE_ARTIFACTS: /tmp/artifacts
47+
parallelism: 2
48+
steps:
49+
- checkout
50+
- run: mkdir $CIRCLE_ARTIFACTS
51+
- run: git submodule update --init
52+
- attach_workspace:
53+
at: .
54+
# kick off creation of test VMs
55+
- run: bin/provision_test_vms.sh
56+
# when VMs are ready, copy built software to them
57+
- run: bin/circle-test-pre
58+
- run:
59+
command: bin/circle-test-smoke
60+
no_output_timeout: 360s
61+
# Destroy testing VMs:
62+
- run:
63+
command: bin/circle-destroy-vms
64+
background: true
65+
- persist_to_workspace:
66+
root: .
67+
paths:
68+
- test/coverage
69+
- store_artifacts:
70+
path: /tmp/artifacts
71+
72+
gen-coverage:
73+
<<: *defaults
74+
environment:
75+
CIRCLE_ARTIFACTS: /tmp/artifacts
76+
steps:
77+
- checkout
78+
- run: mkdir $CIRCLE_ARTIFACTS
79+
- attach_workspace:
80+
at: .
81+
- run: cd test; ./gen_coverage_reports.sh
82+
- run: goveralls -repotoken $COVERALLS_REPO_TOKEN -coverprofile=test/profile.cov -service=circleci
83+
- run: cp test/coverage.* $CIRCLE_ARTIFACTS
84+
- store_artifacts:
85+
path: /tmp/artifacts
86+
87+
deploy:
88+
<<: *defaults
89+
steps:
90+
- setup_remote_docker
91+
# Rebuild without coverage and push to dockerhub
92+
- deploy: bin/circle-deploy-master
93+
94+
workflows:
95+
version: 2
96+
build_test:
97+
jobs:
98+
- lint
99+
- unit-test
100+
- build
101+
- smoke-tests:
102+
requires:
103+
- lint
104+
- unit-test
105+
- build
106+
- gen-coverage:
107+
requires:
108+
- unit-test
109+
- smoke-tests
110+
- deploy:
111+
requires:
112+
- smoke-tests
113+
filters:
114+
branches:
115+
only: master

.lintignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# avoid breaking the build on make lint:
55
bin/circle-deploy-issues
66
bin/circle-deploy-master
7-
bin/circle-teardown-pre
87
bin/circle-test-teardown
98
bin/circle-test-unit
109
bin/install-wordepress

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ endif
246246
# It also makes sure the multiarch hooks are reqistered in the kernel so the QEMU emulation works
247247
$(BUILD_UPTODATE): build/*
248248
$(SUDO) docker build -t $(BUILD_IMAGE) build/
249+
$(SUDO) docker tag $(BUILD_IMAGE) $(BUILD_IMAGE):$(shell tools/image-tag)
249250
$(SUDO) docker run --rm --privileged multiarch/qemu-user-static:register --reset
250251
touch $@
251252

bin/circle-dependencies-post

-17
This file was deleted.

bin/circle-dependencies-post-sources

-36
This file was deleted.

bin/circle-deploy-master

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
set -e
44

5-
source "$STATE"
6-
7-
if [ -n "$TEST_AND_PUBLISH" ] ; then
8-
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
9-
cd $SRCDIR
10-
make clean-bin
11-
# CircleCI doesn't let us install the qemu module to do ARM docker builds
12-
make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only
13-
fi
5+
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
6+
cd $SRCDIR
7+
make clean-bin
8+
# CircleCI doesn't let us install the qemu module to do ARM docker builds
9+
make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only SUDO= BUILD_IN_CONTAINER=false

bin/circle-destroy-vms

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source "$SRCDIR/bin/circle-env"
6+
cd "$SRCDIR/test"
7+
./run-integration-tests.sh destroy

bin/circle-env

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Set environment variables here because CircleCI can't expand $FOO in 'env' section
2+
3+
export PATH="$PATH:$HOME/.local/bin:/opt/google-cloud-sdk/bin"
4+
export CLOUDSDK_CORE_DISABLE_PROMPTS=1
5+
# Base name of VMs for integration tests:
6+
export NAME=test-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX
7+
export TEST_VMS_PROV_AND_CONF_LOCK_FILE=$CIRCLE_ARTIFACTS/test_vms_provisioned_and_configured.txt
8+
export TEST_VMS_READY_LOCK_FILE=$CIRCLE_ARTIFACTS/test_vms_ready.txt
9+
# Google Cloud Platorm images for integration tests:
10+
export USE_IMAGE=1
11+
export DISK_NAME_PREFIX=test-$CIRCLE_BUILD_NUM-0

bin/circle-teardown-pre

-13
This file was deleted.

bin/circle-test-pre

+14-15
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ function signal_failure() {
99
}
1010
trap signal_failure ERR
1111

12-
source "$STATE"
1312
source "$(dirname "$0")/wait_for.sh"
1413

15-
if [ -n "$TEST_AND_PUBLISH" ]; then
16-
[ -n "$SECRET_KEY" ] || {
17-
echo "Cannot run smoke tests: no secret key"
18-
exit 1
19-
}
14+
[ -n "$SECRET_KEY" ] || {
15+
echo "Cannot run smoke tests: no secret key"
16+
exit 1
17+
}
18+
19+
source "$SRCDIR/bin/circle-env"
2020

21-
# Provisioning from image typically take 90 seconds,
22-
# but if we are creating a GCP image, it can take more than 10 minutes:
23-
wait_for 900 "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
21+
# Provisioning from image typically take 90 seconds,
22+
# but if we are creating a GCP image, it can take more than 10 minutes:
23+
wait_for 900 "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
2424

25-
# Upload built binaries to testing VMs:
26-
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
27-
./run-integration-tests.sh setup >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
28-
echo "OK" >"$TEST_VMS_READY_LOCK_FILE"
29-
echo "Test VMs now ready. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
30-
fi
25+
# Upload built binaries to testing VMs:
26+
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
27+
./run-integration-tests.sh setup
28+
echo "OK" >"$TEST_VMS_READY_LOCK_FILE"
29+
echo "Test VMs now ready. $(date)."

bin/circle-test-smoke

+14-15
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
set -e
44

5-
source "$STATE"
65
source "$(dirname "$0")/wait_for.sh"
76

8-
if [ -n "$TEST_AND_PUBLISH" ]; then
9-
[ -n "$SECRET_KEY" ] || {
10-
echo "Cannot run smoke tests: no secret key"
11-
exit 1
12-
}
7+
[ -n "$SECRET_KEY" ] || {
8+
echo "Cannot run smoke tests: no secret key"
9+
exit 1
10+
}
1311

14-
# Provisioning from image typically take 90 seconds,
15-
# but if we are creating a GCP image, it can take more than 10 minutes:
16-
wait_for 900 "$TEST_VMS_READY_LOCK_FILE"
12+
source "$SRCDIR/bin/circle-env"
1713

18-
# Run integration tests:
19-
export COVERAGE=true
20-
export WEAVE_NET_SANITY_CHECKS_FILES="$CIRCLE_ARTIFACTS/weave_net_sanity_check_*.log"
21-
cd "$SRCDIR/test" # Ensures we generate code coverage files in the right folder, and use the Terraform state of previously provisionned VMs.
22-
./run-integration-tests.sh test
23-
fi
14+
# Provisioning from image typically take 90 seconds,
15+
# but if we are creating a GCP image, it can take more than 10 minutes:
16+
wait_for 900 "$TEST_VMS_READY_LOCK_FILE"
17+
18+
# Run integration tests:
19+
export COVERAGE=true
20+
export WEAVE_NET_SANITY_CHECKS_FILES="$CIRCLE_ARTIFACTS/weave_net_sanity_check_*.log"
21+
cd "$SRCDIR/test" # Ensures we generate code coverage files in the right folder, and use the Terraform state of previously provisionned VMs.
22+
./run-integration-tests.sh test

bin/circle-test-teardown

-10
This file was deleted.

bin/circle-test-unit

-11
This file was deleted.

bin/provision_test_vms.sh

+15-18
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ function signal_failure() {
99
}
1010
trap signal_failure ERR
1111

12-
source "$STATE"
13-
1412
function install_terraform() {
1513
curl -fsS https://releases.hashicorp.com/terraform/0.8.5/terraform_0.8.5_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin
1614
}
@@ -20,24 +18,23 @@ function install_ansible() {
2018
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev \
2119
&& pip install --user -U setuptools cffi \
2220
&& pip install --user ansible
23-
export PATH="$PATH:$HOME/.local/bin"
2421
}
2522

26-
if [ -n "$TEST_AND_PUBLISH" ]; then
27-
[ -n "$SECRET_KEY" ] || {
28-
echo "Cannot run smoke tests: no secret key"
29-
exit 1
30-
}
23+
[ -n "$SECRET_KEY" ] || {
24+
echo "Cannot run smoke tests: no secret key"
25+
exit 1
26+
}
27+
28+
source "$SRCDIR/bin/circle-env"
3129

32-
install_terraform >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
33-
install_ansible >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
30+
install_terraform
31+
install_ansible
3432

35-
# Only attempt to create GCP image in first container, wait for it to be created otherwise:
36-
[ "$CIRCLE_NODE_INDEX" != "0" ] && export CREATE_IMAGE=0
33+
# Only attempt to create GCP image in first container, wait for it to be created otherwise:
34+
[ "$CIRCLE_NODE_INDEX" != "0" ] && export CREATE_IMAGE=0
3735

38-
# Provision and configure testing VMs:
39-
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
40-
./run-integration-tests.sh configure >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
41-
echo "OK" >"$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
42-
echo "Test VMs now provisioned and configured. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
43-
fi
36+
# Provision and configure testing VMs:
37+
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
38+
./run-integration-tests.sh configure
39+
echo "OK" >"$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
40+
echo "Test VMs now provisioned and configured. $(date)."

bin/wait_for.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ wait_for() {
1616
if ! ((i % 10)); then echo "[$i seconds]: Waiting for $lock_file to be created..."; fi
1717
sleep 1
1818
done
19-
echo "Timed out waiting for test VMs to be ready. See details in: $TEST_VMS_SETUP_OUTPUT_FILE" >&2
19+
echo "Timed out waiting for test VMs to be ready." >&2
2020
return 1
2121
}

0 commit comments

Comments
 (0)