forked from mlinderm/deca
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkins-test
executable file
·157 lines (129 loc) · 4.25 KB
/
jenkins-test
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
set -e -x -v
# make a tempdir for writing maven cruft to
DECA_MVN_TMP_DIR=$(mktemp -d -t decaTestMvnXXXXXXX)
# add this tempdir to the poms...
find . -name pom.xml \
-exec sed -i.bak \
-e "s:sun.io.serialization.extendedDebugInfo=true:sun.io.serialization.extendedDebugInfo=true -Djava.io.tmpdir=${DECA_MVN_TMP_DIR}:g" \
{} \;
find . -name "*.bak" -exec rm -f {} \;
# variable declarations
export PATH=${JAVA_HOME}/bin/:${PATH}
export MAVEN_OPTS="-Xmx1536m -XX:MaxPermSize=1g -Dfile.encoding=utf-8"
DIR=$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd )
PROJECT_ROOT=${DIR}/..
VERSION=$(grep "<version>" ${PROJECT_ROOT}/pom.xml | head -2 | tail -1 | sed 's/ *<version>//g' | sed 's/<\/version>//g')
# is the hadoop version set?
if ! [[ ${HADOOP_VERSION} ]];
then
echo "HADOOP_VERSION environment variable is not set."
echo "Please set this variable before running."
exit 1
fi
# is the spark version set?
if ! [[ ${SPARK_VERSION} ]];
then
echo "SPARK_VERSION environment variable is not set."
echo "Please set this variable before running."
exit 1
fi
# this next line is supposed to fail
set +e
echo "Rewriting POM.xml files to Scala 2.10 and Spark 1 should error..."
./scripts/move_to_spark_1.sh
if [[ $? == 0 ]];
then
echo "Running move_to_spark_1.sh when POMs are set up for Spark 1 should fail, but error code was 0 (success)."
exit 1
fi
./scripts/move_to_scala_2.10.sh
if [[ $? == 0 ]];
then
echo "Running move_to_scala_2.10.sh when POMs are set up for Scala 2.10 should fail, but error code was 0 (success)."
exit 1
fi
set -e
# are we testing for spark 2.0.0? if so, we need to rewrite our poms first
if [ ${SPARK_VERSION} == 2.0.0 ];
then
echo "Rewriting POM.xml files for Spark 2."
./scripts/move_to_spark_2.sh
# shouldn't be able to move to spark 2 twice
set +e
./scripts/move_to_spark_2.sh
if [[ $? == 0 ]];
then
echo "We have already moved to Spark 2, so running move_to_spark_2.sh a second time should fail, but error code was 0 (success)."
exit 1
fi
set -e
fi
# are we testing for scala 2.11? if so, we need to rewrite our poms to 2.11 first
if [ ${SCALAVER} == 2.11 ];
then
echo "Rewriting POM.xml files for Scala 2.11."
./scripts/move_to_scala_2.11.sh
# shouldn't be able to move to scala 2.11 twice
set +e
./scripts/move_to_scala_2.11.sh
if [[ $? == 0 ]];
then
echo "We have already moved to Scala 2.11, so running move_to_scala_2.11.sh a second time should fail, but error code was 0 (success)."
exit 1
fi
set -e
fi
# print versions
echo "Testing DECA version ${VERSION} on Spark ${SPARK_VERSION} and Hadoop ${HADOOP_VERSION}"
# first, build the sources, run the unit tests, and generate a coverage report
mvn clean \
-Dhadoop.version=${HADOOP_VERSION} \
-Dspark.version=${SPARK_VERSION}
# if those pass, build the distribution package and the integration tests
mvn -U \
test \
-P coverage scoverage:report
# if those pass, build the distribution package
mvn -U \
-P distribution \
package \
-DskipTests \
-Dhadoop.version=${HADOOP_VERSION} \
-Dspark.version=${SPARK_VERSION} \
-DargLine=${DECA_MVN_TMP_DIR}
# we are done with maven, so clean up the maven temp dir
find ${DECA_MVN_TMP_DIR}
rm -rf ${DECA_MVN_TMP_DIR}
# and move our poms back to their original values
# this will allow us to pass our porcelain test at the end
if [ ${SPARK_VERSION} == 2.0.0 ];
then
echo "Rewriting POM.xml files back to Spark 1."
./scripts/move_to_spark_1.sh
fi
if [ ${SCALAVER} == 2.11 ];
then
echo "Rewriting POM.xml files back to Scala 2.10."
./scripts/move_to_scala_2.10.sh
fi
find . -name pom.xml \
-exec sed -i.bak \
-e "s:sun.io.serialization.extendedDebugInfo=true -Djava.io.tmpdir=${DECA_MVN_TMP_DIR}:sun.io.serialization.extendedDebugInfo=true:g" \
{} \;
find . -name "*.bak" -exec rm -f {} \;
if test -n "$(git status --porcelain | grep -v -e html -e pdf)"
then
echo "Applying move_to_xyz script marred a pom.xml file."
echo "Exiting..."
exit 1
fi
./scripts/format-source
if test -n "$(git status --porcelain | grep -v -e html -e pdf)"
then
echo "Please run './scripts/format-source'"
exit 1
fi
echo
echo "All the tests passed"
echo