forked from datastax/cpp-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.yaml
110 lines (98 loc) · 4.05 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
schedules:
adhoc:
schedule: adhoc
branches:
include: [master]
architecture:
- x64
os:
- ubuntu/trusty64/cpp
- 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
- packaging/packages/*
release:
after:
each:
- script: |
LIBUV_VERSION=1.14.1
CC=gcc
TEST_PROGRAM=$(mktemp)
TOKENS=($(echo ${OS_VERSION} | tr "/" " "))
DISTRO=${TOKENS[0]}
RELEASE=${TOKENS[1]}
if [ "${DISTRO}" = "ubuntu" ]; then
NAME=$(echo ${RELEASE%??})
ARCHITECTURE=${RELEASE:-2}
PACKAGE_TYPE=deb
PACKAGE_INSTALL="dpkg -i"
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
elif [ "${DISTRO}" = "centos" ]; then
TOKENS=($(echo ${RELEASE} | tr "-" " "))
NAME=${DISTRO}
RELEASE=${TOKENS[0]}
ARCHITECTURE=${TOKENS[1]}
PACKAGE_TYPE=rpm
PACKAGE_INSTALL="rpm -i"
else
printf "Unsupported OS: %s\n" ${OS_VERSION}
exit 1
fi
pushd packaging
mkdir packages
# Build libuv, install, and copy to "packages"
echo "Building libuv Packages [${LIBUV_VERSION}] ...\n"
git clone --depth 1 https://github.com/mpenick/libuv-packaging.git libuv-packaging
pushd libuv-packaging
./build_${PACKAGE_TYPE}.sh ${LIBUV_VERSION}
popd
find libuv-packaging/build -type f -name "*.${PACKAGE_TYPE}" -exec mv {} packages \;
sudo ${PACKAGE_INSTALL} packages/libuv*.${PACKAGE_TYPE}
# Build, package and upload DataStax C/C driver
echo "Building DataStax C/C driver ..."
./build_${PACKAGE_TYPE}.sh
find build -type f -name "*.${PACKAGE_TYPE}" -exec mv {} packages \;
pushd packages
# Install cpp-driver packages
sudo ${PACKAGE_INSTALL} cassandra*.${PACKAGE_TYPE}
# Create test file against cpp-driver and try to connect.
# Should compile and throw a connection error when executed.
$CC -x c -o $TEST_PROGRAM - -Wno-implicit-function-declaration -lcassandra - <<EOF
#include <cassandra.h>
int main(int argc, char* argv[]) {
CassFuture* connect_future = NULL;
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();
cass_cluster_set_contact_points(cluster, "127.0.0.1");
connect_future = cass_session_connect(session, cluster);
cass_future_wait(connect_future);
printf("Success\n");
return 0;
}
EOF
# Throw error if either compilation or test run fails
if [ $? -ne 0 ] ; then
echo "Connection test compilation failed. Marking build as failure."
exit 1
fi
if [ "$($TEST_PROGRAM)" != "Success" ] ; then
echo "Connection test did not return success. Marking build as failure."
exit 1
fi
# Uploading driver packages
curl -$ARTIFACTORY_CREDS -T "{$(echo cassandra-cpp-driver* | tr ' ' ',')}" "https://datastax.jfrog.io/datastax/cpp-php-drivers/cpp-driver/builds/{$BUILD_NUMBER}/$DISTRO/$RELEASE/cassandra/v$version/"
# Uploading libuv packages
curl -$ARTIFACTORY_CREDS -T "{$(echo libuv* | tr ' ' ',')}" "https://datastax.jfrog.io/datastax/cpp-php-drivers/cpp-driver/builds/{$BUILD_NUMBER}/$DISTRO/$RELEASE/dependencies/libuv/v$LIBUV_VERSION/"
popd