913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
1 |
#!/bin/bash
|
2 |
set -eux
|
|
3 |
||
4 |
WORKSPACE=$(readlink -f $1) # Where to build the tree. |
|
928.3.6
by Curtis Hovey
Corrections and clarification per review. |
5 |
LOCAL_TREE=$(readlink -f $2) # Path to the repo: ~/gogo/src |
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
6 |
ECO_PROJECT=$3 # Go Package name: github.com/juju/foo |
7 |
||
8 |
: ${CI_TOOLS=$(readlink -f $(dirname $0))} |
|
9 |
RELEASE_TOOLS=$(readlink -f $CI_TOOLS/../juju-release-tools) |
|
10 |
CLOUD_CITY=$(readlink -f $CI_TOOLS/../cloud-city) |
|
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
11 |
JUJU_BUILD="" |
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
12 |
|
13 |
while [[ "${1-}" != "" ]]; do |
|
14 |
case $1 in |
|
15 |
--release-tools)
|
|
16 |
shift
|
|
17 |
RELEASE_TOOLS=$1 |
|
18 |
;;
|
|
19 |
--cloud-city)
|
|
20 |
shift
|
|
21 |
CLOUD_CITY=$1 |
|
22 |
;;
|
|
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
23 |
--juju-build)
|
24 |
shift
|
|
25 |
JUJU_BUILD=$1 |
|
26 |
;;
|
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
27 |
esac
|
28 |
shift
|
|
29 |
done
|
|
30 |
||
31 |
GOPATH=$WORKSPACE/ecosystem |
|
32 |
export GOPATH
|
|
928.3.7
by Curtis Hovey
Revise var names and DRY. |
33 |
export PATH="$RELEASE_TOOLS:$CI_TOOLS:$PATH" |
34 |
||
35 |
JUJU_PROJECT="github.com/juju/juju" |
|
36 |
JUJU_DEPS="$GOPATH/src/$JUJU_PROJECT/dependencies.tsv" |
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
37 |
ECO_PATH="$GOPATH/src/$(dirname $ECO_PROJECT)" |
928.3.7
by Curtis Hovey
Revise var names and DRY. |
38 |
ECO_PACKAGE=$(basename $ECO_PROJECT) |
39 |
ECO_DEPS="$ECO_PATH/$ECO_PACKAGE/dependencies.tsv" |
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
40 |
|
928.3.5
by Curtis Hovey
Build the eco tree from a local tree to minimise network calls. |
41 |
# Copy the local Go tree to the GOPATH and use master for the eco project.
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
42 |
mkdir -p $ECO_PATH
|
928.3.5
by Curtis Hovey
Build the eco tree from a local tree to minimise network calls. |
43 |
cp -rp $LOCAL_TREE $GOPATH |
928.3.7
by Curtis Hovey
Revise var names and DRY. |
44 |
cd $ECO_PATH/$ECO_PACKAGE |
928.3.5
by Curtis Hovey
Build the eco tree from a local tree to minimise network calls. |
45 |
git checkout master |
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
46 |
SHORTHASH=$(git log --first-parent -1 --pretty=format:%h) |
47 |
||
928.3.5
by Curtis Hovey
Build the eco tree from a local tree to minimise network calls. |
48 |
# Are we testing a new Juju revision with the eco project, or a new eco rev?
|
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
49 |
if [[ -n "$JUJU_BUILD" ]]; then |
50 |
set +x
|
|
51 |
source $CLOUD_CITY/juju-qa.jujuci |
|
52 |
set -x
|
|
53 |
jujuci.py get -b $JUJU_BUILD build-revision \ |
|
54 |
buildvars.bash $WORKSPACE/
|
|
55 |
source $WORKSPACE/buildvars.bash |
|
56 |
JUJU_REVISION=$REVISION_ID |
|
57 |
else
|
|
928.3.7
by Curtis Hovey
Revise var names and DRY. |
58 |
JUJU_REVISION=$(grep $JUJU_PROJECT $ECO_DEPS | cut -d $'\t' -f 3) |
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
59 |
fi
|
60 |
||
928.3.6
by Curtis Hovey
Corrections and clarification per review. |
61 |
# Update Juju to the version under test.
|
928.3.7
by Curtis Hovey
Revise var names and DRY. |
62 |
cd $GOPATH/src/$JUJU_PROJECT |
928.3.6
by Curtis Hovey
Corrections and clarification per review. |
63 |
git fetch |
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
64 |
git checkout $JUJU_REVISION
|
65 |
||
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
66 |
# Reassemble. We are still waiting for multifile godeps.
|
928.3.1
by Curtis Hovey
Update run-juju-eco-unit-tests.bash so that it can test the upstream as well as juju. |
67 |
# godeps exist with an error when it cannot fetch a newer revision.
|
928.3.7
by Curtis Hovey
Revise var names and DRY. |
68 |
deptree.py -v $JUJU_DEPS $ECO_DEPS || deptree.py -v $JUJU_DEPS $ECO_DEPS |
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
69 |
|
928.3.5
by Curtis Hovey
Build the eco tree from a local tree to minimise network calls. |
70 |
# Verify Juju and the eco project are integrated.
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
71 |
echo "" |
928.3.7
by Curtis Hovey
Revise var names and DRY. |
72 |
echo "Testing $ECO_PACKAGE $SHORTHASH with Juju $JUJU_REVISION" |
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
73 |
set +e
|
997.1.1
by Aaron Bentley
Make ecosystem tests more robust. |
74 |
go test $ECO_PROJECT/... -test.v -gocheck.vv ||\ |
75 |
go test $ECO_PROJECT/... -test.v -gocheck.vv |
|
913
by Curtis Hovey
Added a script to run unit-tests for ecosystem projects that import juju. |
76 |
EXITCODE=$? |
77 |
if [[ $((EXITCODE)) == 0 ]]; then |
|
78 |
echo "SUCCESS" |
|
79 |
else
|
|
80 |
echo "FAIL" |
|
81 |
fi
|
|
82 |
exit $EXITCODE |