From d837a23cab4244cd25a20424d47acccc29eb1ee8 Mon Sep 17 00:00:00 2001 From: Alok Bhatt Date: Fri, 13 Nov 2020 22:54:17 +0000 Subject: [PATCH] Static code analysis for ric-plt-utils This change adds the job to trigger sonar scans on the ric-plt-utils repo. Issue-Id: 694 Signed-off-by: Alok Bhatt Change-Id: Iaaebc0077a3cbaf19e3609505e7a4eea483f5e75 --- jjb/ric-plt-utils/Dockerfile.build | 83 ++++++++++++++++++++++++++++++ jjb/ric-plt-utils/cmake-sonarqube.sh | 17 +++++++ jjb/ric-plt-utils/ric-plt-utils.yaml | 98 +++++++++++++++++++++++++++++++++++- 3 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 jjb/ric-plt-utils/Dockerfile.build create mode 100644 jjb/ric-plt-utils/cmake-sonarqube.sh diff --git a/jjb/ric-plt-utils/Dockerfile.build b/jjb/ric-plt-utils/Dockerfile.build new file mode 100644 index 00000000..387bef39 --- /dev/null +++ b/jjb/ric-plt-utils/Dockerfile.build @@ -0,0 +1,83 @@ +# vi: ts=4 sw=4 noet: + +#================================================================================== +# Copyright (c) 2020 AT&T Intellectual Property. +# Copyright (c) 2020 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. +#================================================================================== + +# Build the munchkin container assuming that the current working directory is the +# top of the munchkin portion of the shared repo. + +# ---- these are global and must be set before the first from directive +# +# package versions and locations for easier maintenance +ARG RMR_VER=4.1.4 +ARG LOG_VER=0.0.4 +ARG FRAME_VER=2.2.0 + +ARG PROD_URL_BASE=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/ +ARG BETA_URL_BASE=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/ + +ARG LOG_BASE=${PROD_URL_BASE} +ARG RMR_BASE=${BETA_URL_BASE} +ARG FRAME_BASE=${BETA_URL_BASE} + + +# ----------------------------------------------------------------------------------------------------- +FROM ubuntu:18.04 + +RUN apt-get update \ + && apt-get install -y git cmake make g++ wget curl libcurl4-gnutls-dev libcurlpp-dev libcurlpp0 + + +# sadly they need to be 'touched' to pull them into each stage +ARG RMR_VER +ARG LOG_VER +ARG FRAME_VER +ARG FRAME_BASE +ARG RMR_BASE +ARG LOG_BASE + +WORKDIR /playpen/down + +RUN wget --content-disposition ${LOG_BASE}/mdclog_${LOG_VER}-1_amd64.deb/download.deb \ + && wget --content-disposition ${LOG_BASE}/mdclog-dev_${LOG_VER}-1_amd64.deb/download.deb \ + && wget --content-disposition ${RMR_BASE}/rmr-dev_${RMR_VER}_amd64.deb/download.deb \ + && wget --content-disposition ${RMR_BASE}/rmr_${RMR_VER}_amd64.deb/download.deb \ + && wget --content-disposition ${FRAME_BASE}/ricxfcpp_${FRAME_VER}_amd64.deb/download.deb \ + && wget --content-disposition ${FRAME_BASE}/ricxfcpp-dev_${FRAME_VER}_amd64.deb/download.deb \ + && dpkg -i *deb + + + +WORKDIR /playpen/build +COPY ./ ./ + +# build the utility; installs into /usr/local/bin +# +RUN rm -fr .build \ + && mkdir .build \ + && cd .build \ + && cmake .. \ + && make install \ + && make test ARGS="-V" + + + +#RUN mkdir /var/mgxapp +#COPY xapp_config.json /var/mgxapp/config.json + +#WORKDIR /playpen +#CMD [ "munchkin", "-c", "/var/mgxapp/config.json" ] \ No newline at end of file diff --git a/jjb/ric-plt-utils/cmake-sonarqube.sh b/jjb/ric-plt-utils/cmake-sonarqube.sh new file mode 100644 index 00000000..891f1c3f --- /dev/null +++ b/jjb/ric-plt-utils/cmake-sonarqube.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2020 HCL Technologies and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## +echo "---> cmake-sonarqube.sh" +cd mgxapp +docker build -t ric-plt-utils -f Dockerfile.build . +docker create --name ric-plt-utils ric-plt-utils +docker cp ric-plt-utils:/playpen/build/test/ . +docker rm ric-plt-utils +echo "---> cmake-sonarqube.sh ends" \ No newline at end of file diff --git a/jjb/ric-plt-utils/ric-plt-utils.yaml b/jjb/ric-plt-utils/ric-plt-utils.yaml index 276db491..3735fc65 100644 --- a/jjb/ric-plt-utils/ric-plt-utils.yaml +++ b/jjb/ric-plt-utils/ric-plt-utils.yaml @@ -7,8 +7,104 @@ - project: name: ric-plt-utils-info - project: ric-plt/utils + project: ric-plt-utils project-name: ric-plt-utils build-node: centos7-builder-1c-1g jobs: - gerrit-info-yaml-verify + +- utils_common: &utils_common + name: utils-common + # git repo + project: ric-plt/utils + # jenkins job name prefix + project-name: ric-plt-utils + # maven settings file has credentials to archive artifacts + mvn-settings: ric-plt-utils-settings + # test scripts depend on this name + build-dir: $WORKSPACE/mgxapp/build + # Use ubuntu base for cmake v3 + # Use docker variant for packagecloud ruby gem + build-node: ubuntu1804-docker-4c-4g + # pre-build scripts for CMake templates: + # install alien package to build RPMS + # install RMR per version file in repo + pre-build: !include-raw-escape: + - ../shell/install-deb-alien.sh + - ./cmake-sonarqube.sh + # skip install in cmake-build.sh + install: false + +# verify every commit +- project: + <<: *utils_common + name: utils-verify + cmake-opts: -DDEV_PKG=1 + make-opts: package test ARGS=-V + jobs: + - gerrit-cmake-verify + stream: + - master: + branch: master + +# development library - package and publish +- project: + <<: *utils_common + name: ric-plt-utils-dev + project-name: '{name}' + cmake-opts: -DDEV_PKG=1 + make-opts: package + install-prefix: /usr/local + jobs: + - gerrit-cmake-packagecloud-stage + stream: + - master: + branch: master + +# runtime library - package and publish +- project: + <<: *utils_common + name: ric-plt-utils-rt + project-name: '{name}' + cmake-opts: -DDEV_PKG=0 + make-opts: package + install-prefix: /usr/local + jobs: + - gerrit-cmake-packagecloud-stage + stream: + - master: + branch: master + +# promote deb/rpm from staging to release at PackageCloud.io +- project: + <<: *utils_common + name: ric-plt-utils-release + # release uses sigul which requires centos + build-node: centos7-builder-1c-1g + jobs: + - gerrit-packagecloud-release-verify + - gerrit-packagecloud-release-merge + +# analyze C code and test coverage +- project: + name: utils-sonarqube + <<: *utils_common + make-opts: test ARGS=-V + sonar-project-file: "" + sonar-properties: | + sonar.login={sonarcloud_api_token} + sonar.projectKey={sonarcloud_project_organization}_{project-name} + sonar.projectName={project-name} + sonar.organization={sonarcloud_project_organization} + sonar.scanner.force-deprecated-java-version=true + sonar.build.sourceEncoding=UTF-8 + sonar.sources=mgxapp/src + sonar.cfamily.threads=4 + sonar.cfamily.cache.enabled=false + sonar.cfamily.build-wrapper-output=$WORKSPACE/bw-output + sonar.cfamily.gcov.reportsPath=test + sonar.c.file.suffixes=- + sonar.cpp.file.suffixes=- + sonar.objc.file.suffixes=- + jobs: + - gerrit-cmake-sonarqube -- 2.16.6