use circleci 2.0

This commit is contained in:
Michael Hobbs
2017-08-29 10:14:33 -07:00
parent 5e0ea9c734
commit 4db991c891
6 changed files with 62 additions and 124 deletions

29
.circleci/config.yml Normal file
View File

@@ -0,0 +1,29 @@
version: 2
jobs:
build:
machine: true
parallelism: 4
steps:
- checkout
- run: |
make ci-dependencies
- run: |
./tests/ci/setup.sh
- run: |
sudo apt-get remove -qq -y git
sudo apt-get install -qq -y git=1:1.9.1-1ubuntu0.6 git-man=1:1.9.1-1ubuntu0.6
- run: |
echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup
- run: |
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0
sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev eth0
- run: |
case $CIRCLE_NODE_INDEX in
0) sudo -E make -e lint ;;
1) sudo -E make -e go-tests ;;
2) sudo -E make -e deploy-test-checks-root deploy-test-config deploy-test-multi deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;;
esac
- run:
shell: /bin/bash
command: sudo -E make -e test-ci
no_output_timeout: 60m

View File

@@ -116,7 +116,7 @@ dependencies: apt-update sshcommand plugn docker help2man man-db sigil
$(MAKE) -e stack
apt-update:
apt-get update
apt-get update -qq
help2man:
apt-get install -qq -y help2man

View File

@@ -1,20 +0,0 @@
machine:
pre:
- echo 'DOCKER_OPTS="-s btrfs -e lxc --userland-proxy=false"' | sudo tee -a /etc/default/docker
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci-cp-workaround'
- sudo chmod 0755 /usr/bin/docker
services:
- docker
dependencies:
cache_directories:
- "~/docker"
override:
- ./tests/ci/parallel_runner.sh setup: { timeout: 300 }
- echo "export DOKKU_SKIP_CLEANUP=true" > /home/dokku/.dokkurc/dokku_skip_cleanup
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0
- sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev eth0
post:
- sudo -E make -e lint
test:
override:
- ./tests/ci/parallel_runner.sh testing: { parallel: true, timeout: 3600 }

View File

@@ -6,7 +6,7 @@ ifeq ($(SYSTEM),Darwin)
brew install shellcheck
else
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse'
sudo apt-get update && sudo apt-get install -y shellcheck
sudo apt-get update -qq && sudo apt-get install -qq -y shellcheck
endif
endif
@@ -194,3 +194,7 @@ deploy-tests:
@$(QUIET) $(MAKE) deploy-test-static
test: setup-deploy-tests lint unit-tests deploy-tests
test-ci:
@echo "executing tests: $(shell circleci tests glob tests/unit/*.bats | circleci tests split --split-by=timings | xargs)"
bats $(shell circleci tests glob tests/unit/*.bats | circleci tests split --split-by=timings | xargs)

View File

@@ -1,102 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
MODE="$1"; MODE=${MODE:="testing"}
# shellcheck disable=SC2120
setup_circle() {
echo "=====> setup_circle on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E CI=true make -e sshcommand
# need to add the dokku user to the docker group
sudo usermod -G docker dokku
#### circle does some weird *expletive* with regards to root and gh auth (needed for gitsubmodules test)
sudo rsync -a ~ubuntu/.ssh/ ~root/.ssh/
sudo chown -R root:root ~root/.ssh/
sudo sed --in-place 's:/home/ubuntu:/root:g' ~root/.ssh/config
####
[[ "$1" == "buildstack" ]] && BUILD_STACK=true make -e stack
sudo -E CI=true make -e install
sudo -E make -e setup-deploy-tests
make -e ci-dependencies
# circleci runs Ubuntu 12.04 and thus a previous version of bash (4.2) than 14.04
# sudo apt-get install -y -q "bash=$(apt-cache show bash | egrep "^Version: 4.3" | head -1 | awk -F: '{ print $2 }' | xargs)"
bash --version
docker version
lsb_release -a
# setup .dokkurc
sudo -E mkdir -p /home/dokku/.dokkurc
sudo -E chown dokku:ubuntu /home/dokku/.dokkurc
sudo -E chmod 775 /home/dokku/.dokkurc
# pull node:4 image for testing
sudo docker pull node:4
}
if [[ -n "$CIRCLE_NODE_INDEX" ]] && [[ "$MODE" == "setup" ]]; then
# shellcheck disable=SC2119
setup_circle
exit $?
# case "$CIRCLE_NODE_INDEX" in
# 3)
# setup_circle buildstack
# exit $?
# ;;
# *)
# setup_circle
# exit $?
# ;;
# esac
fi
start=$(date +%s)
case "$CIRCLE_NODE_INDEX" in
0)
echo "=====> make unit-tests (1/4) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E UNIT_TEST_BATCH=1 make -e unit-tests
RC=$?
if [[ $RC -ne 0 ]]; then
echo "exit status: $RC"
exit $RC
fi
;;
1)
echo "=====> make unit-tests (2/4) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E UNIT_TEST_BATCH=2 make -e unit-tests
RC=$?
if [[ $RC -ne 0 ]]; then
echo "exit status: $RC"
exit $RC
fi
;;
2)
echo "=====> make unit-tests (3/4) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E UNIT_TEST_BATCH=3 make -e unit-tests
RC=$?
if [[ $RC -ne 0 ]]; then
echo "exit status: $RC"
exit $RC
fi
echo "=====> make deploy tests"
sudo -E make -e deploy-test-checks-root deploy-test-config deploy-test-multi deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy
RC=$?
if [[ $RC -ne 0 ]]; then
echo "exit status: $RC"
exit $RC
fi
;;
3)
echo "=====> make unit-tests (4/4) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E UNIT_TEST_BATCH=4 make -e unit-tests
RC=$?
if [[ $RC -ne 0 ]]; then
echo "exit status: $RC"
exit $RC
fi
;;
esac
end=$(date +%s)
runtime=$((end-start))
echo "suite runtime: $(date -u -d @${runtime} +"%T")"

27
tests/ci/setup.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC2120
setup_circle() {
echo "=====> setup_circle on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
sudo -E CI=true make -e sshcommand
# need to add the dokku user to the docker group
sudo usermod -G docker dokku
[[ "$1" == "buildstack" ]] && BUILD_STACK=true make -e stack
sudo -E CI=true make -e install
sudo -E make -e setup-deploy-tests
bash --version
docker version
lsb_release -a
# setup .dokkurc
sudo -E mkdir -p /home/dokku/.dokkurc
sudo -E chown dokku:ubuntu /home/dokku/.dokkurc
sudo -E chmod 775 /home/dokku/.dokkurc
# pull node:4 image for testing
sudo docker pull node:4
}
# shellcheck disable=SC2119
setup_circle
exit $?