Don't need gsutil on circle; use a prebuild weave-build image and cache it locally.
This commit is contained in:
1 parent
5e5e932584
commit
5ed8ad46ee
2 files changed
+44
-27
No files matched your search
+18
-5
@@ -1,3 +1,8 @@
|
||||
general:
|
||||
branches:
|
||||
ignore:
|
||||
- gh-pages
|
||||
|
||||
machine:
|
||||
services:
|
||||
- docker
|
||||
@@ -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
|
||||
|
||||
+26
-22
@@ -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
|
||||
}
|
||||
|
||||
function external_ip {
|
||||
@@ -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
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user