#!/bin/bash set -e # We need jq to analyse the PR files JSON, so install that first sudo apt-get -q update && sudo apt-get -q install bc jq echo "TEST_AND_PUBLISH=1" > "$STATE" if [ -n "$CI_PULL_REQUEST" -a "$CI_PULL_REQUEST" = "$CI_PULL_REQUESTS" ] ; then if PR=$(echo "$CI_PULL_REQUEST" | grep -oP '(?<=^https://github.com/weaveworks/weave/pull/)[0-9]+$') ; then echo "GH_PR=$PR" >> "$STATE" if FILES=$(curl -s https://api.github.com/repos/weaveworks/weave/pulls/$PR/files | jq -r '.[]|.filename') ; then echo "PR touches [$FILES]" if ! echo "$FILES" | grep -v ^site/ ; then echo "PR contains site changes only - skipping tests" echo "TEST_AND_PUBLISH=" >> "$STATE" else echo "PR contains non-site changes - running tests" fi else echo "Unable to get files for PR $PR" >&2 fi else echo "Unable to extract PR number from $CI_PULL_REQUEST" >&2 fi fi source "$STATE" mkdir -p $(dirname $SRCDIR) && cp -r $(pwd)/ $SRCDIR if [ -n "$TEST_AND_PUBLISH" ] ; then bin/setup-circleci-secrets "$SECRET_PASSWORD" cd $SRCDIR; git submodule update --init if [ "$CIRCLE_NODE_INDEX" = "0" ] ; then cd $SRCDIR/test; ./gce.sh make_template fi cd $SRCDIR/build ../tools/rebuild-image weaveworks/weavebuild . Dockerfile build.sh touch $SRCDIR/.build.uptodate sudo chown -R ubuntu /usr/local/go fi