blob: 87974335460524fd9b3b714d4f422df3c12a83d9 [file] [log] [blame]
Andrew Gauldb34cbd02017-08-24 16:46:17 -04001#!/bin/bash
Lusheng Jic38ca2f2017-09-11 20:11:29 +00002
3# ================================================================================
Lusheng Ji6d381a52018-03-22 14:27:41 -04004# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
Lusheng Jic38ca2f2017-09-11 20:11:29 +00005# ================================================================================
Andrew Gauldb34cbd02017-08-24 16:46:17 -04006# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
Lusheng Jic38ca2f2017-09-11 20:11:29 +000010# http://www.apache.org/licenses/LICENSE-2.0
Andrew Gauldb34cbd02017-08-24 16:46:17 -040011#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
Lusheng Jic38ca2f2017-09-11 20:11:29 +000017# ============LICENSE_END=========================================================
18#
Lusheng Jic38ca2f2017-09-11 20:11:29 +000019
Lusheng Jid92d4482017-09-21 05:42:28 +000020
Lusheng Jic38ca2f2017-09-11 20:11:29 +000021set -ex
22
Andrew Gauldb34cbd02017-08-24 16:46:17 -040023echo "running script: [$0] for module [$1] at stage [$2]"
24
Lusheng Jic38ca2f2017-09-11 20:11:29 +000025MVN_PROJECT_MODULEID="$1"
26MVN_PHASE="$2"
Lusheng Ji5e111842017-09-11 23:01:37 +000027PROJECT_ROOT=$(dirname $0)
Lusheng Jic38ca2f2017-09-11 20:11:29 +000028
Lusheng Jic38ca2f2017-09-11 20:11:29 +000029
Lusheng Ji937f02f2018-03-23 13:30:20 -040030echo "MVN_RELEASE_TAG is set to [$MVN_RELEASE_TAG]"
vv770df35d2f02020-10-01 21:26:18 +000031RELEASE_TAG=${MVN_RELEASE_TAG:-R8}
Lusheng Ji937f02f2018-03-23 13:30:20 -040032if [ "$RELEASE_TAG" != "R1" ]; then
33 RELEASE_TAGGED_DIR="${RELEASE_TAG}/"
34else
35 RELEASE_TAGGED_DIR=""
36fi
Lusheng Ji6d381a52018-03-22 14:27:41 -040037if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \
Lusheng Ji937f02f2018-03-23 13:30:20 -040038 "$MVN_RAWREPO_BASEURL_DOWNLOAD"/org.onap.dcaegen2.utils/${RELEASE_TAGGED_DIR}scripts/mvn-phase-lib.sh; then
39 echo "Fail to download mvn-phase-lib.sh"
40 exit 1
Lusheng Ji6d381a52018-03-22 14:27:41 -040041fi
Lusheng Ji5e111842017-09-11 23:01:37 +000042source "${PROJECT_ROOT}"/mvn-phase-lib.sh
Lusheng Jic38ca2f2017-09-11 20:11:29 +000043
Lusheng Jid92d4482017-09-21 05:42:28 +000044
45TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
46export BUILD_NUMBER="${TIMESTAMP}"
Lusheng Jid92d4482017-09-21 05:42:28 +000047shift 2
48
Andrew Gauldb34cbd02017-08-24 16:46:17 -040049case $MVN_PHASE in
50clean)
51 echo "==> clean phase script"
Lusheng Jic38ca2f2017-09-11 20:11:29 +000052 clean_templated_files
Lusheng Ji5e111842017-09-11 23:01:37 +000053 clean_tox_files
Lusheng Jid92d4482017-09-21 05:42:28 +000054 rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml
Andrew Gauldb34cbd02017-08-24 16:46:17 -040055 ;;
56generate-sources)
57 echo "==> generate-sources phase script"
Lusheng Jic38ca2f2017-09-11 20:11:29 +000058 expand_templates
Andrew Gauldb34cbd02017-08-24 16:46:17 -040059 ;;
60compile)
61 echo "==> compile phase script"
Andrew Gauldb34cbd02017-08-24 16:46:17 -040062 ;;
63test)
64 echo "==> test phase script"
cluckenbaughfffe41c2021-02-11 18:26:30 -050065 case $MVN_PROJECT_MODULEID in
66 dcae-services-policy-sync)
67 set -e -x
68 CURDIR=$(pwd)
69 TOXINIS=$(find . -name "tox.ini")
70 for TOXINI in "${TOXINIS[@]}"; do
71 DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev)
72 cd "${CURDIR}/${DIR}"
73 rm -rf ./venv-tox ./.tox
74 virtualenv ./venv-tox
75 source ./venv-tox/bin/activate
76 pip install pip==20.3.4
77 pip install --upgrade argparse
78 pip install tox
79 pip freeze
80 tox
81 deactivate
82 rm -rf ./venv-tox ./.tox
83 done
84 ;;
85 esac
Andrew Gauldb34cbd02017-08-24 16:46:17 -040086 ;;
87package)
88 echo "==> package phase script"
Andrew Gauldb34cbd02017-08-24 16:46:17 -040089 ;;
90install)
91 echo "==> install phase script"
Lusheng Jif7e64762017-10-12 05:16:59 +000092 case $MVN_PROJECT_MODULEID in
93 bootstrap)
94 upload_files_of_extension sh
95 ;;
96 esac
Andrew Gauldb34cbd02017-08-24 16:46:17 -040097 ;;
98deploy)
99 echo "==> deploy phase script"
Lusheng Ji5e111842017-09-11 23:01:37 +0000100
Lusheng Jic38ca2f2017-09-11 20:11:29 +0000101 case $MVN_PROJECT_MODULEID in
vv770d9d9a7f22021-02-20 01:08:58 +0000102 cm-container|healthcheck-container|tls-init-container|consul-loader-container|multisite-init-container|dcae-k8s-cleanup-container|dcae-services-policy-sync)
vv770dcfef2602021-02-20 02:46:28 +0000103 build_and_push_docker
Lusheng Jic38ca2f2017-09-11 20:11:29 +0000104 ;;
105 *)
106 echo "====> unknown mvn project module"
107 ;;
108 esac
Andrew Gauldb34cbd02017-08-24 16:46:17 -0400109 ;;
110*)
111 echo "==> unprocessed phase"
112 ;;
113esac
114