blob: a18f351b83c78708b04da976edaffb31288d39c5 [file] [log] [blame]
Mohamed Abukarebe58c22020-03-13 14:40:47 +02001#!/bin/bash
2
3#==================================================================================
4# Copyright (c) 2020 AT&T Intellectual Property.
5# Copyright (c) 2020 Nokia
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#==================================================================================
19
Anssi Mannila43fe17e2020-11-05 14:06:54 +020020#set -eux
Mohamed Abukarebe58c22020-03-13 14:40:47 +020021
Abukar Mohamed121e8b62020-09-18 11:41:33 +000022echo "--> build_ubuntu.sh starts"
Mohamed Abukarebe58c22020-03-13 14:40:47 +020023
24# Install RMR from deb packages at packagecloud.io
czichy32e16bb2023-12-13 12:22:53 +020025rmr=rmr_4.9.4_amd64.deb
wahidw2a5ec392020-12-08 06:30:32 +000026wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmr/download.deb
Mohamed Abukarebe58c22020-03-13 14:40:47 +020027sudo dpkg -i $rmr
28rm $rmr
czichy32e16bb2023-12-13 12:22:53 +020029rmrdev=rmr-dev_4.9.4_amd64.deb
wahidw2a5ec392020-12-08 06:30:32 +000030wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmrdev/download.deb
Mohamed Abukarebe58c22020-03-13 14:40:47 +020031sudo dpkg -i $rmrdev
32rm $rmrdev
33
34# Required to find nng and rmr libs
35export LD_LIBRARY_PATH=/usr/local/lib
36
manoj114025252021-10-29 13:05:57 +000037# Installing the go version
Juha Hyttinen5f9b88b2023-06-02 10:04:15 +030038GOLANG_VERSION=1.20.4
manoj114025252021-10-29 13:05:57 +000039wget --quiet https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz \
40 && tar xvzf go$GOLANG_VERSION.linux-amd64.tar.gz -C /usr/local
41PATH="/usr/local/go/bin:${PATH}"
42GOPATH="/go"
43rm go$GOLANG_VERSION.linux-amd64.tar.gz
44
45
Mohamed Abukarebe58c22020-03-13 14:40:47 +020046# Go install, build, etc
47export GOPATH=$HOME/go
48export PATH=$GOPATH/bin:$PATH
49
50# xApp-framework stuff
51export CFG_FILE=../config/config-file.json
52export RMR_SEED_RT=../config/uta_rtg.rt
53
vipin14323a92020-09-25 10:03:43 +000054# xApp stuff
Anssi Mannila43fe17e2020-11-05 14:06:54 +020055export DEF_FILE=../../definitions/alarm-definition.json
Anssi Mannila00894a42020-10-19 11:36:26 +030056export PERF_DEF_FILE=../testresources/perf-alarm-definition.json
57export PERF_OBJ_FILE=../testresources/perf-alarm-object.json
vipin14323a92020-09-25 10:03:43 +000058
Mohamed Abukarebe58c22020-03-13 14:40:47 +020059GO111MODULE=on GO_ENABLED=0 GOOS=linux
60
61# setup version tag
Mohamed Abukar3649fae2020-10-30 23:51:39 +020062if [ -f build/container-tag.yaml ]
Mohamed Abukarebe58c22020-03-13 14:40:47 +020063then
Mohamed Abukar3649fae2020-10-30 23:51:39 +020064 tag=$(grep "tag:" build/container-tag.yaml | awk '{print $2}')
Mohamed Abukarebe58c22020-03-13 14:40:47 +020065else
66 tag="no-tag-found"
67fi
68
69hash=$(git rev-parse --short HEAD || true)
70
Abukar Mohamed121e8b62020-09-18 11:41:33 +000071ROOT_DIR=$PWD
72
Anssi Mannila00894a42020-10-19 11:36:26 +030073# compile the CLI
74cd ${ROOT_DIR}/cli && go build -a -installsuffix cgo alarm-cli.go
75
Mohamed Abukarebe58c22020-03-13 14:40:47 +020076# Build
Abukar Mohamed121e8b62020-09-18 11:41:33 +000077cd ${ROOT_DIR}/manager && go build -a -installsuffix cgo -ldflags "-X main.Version=$tag -X main.Hash=$hash" -o alarm-manager ./cmd/*.go
Mohamed Abukarebe58c22020-03-13 14:40:47 +020078
79# Execute UT and measure coverage for the Alarm Library
Abukar Mohamed121e8b62020-09-18 11:41:33 +000080cd ${ROOT_DIR}/alarm && go test . -v -coverprofile cover.out
Mohamed Abukarebe58c22020-03-13 14:40:47 +020081
Anssi Mannila43fe17e2020-11-05 14:06:54 +020082# Copy alarm/cover.out to alarm-go/cover.out
83cd ${ROOT_DIR} && cat alarm/cover.out > coverage.out
84
Abukar Mohamed121e8b62020-09-18 11:41:33 +000085# And for the Alarm Manager
Anssi Mannila43fe17e2020-11-05 14:06:54 +020086#cd ${ROOT_DIR}/manager && go test -v -p 1 -coverprofile cover.out ./cmd/ -c -o ./manager_test && ./manager_test
87cd ${ROOT_DIR}/manager && GO111MODULE=on RMR_SEED_RT=../../config/uta_rtg.rt CFG_FILE=../../config/config-file.json go test -v -p 1 -cover -coverprofile=cover.out ./...
88
89# Remove first line of the manager/cover.out and append to alarm-go/coverity.out
90cd ${ROOT_DIR} && sed '1d' manager/cover.out >> coverage.out
91
92cd ${ROOT_DIR} && GO111MODULE=on go tool cover -html=coverage.out -o coverage.html
Mohamed Abukarebe58c22020-03-13 14:40:47 +020093
Abukar Mohamed121e8b62020-09-18 11:41:33 +000094echo "--> build_ubuntu.sh ends"