diff --git a/.lintignore b/.lintignore index 8a9c0f18..f6b9efd0 100644 --- a/.lintignore +++ b/.lintignore @@ -2,7 +2,6 @@ # Do not lint the below bash scripts in Weave Net, in order to # avoid breaking the build on make lint: -bin/circle-dependencies-post bin/circle-deploy-issues bin/circle-deploy-master bin/circle-teardown-pre diff --git a/bin/circle-dependencies-post b/bin/circle-dependencies-post index f83a728f..1b705fc6 100755 --- a/bin/circle-dependencies-post +++ b/bin/circle-dependencies-post @@ -2,41 +2,16 @@ set -e -echo "TEST_AND_PUBLISH=1" > "$STATE" - -# Avoid doing a full build if we can. Note if the PR doesn't exist -# when the build is kicked off, we can't run this check so we do a -# full build. Subsequent pushes to the same branch will have the desired behaviour -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 - cd $SRCDIR; git submodule update --init - cd $SRCDIR/build +if [ -n "$TEST_AND_PUBLISH" ]; then + cd "$SRCDIR" + git submodule update --init + cd "$SRCDIR/build" ../tools/rebuild-image weaveworks/weavebuild . Dockerfile build.sh - touch $SRCDIR/.build.uptodate + touch "$SRCDIR/.build.uptodate" sudo chown -R ubuntu /usr/local/go - cd $SRCDIR + cd "$SRCDIR" make testrunner make COVERAGE=true RM= exes all fi diff --git a/bin/circle-dependencies-post-sources b/bin/circle-dependencies-post-sources new file mode 100755 index 00000000..f6875ced --- /dev/null +++ b/bin/circle-dependencies-post-sources @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +echo "TEST_AND_PUBLISH=1" >"$STATE" + +# Avoid doing a full build if we can. Note if the PR doesn't exist +# when the build is kicked off, we can't run this check so we do a +# full build. Subsequent pushes to the same branch will have the desired behaviour +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 + cd "$SRCDIR" + git submodule update --init +fi diff --git a/circle.yml b/circle.yml index eb6fd1d5..39740407 100644 --- a/circle.yml +++ b/circle.yml @@ -27,6 +27,7 @@ dependencies: cache_directories: - "~/docker" post: + - bin/circle-dependencies-post-sources # Provision & configure testing VMs: - "while [ ! -d $SRCDIR ]; do sleep 1; done; $SRCDIR/bin/provision_test_vms.sh": parallel: true