8000 Improvements to circle ci integration by tomwilkie · Pull Request #637 · weaveworks/weave · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Improvements to circle ci integration #637

Merged
merged 1 commit into from
May 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
general:
branches:
ignore:
- gh-pages

machine:
services:
- docker
Expand All @@ -6,18 +11,26 @@ machine:
SRCDIR: /home/ubuntu/src/github.com/weaveworks/weave
PATH: $PATH:$HOME/.local/bin:$HOME/google-cloud-sdk/bin/
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
WEAVE_BUILD: $HOME/docker/weave-build.tar

dependencies:
cache_directories:
- "~/docker"
override:
- if [[ -e "$WEAVE_BUILD" ]]; then
docker load -i $WEAVE_BUILD;
else
docker pull weaveworks/weave-build;
mkdir -p $(dirname "$WEAVE_BUILD");
docker save weaveworks/weave-build >$WEAVE_BUILD;
fi
post:
- docker build -t weaveworks/weave-build build
- pip install --user --upgrade gcloud gsutil
- curl https://sdk.cloud.google.com | bash
- bin/setup-circleci-secrets "$SECRET_PASSWORD"

test:
pre:
- mkdir -p $(dirname $SRCDIR)
- cp -r $(pwd)/ $SRCDIR

test:
override:
- docker run -v /var/run/docker.sock:/run/docker.sock -v /home/ubuntu:/home/go weaveworks/weave-build
- cd $SRCDIR/test; ./gce.sh setup
Expand Down
48 changes: 26 additions & 22 deletions test/gce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,27 @@ IMAGE=ubuntu-14-04
TEMPLATE_NAME="test-template"
ZONE=us-central1-a
NUM_HOSTS=2
SUFFIX=""
if [ -n "$CIRCLECI" -a -n "$CIRCLE_SHA1" ]; then
SUFFIX="-${CIRCLE_SHA1:0:7}"
fi

# Setup authentication
gcloud auth activate-service-account --key-file $KEY_FILE
gcloud config set project $PROJECT

function vm_names {
local names=
for i in $(seq 1 $NUM_HOSTS); do
names="host$i$SUFFIX $names"
done
echo "$names"
}

# Delete all vms in this account
function destroy {
names="$(gcloud compute instances list --format=yaml | grep "^name\:" | cut -d: -f2 | xargs echo)"
if [ -n "$names" ]; then
gcloud compute instances delete --zone $ZONE -q $names
fi
names="$(vm_names)"
gcloud compute instances delete --zone $ZONE -q $names || true
CABF }

function external_ip {
Expand Down Expand Up @@ -53,25 +63,19 @@ EOF
# Create new set of VMS
function setup {
destroy
names=
for i in $(seq 1 $NUM_HOSTS); do
names="host$i $names"
done

names="$(vm_names)"
gcloud compute instances create $names --image $TEMPLATE_NAME --zone $ZONE
gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE

hosts=
for i in $(seq 1 $NUM_HOSTS); do
name="host$i.$ZONE.$PROJECT"
for name in $names; do
hostname="$name.$ZONE.$PROJECT"
# Add the remote ip to the local /etc/hosts
sudo -- sh -c "echo \"$(external_ip host$i) $name\" >>/etc/hosts"
sudo -- sh -c "echo \"$(external_ip $name) $hostname\" >>/etc/hosts"

# Add the local ips to the remote /etc/hosts
for j in $(seq 1 $NUM_HOSTS); do
ipaddr=$(internal_ip host$j)
othername="host$j.$ZONE.$PROJECT"
entry="$ipaddr $othername"
ssh -t $name "sudo -- sh -c \"echo \\\"$entry\\\" >>/etc/hosts\""
for othername in $names; do
entry="$(internal_ip $othername) $othername.$ZONE.$PROJECT"
ssh -t "$hostname" "sudo -- sh -c \"echo \\\"$entry\\\" >>/etc/hosts\""
done
done
}
Expand All @@ -88,10 +92,10 @@ function make_template {
function hosts {
hosts=
args=
for i in $(seq 1 $NUM_HOSTS); do
name="host$i.$ZONE.$PROJECT"
hosts="$name $hosts"
args="--add-host=$name:$(internal_ip host$i) $args"
for name in $(vm_names); do
hostname="$name.$ZONE.$PROJECT"
hosts="$hostname $hosts"
args="--add-host=$hostname:$(internal_ip $name) $args"
done
export SSH=ssh
export HOSTS="$hosts"
Expand Down
0