blob: 71df21a8e4cbdb5e181745c0bc4c3fc7db22849b [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
102 bootstrap)
Lusheng Ji5e111842017-09-11 23:01:37 +0000103 # build docker image from Docker file (under module dir) and push to registry
Lusheng Jif7e64762017-10-12 05:16:59 +0000104 upload_files_of_extension sh
Lusheng Jic38ca2f2017-09-11 20:11:29 +0000105 build_and_push_docker
106 ;;
Jack Lucas5fe13082020-02-07 15:45:42 -0500107 tca-cdap-container|cm-container|redis-cluster-container|healthcheck-container|pnda-mirror-container|pnda-bootstrap-container|tls-init-container|consul-loader-container|multisite-init-container|dcae-k8s-cleanup-container)
Lusheng Ji6d381a52018-03-22 14:27:41 -0400108 build_and_push_docker
109 ;;
Lusheng Ji6c117932018-04-03 15:07:58 -0400110 scripts|cloud_init|heat)
Julien Barbotbfa1bbe2018-08-20 18:42:48 +0200111 # upload all sh file under the root of module
Lusheng Ji6c117932018-04-03 15:07:58 -0400112 upload_files_of_extension_recursively sh $MVN_PROJECT_MODULEID
113 upload_files_of_extension_recursively py $MVN_PROJECT_MODULEID
114 upload_files_of_extension_recursively yaml $MVN_PROJECT_MODULEID
Lusheng Jic38ca2f2017-09-11 20:11:29 +0000115 ;;
116 *)
117 echo "====> unknown mvn project module"
118 ;;
119 esac
Andrew Gauldb34cbd02017-08-24 16:46:17 -0400120 ;;
121*)
122 echo "==> unprocessed phase"
123 ;;
124esac
125