Skip to content

Commit 3100446

Browse files
esteffinfaberga
authored andcommitted
Multi platform and multi configuration Travis-CI pipeline
Multi platform and multi configuration Travis-CI pipeline: - Lib build and Package build (`PACKAGE_BUILD=OFF`, `PACKAGE_BUILD=ON`) testing - Utilities testing (`utils` folder) - Examples testing (`examples` folder) - Platform testing: - Ubuntu 18.04 - Ubuntu 20.04 - MacOS Mojave (Xcode 11.3) - MacOS Catalina (Xcode 12) - Testing with `gcc` and `clang` under Ubuntu Co-authored-by: Flavio Bergamaschi <anadyomeni@gmx.com>
1 parent 1457255 commit 3100446

File tree

7 files changed

+238
-35
lines changed

7 files changed

+238
-35
lines changed

.travis.yml

+100-33
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,112 @@
1+
# Copyright (C) 2020 IBM Corp.
2+
# This program is Licensed under the Apache License, Version 2.0
3+
# (the "License"); you may not use this file except in compliance
4+
# with the License. You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License. See accompanying LICENSE file.
11+
112
language: cpp
213
notifications:
314
email: false
4-
sudo: required
515

616
branches:
717
only:
818
- master
919

10-
before_script:
11-
#
12-
- curl -O "https://www.shoup.net/ntl/ntl-11.4.3.tar.gz"
13-
- tar --no-same-owner -xf ntl-11.4.3.tar.gz
14-
- cd ntl-11.4.3/src
15-
- ./configure PREFIX=~/ntl SHARED=on NTL_GMP_LIP=on NTL_THREADS=on NTL_THREAD_BOOST=on
16-
- make -j4
17-
- make install
18-
- cd ../..
19-
20-
# Build Folder
21-
#
22-
- mkdir build
23-
- cd build
24-
25-
matrix:
20+
cache: ccache
21+
22+
jobs:
2623
include:
27-
- os: linux
28-
dist: bionic
29-
env:
30-
- TEST="Build test"
31-
addons:
32-
apt:
33-
sources:
34-
- ubuntu-toolchain-r-test
35-
packages:
36-
- gcc
37-
- g++
38-
- m4
39-
- patchelf
24+
- name: "Ubuntu 18.04 lib build gcc"
25+
os: linux
26+
dist: bionic
27+
compiler: gcc
28+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
29+
- name: "Ubuntu 20.04 lib build gcc"
30+
os: linux
31+
dist: focal
32+
compiler: gcc
33+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
34+
- name: "Ubuntu 18.04 lib build clang"
35+
os: linux
36+
dist: bionic
37+
compiler: clang
38+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
39+
- name: "Ubuntu 20.04 lib build clang"
40+
os: linux
41+
dist: focal
42+
compiler: clang
43+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
44+
- name: "Ubuntu 18.04 package build gcc"
45+
os: linux
46+
dist: bionic
47+
compiler: gcc
48+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
49+
- name: "Ubuntu 20.04 package build gcc"
50+
os: linux
51+
dist: focal
52+
compiler: gcc
53+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
54+
- name: "Ubuntu 18.04 package build clang"
55+
os: linux
56+
dist: bionic
57+
compiler: clang
58+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
59+
- name: "Ubuntu 20.04 package build clang"
60+
os: linux
61+
dist: focal
62+
compiler: clang
63+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
64+
- name: "MacOS Mojave lib build"
65+
os: osx
66+
osx_image: xcode11.3
67+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
68+
- name: "MacOS Mojave package build"
69+
os: osx
70+
osx_image: xcode11.3
71+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
72+
- name: "MacOS Catalina lib build"
73+
os: osx
74+
osx_image: xcode12
75+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=OFF
76+
- name: "MacOS Catalina package build"
77+
os: osx
78+
osx_image: xcode12
79+
env: INSTALL_PREFIX="~/helib_install" PACKAGE_BUILD=ON
80+
81+
82+
addons:
83+
apt:
84+
packages:
85+
- g++
86+
- clang
87+
- patchelf
88+
- cmake
89+
- bats
90+
update: true
91+
homebrew:
92+
packages:
93+
- cmake
94+
- bats-core
95+
- ccache
96+
update: true
4097

98+
# activating ccache on MacOS.
99+
before_install:
100+
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
101+
export PATH="/usr/local/opt/ccache/libexec:$PATH";
102+
fi
103+
104+
install:
105+
- ./ci/install_deps.sh
41106

42107
script:
43-
- cmake -DPACKAGE_BUILD=OFF -DNTL_DIR="/home/travis/ntl/" -DENABLE_TEST=ON ..
44-
- make -j4
45-
- ctest -j4
108+
- ./ci/build_install_lib.sh "${PACKAGE_BUILD}" "${INSTALL_PREFIX}"
109+
- ./ci/test_lib.sh
110+
- ./ci/build_test_consumer.sh "examples" "${PACKAGE_BUILD}" "${INSTALL_PREFIX}"
111+
- ./ci/build_test_consumer.sh "utils" "${PACKAGE_BUILD}" "${INSTALL_PREFIX}"
112+

ci/build_install_lib.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2020 IBM Corp.
4+
# This program is Licensed under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License. See accompanying LICENSE file.
13+
14+
set -xe
15+
16+
if [ "$#" -ne 2 ]; then
17+
echo "Wrong parameter number. Usage ./${0} <PACKAGE_BUILD> <CMAKE_INSTALL_PREFIX>"
18+
exit 1
19+
fi
20+
21+
PACKAGE_BUILD="${1}"
22+
CMAKE_INSTALL_PREFIX="${2}"
23+
ROOT_DIR="$(pwd)"
24+
25+
mkdir build
26+
cd build
27+
# We assume PACKAGE_BUILD argument to be a valid cmake option
28+
cmake -DPACKAGE_BUILD="${PACKAGE_BUILD}" -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -DBUILD_SHARED=ON -DENABLE_TEST=ON -DTARGET_ARCHITECTURE=x86-64 ..
29+
make -j4 VERBOSE=1
30+
make install
31+
cd "${ROOT_DIR}"

ci/build_test_consumer.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2020 IBM Corp.
4+
# This program is Licensed under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License. See accompanying LICENSE file.
13+
14+
set -xe
15+
16+
if [ "$#" -ne 3 ]; then
17+
echo "Wrong parameter number. Usage ./${0} <CONSUMER_FOLDER> <PACKAGE_BUILD> <CMAKE_INSTALL_PREFIX>"
18+
exit 1
19+
fi
20+
21+
CONSUMER_FOLDER="${1}"
22+
PACKAGE_BUILD="${2}"
23+
CMAKE_INSTALL_PREFIX="${3}"
24+
ROOT_DIR="$(pwd)"
25+
26+
cd "${ROOT_DIR}/${CONSUMER_FOLDER}"
27+
mkdir build
28+
cd build
29+
30+
# This test is quite brittle, but we can assume PACKAGE_BUILD is ON or OFF
31+
if [ "${PACKAGE_BUILD}" == "ON" ]; then
32+
CMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}/helib_pack"
33+
fi
34+
35+
cmake -Dhelib_DIR="${CMAKE_INSTALL_PREFIX}/share/cmake/helib" ..
36+
make -j4 VERBOSE=1
37+
cd "${ROOT_DIR}/${CONSUMER_FOLDER}/tests"
38+
bats -t .
39+
40+
cd "${ROOT_DIR}"

ci/install_deps.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2020 IBM Corp.
4+
# This program is Licensed under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License. See accompanying LICENSE file.
13+
14+
set -xe
15+
16+
cd $HOME
17+
18+
if [ "${PACKAGE_BUILD}" == "OFF" ]; then
19+
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
20+
if [ "${TRAVIS_DIST}" == "bionic" ]; then
21+
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install m4 libgmp-dev
22+
curl -O "https://www.shoup.net/ntl/ntl-11.4.3.tar.gz"
23+
tar --no-same-owner -xf ntl-11.4.3.tar.gz
24+
cd "$HOME/ntl-11.4.3/src"
25+
./configure SHARED=on NTL_GMP_LIP=on NTL_THREADS=on NTL_THREAD_BOOST=on
26+
make -j4
27+
sudo make install
28+
else
29+
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install libgmp-dev libntl-dev
30+
fi
31+
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
32+
# GMP will be installed as a dependency to NTL (if it is not already present)
33+
brew install ntl
34+
fi
35+
else
36+
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
37+
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install patchelf m4
38+
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
39+
brew install m4
40+
fi
41+
fi
42+
43+
cd "$HOME"

ci/test_lib.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2020 IBM Corp.
4+
# This program is Licensed under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License. See accompanying LICENSE file.
13+
14+
set -xe
15+
16+
ROOT_DIR="$(pwd)"
17+
18+
cd "${ROOT_DIR}/build"
19+
20+
ctest --output-on-failure -j4
21+
22+
cd "${ROOT_DIR}"

examples/tests/std.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
function random-char-string {
1313
local N=${1:-8}
14-
echo $(head /dev/urandom | LC_CTYPE=C tr -dc A-Za-z0-9 | head -c $N)
14+
echo $(head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9 | head -c $N)
1515
}
1616

1717
tmp_folder="tmp_$(random-char-string)"

utils/tests/std.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
function random-char-string {
1313
local N=${1:-8}
14-
echo $(head /dev/urandom | LC_CTYPE=C tr -dc A-Za-z0-9 | head -c $N)
14+
echo $(head /dev/urandom | LC_ALL=C tr -dc A-Za-z0-9 | head -c $N)
1515
}
1616

1717
utils_dir=${utils_dir:-"../.."}

0 commit comments

Comments
 (0)