~sseman/juju-ci-tools/assess-ext-user

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -eux

WORKSPACE=$(readlink -f $1)  # Where to build the tree.
LOCAL_TREE=$(readlink -f $2)  # Path to the repo: ~/gogo/src
ECO_PROJECT=$3  # Go Package name: github.com/juju/foo

: ${CI_TOOLS=$(readlink -f $(dirname $0))}
RELEASE_TOOLS=$(readlink -f $CI_TOOLS/../juju-release-tools)
CLOUD_CITY=$(readlink -f $CI_TOOLS/../cloud-city)
JUJU_BUILD=""

while [[ "${1-}" != "" ]]; do
    case $1 in
        --release-tools)
            shift
            RELEASE_TOOLS=$1
            ;;
        --cloud-city)
            shift
            CLOUD_CITY=$1
            ;;
        --juju-build)
            shift
            JUJU_BUILD=$1
            ;;
    esac
    shift
done

GOPATH=$WORKSPACE/ecosystem
export GOPATH
export PATH="$RELEASE_TOOLS:$CI_TOOLS:$PATH"

JUJU_PROJECT="github.com/juju/juju"
JUJU_DEPS="$GOPATH/src/$JUJU_PROJECT/dependencies.tsv"
ECO_PATH="$GOPATH/src/$(dirname $ECO_PROJECT)"
ECO_PACKAGE=$(basename $ECO_PROJECT)
ECO_DEPS="$ECO_PATH/$ECO_PACKAGE/dependencies.tsv"

# Copy the local Go tree to the GOPATH and use master for the eco project.
mkdir -p $ECO_PATH
cp -rp $LOCAL_TREE $GOPATH
cd $ECO_PATH/$ECO_PACKAGE
git checkout master
SHORTHASH=$(git log --first-parent -1 --pretty=format:%h)

# Are we testing a new Juju revision with the eco project, or a new eco rev?
if [[ -n "$JUJU_BUILD" ]]; then
    set +x
    source $CLOUD_CITY/juju-qa.jujuci
    set -x
    jujuci.py get -b $JUJU_BUILD build-revision \
        buildvars.bash $WORKSPACE/
    source $WORKSPACE/buildvars.bash
    JUJU_REVISION=$REVISION_ID
else
    JUJU_REVISION=$(grep $JUJU_PROJECT $ECO_DEPS | cut -d $'\t' -f 3)
fi

# Update Juju to the version under test.
cd $GOPATH/src/$JUJU_PROJECT
git fetch
git checkout $JUJU_REVISION

# Reassemble. We are still waiting for multifile godeps.
# godeps exist with an error when it cannot fetch a newer revision.
deptree.py -v $JUJU_DEPS $ECO_DEPS || deptree.py -v $JUJU_DEPS $ECO_DEPS

# Verify Juju and the eco project are integrated.
echo ""
echo "Testing $ECO_PACKAGE $SHORTHASH with Juju $JUJU_REVISION"
set +e
go test $ECO_PROJECT/... -test.v -gocheck.vv ||\
  go test $ECO_PROJECT/... -test.v -gocheck.vv
EXITCODE=$?
if [[ $((EXITCODE)) == 0 ]]; then
    echo "SUCCESS"
else
    echo "FAIL"
fi
exit $EXITCODE