-
Notifications
You must be signed in to change notification settings - Fork 153
/
build.yaml
134 lines (124 loc) · 5.86 KB
/
build.yaml
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
schedules:
adhoc:
schedule: adhoc
branches:
include: [master]
architecture:
- x64
os:
- ubuntu/trusty64/cpp-php
- ubuntu/xenial64
- centos/6-64
- centos/7-64
build:
- script: |
echo "Running packaging job"
package:
include: # list of files and glob paths to include in the artifact, relative to the current working directory
- ext/packaging/packages/*
release:
after:
each:
- script: |
LIBUV_VERSION=1.13.1
LIBUV_SUBVERSION=1
TOKENS=($(echo ${OS_VERSION} | tr "/" " "))
DISTRO=${TOKENS[0]}
RELEASE=${TOKENS[1]}
CPP_DRIVER_VERSION=2.7.0
CPP_DRIVER_SUBVERSION=1
if [ "${DISTRO}" = "ubuntu" ]; then
NAME=$(echo ${RELEASE%??})
ARCHITECTURE=${RELEASE:-2}
PACKAGE_TYPE=deb
PACKAGE_INSTALL="dpkg -i"
PACKAGE_UTILITY="apt-get"
PHP_VERSIONS=( php5.6-dev php7.0-dev php7.1-dev )
if [ "${NAME}" = "trusty" ]; then
RELEASE=14.04
elif [ "${NAME}" = "xenial" ]; then
RELEASE=16.04
else
printf "Unsupported Ubuntu Version: %s\n" ${RELEASE}
exit 1
fi
CPP_DRIVER_SUFFIX=_$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}_amd64.deb
CPP_DEV_DRIVER_SUFFIX=-dev_$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}_amd64.deb
LIBUV_SUFFIX=_${LIBUV_VERSION}-${LIBUV_SUBVERSION}_amd64.deb
LIBUV_DEV_SUFFIX=-dev_${LIBUV_VERSION}-${LIBUV_SUBVERSION}_amd64.deb
elif [ "${DISTRO}" = "centos" ]; then
TOKENS=($(echo ${RELEASE} | tr "-" " "))
NAME=${DISTRO}
RELEASE=${TOKENS[0]}
ARCHITECTURE=${TOKENS[1]}
PACKAGE_TYPE=rpm
PACKAGE_INSTALL="rpm -i"
PACKAGE_UTILITY="yum"
PHP_VERSIONS=( php56w-devel php70w-devel php71w-devel )
if [ "${RELEASE}" = "7" ]; then
CPP_DRIVER_SUFFIX=-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.centos.x86_64.rpm
CPP_DEV_DRIVER_SUFFIX=-devel-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.centos.x86_64.rpm
LIBUV_SUFFIX=-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el7.centos.x86_64.rpm
LIBUV_DEV_SUFFIX=-devel-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el7.centos.x86_64.rpm
elif [ "${RELEASE}" = "6" ]; then
CPP_DRIVER_SUFFIX=-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.x86_64.rpm
CPP_DEV_DRIVER_SUFFIX=-devel-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.x86_64.rpm
LIBUV_SUFFIX=-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el6.x86_64.rpm
LIBUV_DEV_SUFFIX=-devel-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el6.x86_64.rpm
else
printf "Unsupported Centos Version: %s\n" ${RELEASE}
exit 1
fi
else
printf "Unsupported OS: %s\n" ${OS_VERSION}
exit 1
fi
PACKAGE_UTILITY_INSTALL="${PACKAGE_UTILITY} install -y"
PACKAGE_UTILITY_REMOVE="${PACKAGE_UTILITY} remove -y"
CPP_DRIVER_BASE_URL=http://downloads.datastax.com/cpp-driver/$DISTRO/$RELEASE/cassandra/v$CPP_DRIVER_VERSION/cassandra-cpp-driver
LIBUV_BASE_URL=http://downloads.datastax.com/cpp-driver/$DISTRO/$RELEASE/dependencies/libuv/v$LIBUV_VERSION/libuv
pushd ext/packaging
mkdir packages
# Download and Install libuv
wget ${LIBUV_BASE_URL}${LIBUV_SUFFIX} ${LIBUV_BASE_URL}${LIBUV_DEV_SUFFIX}
sudo ${PACKAGE_INSTALL} libuv*.${PACKAGE_TYPE}
# Download and Install cpp core drivers
wget ${CPP_DRIVER_BASE_URL}${CPP_DRIVER_SUFFIX} ${CPP_DRIVER_BASE_URL}${CPP_DEV_DRIVER_SUFFIX}
sudo ${PACKAGE_INSTALL} cassandra-cpp-driver*.${PACKAGE_TYPE}
# Build, package and upload DataStax PHP driver
echo "Building DataStax PHP driver ..."
for PHP_VERSION in "${PHP_VERSIONS[@]}"
do
sudo ${PACKAGE_UTILITY_INSTALL} ${PHP_VERSION}
./build_${PACKAGE_TYPE}.sh
find build -type f -name "*.${PACKAGE_TYPE}" -exec mv {} packages \;
rm -rf build
PHP_TOKENS=($(echo ${PHP_VERSION} | tr "-" " "))
# Installing packaging and testing connection
sudo ${PACKAGE_INSTALL} packages/${PHP_TOKENS[0]}*.${PACKAGE_TYPE}
# Checking if cassandra php module is installed
php -m | grep -q cassandra
if [ $? -ne 0 ] ; then
echo "cassandra php module not installed. Marking build as failure"
exit 1
fi
PROGRAM_OUTPUT=$(php <<EOF
<?php
try{
Cassandra::cluster()->build()->connect();
} catch (Cassandra\\Exception\\RuntimeException \$e) {
echo 'Success'.PHP_EOL."";
}
EOF
)
# Throw error if connection test fails
if [ $PROGRAM_OUTPUT != "Success" ]; then
echo "Connection test failed. Marking build as failure."
exit 1
fi
sudo ${PACKAGE_UTILITY_REMOVE} ${PHP_TOKENS[0]}-common "${PHP_TOKENS[0]}-cassandra*"
done
pushd packages
# Uploading driver packages
curl -$ARTIFACTORY_CREDS -T "{$(echo php*-cassandra-driver* | tr ' ' ',')}" "https://datastax.jfrog.io/datastax/cpp-php-drivers/php-driver/builds/{$BUILD_NUMBER}/$DISTRO/$RELEASE/cassandra/$version/"
popd