forked from jbosstm/quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.sh
More file actions
executable file
·179 lines (159 loc) · 6.56 KB
/
quickstart.sh
File metadata and controls
executable file
·179 lines (159 loc) · 6.56 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# JBoss, Home of Professional Open Source
# Copyright 2016, Red Hat, Inc., and others contributors as indicated
# by the @authors tag. All rights reserved.
# See the copyright.txt in the distribution for a
# full listing of individual contributors.
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License, v. 2.1.
# This program is distributed in the hope that it will be useful, but WITHOUT A
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License,
# v.2.1 along with this distribution; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#!/bin/bash
function fatal {
echo "$1"; exit 1
}
set -x
[ $WORKSPACE ] || fatal "please set WORKSPACE to the quickstarts directory"
NARAYANA_REPO=${NARAYANA_REPO:-jbosstm}
NARAYANA_BRANCH="${NARAYANA_BRANCH:-master}"
QUICKSTART_NARAYANA_VERSION=${QUICKSTART_NARAYANA_VERSION:-5.12.8.Final-SNAPSHOT}
function comment_on_pull
{
if [ "$COMMENT_ON_PULL" = "" ]; then return; fi
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F '/' '{ print $2 }')
if [ "$PULL_NUMBER" != "" ]
then
JSON="{ \"body\": \"$1\" }"
curl -d "$JSON" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/issues/$PULL_NUMBER/comments
else
echo "Not a pull request, so not commenting"
fi
}
# Expects one argument as an integer number and adjust it
# with multiplication by MFACTOR value, if it's defined
function timeout_adjust {
local re='^[0-9]+$'
[[ "$1" =~ $re ]] || return 1 # is parameter defined and is it an int number?
# is MFACTOR defined and is it an int number or is equal-or-less-or-equal than 1
if ! [[ "$MFACTOR" =~ $re ]] || [ "$MFACTOR" -le 1 ]; then
echo $1
return 0
fi
echo $(($MFACTOR * $1))
}
function int_env {
cd $WORKSPACE
export GIT_ACCOUNT=jbosstm
export GIT_REPO=quickstart
export MFACTOR=${MFACTOR:-1}
export -f timeout_adjust || echo "Function timeout_adjust won't be used in the subshells as it can't be exported"
[ $NARAYANA_CURRENT_VERSION ] || export NARAYANA_CURRENT_VERSION="5.12.8.Final-SNAPSHOT"
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F '/' '{ print $2 }')
PULL_DESCRIPTION=$(curl -H "Authorization: token $GITHUB_TOKEN" -s https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/pulls/$PULL_NUMBER)
if [[ $PULL_DESCRIPTION =~ "\"state\": \"closed\"" ]]; then
echo "pull closed"
exit 0
fi
}
function rebase_quickstart_repo {
cd $WORKSPACE
git remote add upstream https://github.com/jbosstm/quickstart.git
export BRANCHPOINT=master
git branch $BRANCHPOINT origin/$BRANCHPOINT
git pull --rebase --ff-only origin $BRANCHPOINT
if [ $? -ne 0 ]; then
comment_on_pull "Narayana rebase on $BRANCHPOINT failed. Please rebase it manually: $BUILD_URL"
fi
}
function build_narayana {
cd $WORKSPACE
# INITIALIZE ENV
export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m"
#rm -rf ~/.m2/repository/
rm -rf narayana
git clone https://github.com/${NARAYANA_REPO}/narayana.git -b ${NARAYANA_BRANCH}
echo "Checking if need Narayana PR"
if [ -n "$NY_BRANCH" ]; then
echo "Building NY PR"
[ $? = 0 ] || fatal "git clone https://github.com/${NARAYANA_REPO}/narayana.git failed"
cd narayana
git fetch origin +refs/pull/*/head:refs/remotes/jbosstm/pull/*/head
[ $? = 0 ] || fatal "git fetch of pulls failed"
git checkout $NY_BRANCH
[ $? = 0 ] || fatal "git fetch of pull branch failed"
cd ../
fi
if [ $? != 0 ]; then
comment_on_pull "Checkout failed: $BUILD_URL";
exit -1
fi
cd narayana
./build.sh clean install -B -DskipTests -Pcommunity
if [ $? != 0 ]; then
comment_on_pull "Narayana build failed: $BUILD_URL";
exit -1
fi
echo "Deleting check out - assuming all artifacts are in the .m2"
cp -rp narayana-full/target/narayana-full-5.12.8.Final-SNAPSHOT-bin.zip $WORKSPACE
cd ..
rm -rf narayana
}
function configure_wildfly {
cd $WORKSPACE
wget -nv https://ci.wildfly.org/guestAuth/repository/downloadAll/WF_Nightly/.lastSuccessful/artifacts.zip
unzip -q artifacts.zip
# the artifacts.zip may be wrapping several zip files: artifacts.zip -> wildfly-latest-SNAPSHOT.zip -> wildfly-###-SNAPSHOT.zip
local wildflyLatestZipWrapper=$(ls wildfly-latest-*.zip | head -n 1)
if [ -f "${wildflyLatestZipWrapper}" ]; then # wrapper zip exists, let's unzip it to proceed further to distro zip
unzip -q "${wildflyLatestZipWrapper}"
[ $? -ne 0 ] && echo "Cannot unzip WildFly nightly build wrapper zip file '${wildflyLatestZipWrapper}'" && return 2
rm -f $wildflyLatestZipWrapper
fi
local wildflyDistZip=$(ls wildfly-*-SNAPSHOT.zip | head -n 1)
[ "x$wildflyDistZip" = "x" ] && echo "Cannot find any zip file of SNAPSHOT WildFly distribution in the nightly build artifacts" && return 1
unzip -q "${wildflyDistZip}"
[ $? -ne 0 ] && echo "Cannot unzip WildFly nightly build distribution zip file '${wildflyDistZip}'" && return 3
export JBOSS_HOME="${PWD}/${wildflyDistZip%.zip}"
[ ! -d "${JBOSS_HOME}" ] && echo "After unzipping the file '${wildflyDistZip}' the JBOSS_HOME directory at '${JBOSS_HOME}' does not exist" && return 4
cp $JBOSS_HOME/docs/examples/configs/standalone-xts.xml $JBOSS_HOME/standalone/configuration/
cp $JBOSS_HOME/docs/examples/configs/standalone-rts.xml $JBOSS_HOME/standalone/configuration/
# cleaning
rm -f artifacts.zip
rm -f wildfly-*-SNAPSHOT*.zip
}
function build_apache-karaf {
cd $WORKSPACE
git clone --depth=1 https://github.com/apache/karaf.git apache-karaf
if [ $? != 0 ]; then
comment_on_pull "Karaf clone failed: $BUILD_URL";
exit -1
fi
./build.sh -f apache-karaf/pom.xml -B -Pfastinstall
if [ $? != 0 ]; then
comment_on_pull "Karaf build failed: $BUILD_URL";
exit -1
fi
}
function run_quickstarts {
cd $WORKSPACE
echo Running quickstarts
./build.sh -B clean install -fae -DskipX11Tests=true -Dversion.narayana=$QUICKSTART_NARAYANA_VERSION
if [ $? != 0 ]; then
comment_on_pull "Pull failed: $BUILD_URL";
exit -1
else
comment_on_pull "Pull passed: $BUILD_URL"
fi
}
int_env
comment_on_pull "Started testing this pull request: $BUILD_URL"
rebase_quickstart_repo
build_narayana
configure_wildfly || exit 1
#build_apache-karaf # JBTM-2820 disable the karaf build
run_quickstarts