From 9075724f37d63fd9b6cca5bc185a22ae13c9d1d0 Mon Sep 17 00:00:00 2001 From: Roni Riska Date: Thu, 15 Aug 2019 10:21:49 +0300 Subject: [PATCH] CI build support The CI Docker file runs unit tests and builds the binary packages of tracelibcpp and opentracing-cpp. Change-Id: I8f4d6e7db08b890ba8bfc5d5594a4a1cb7cb279f Signed-off-by: Roni Riska --- .gitreview | 6 ++++++ CMakeLists.txt | 30 +++++++++++++++++++++++++++++- ci/Dockerfile | 35 +++++++++++++++++++++++++++++++++++ ci/build_opentracing.sh | 30 ++++++++++++++++++++++++++++++ ci/ci_build.sh | 30 ++++++++++++++++++++++++++++++ ci/publish.sh | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 .gitreview create mode 100644 ci/Dockerfile create mode 100755 ci/build_opentracing.sh create mode 100755 ci/ci_build.sh create mode 100755 ci/publish.sh diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..99ac43c --- /dev/null +++ b/.gitreview @@ -0,0 +1,6 @@ +[gerrit] +host=gerrit.o-ran-sc.org +port=29418 +project=ric-plt/tracelibcpp.git +defaultbranch=master + diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c5ad29..a3b0e0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,38 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cxx1.cmake) set (tracelibcpp_VERSION_MAJOR "0") set (tracelibcpp_VERSION_MINOR "0") -set (tracelibcpp_VERSION_MICRO "1") +set (tracelibcpp_VERSION_MICRO "2") set (tracelibcpp_VERSION_STRING "${tracelibcpp_VERSION_MAJOR}.${tracelibcpp_VERSION_MINOR}.${tracelibcpp_VERSION_MICRO}") +# Set up cpack +# Common +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++ implementation RIC tracing initialization") +set(CPACK_PACKAGE_VENDOR "Nokia") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_PACKAGE_VERSION_MAJOR ${tracelibcpp_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${tracelibcpp_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${tracelibcpp_VERSION_MICRO}) +set(CPACK_COMPONENTS_ALL DIST DEVEL) +set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP ) +set(CPACK_GENERATOR "RPM;DEB") +set(CPACK_COMPONENTS_IGNORE_GROUPS 1) +set(CPACK_PACKAGE_CONTACT None) + +# RPM +set(CPACK_RPM_COMPONENT_INSTALL ON) +set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") +set(CPACK_RPM_FILE_NAME RPM-DEFAULT) +set(CPACK_RPM_PACKAGE_AUTOREQ 1) + +# Debian +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEB_PACKAGE_COMPONENT ON) +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + +include(CPack) + # Add jaeger hunter_add_package(jaegertracing) find_package(jaegertracing CONFIG REQUIRED) diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..3a10250 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,35 @@ +# O-RAN-SC +# +# Copyright (C) 2019 AT&T Intellectual Property and Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# CI to verify the tracingcpp library +# Inherits C toolchain from buildpack-deps:stretch +# Adds required build tools + +FROM buildpack-deps:stretch + +RUN apt-get update && apt-get -q -y install \ + cmake \ + rpm \ + rename \ + alien + +RUN mkdir -p /tmp/build +COPY . /tmp/build +RUN cd /tmp/build && ci/ci_build.sh + +RUN cd /tmp/build && ci/build_opentracing.sh + +ENTRYPOINT ["/tmp/build/ci/publish.sh"] diff --git a/ci/build_opentracing.sh b/ci/build_opentracing.sh new file mode 100755 index 0000000..b2a5753 --- /dev/null +++ b/ci/build_opentracing.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2018-2019 Nokia. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -e + +REL=1.5.0 + +wget https://github.com/opentracing/opentracing-cpp/archive/v$REL.tar.gz -O opentracing-cpp-$REL.tar.gz +tar zxf opentracing-cpp-$REL.tar.gz +cd opentracing-cpp-$REL + +cmake . +make package +cpack -G RPM -D CPACK_RPM_FILE_NAME=RPM-DEFAULT +alien opentracing-cpp-$REL-1.x86_64.rpm --keep-version +mv *.rpm *.deb .. diff --git a/ci/ci_build.sh b/ci/ci_build.sh new file mode 100755 index 0000000..5caa2b8 --- /dev/null +++ b/ci/ci_build.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2018-2019 Nokia. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +# UT +cmake -DWITH_TESTING=ON -DHUNTER_JOBS_NUMBER=3 . +make && make test + +# Build packages +make package +# Do small renames +rename 's/-DEVEL/-devel/' *.rpm +rename 's/-DIST//' *.rpm +rename 's/-devel/-dev/' *.deb +rename 's/-dist//' *.deb diff --git a/ci/publish.sh b/ci/publish.sh new file mode 100755 index 0000000..3854617 --- /dev/null +++ b/ci/publish.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2018-2019 Nokia. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +echo "$0: start copying packages" + +TARGET=/export +if [ $# -eq 1 ] +then + TARGET=$1 +fi + +if [ ! -d "$TARGET" ] +then + echo "$0: Error: target dir $TARGET does not exist" + exit 1 +fi + +cp -v /tmp/build/*.rpm /tmp/build/*.deb "$TARGET" -- 2.16.6