Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 2 | |
| 3 | # ================================================================================ |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 4 | # Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 5 | # ================================================================================ |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 6 | # 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 Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 11 | # |
| 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 Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 17 | # ============LICENSE_END========================================================= |
| 18 | # |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 19 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 20 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 21 | set -ex |
| 22 | |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 23 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 24 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 25 | MVN_PROJECT_MODULEID="$1" |
| 26 | MVN_PHASE="$2" |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 27 | PROJECT_ROOT=$(dirname $0) |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 28 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 29 | |
Lusheng Ji | 937f02f | 2018-03-23 13:30:20 -0400 | [diff] [blame] | 30 | echo "MVN_RELEASE_TAG is set to [$MVN_RELEASE_TAG]" |
vv770d | f35d2f0 | 2020-10-01 21:26:18 +0000 | [diff] [blame] | 31 | RELEASE_TAG=${MVN_RELEASE_TAG:-R8} |
Lusheng Ji | 937f02f | 2018-03-23 13:30:20 -0400 | [diff] [blame] | 32 | if [ "$RELEASE_TAG" != "R1" ]; then |
| 33 | RELEASE_TAGGED_DIR="${RELEASE_TAG}/" |
| 34 | else |
| 35 | RELEASE_TAGGED_DIR="" |
| 36 | fi |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 37 | if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \ |
Lusheng Ji | 937f02f | 2018-03-23 13:30:20 -0400 | [diff] [blame] | 38 | "$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 Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 41 | fi |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 42 | source "${PROJECT_ROOT}"/mvn-phase-lib.sh |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 43 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 44 | |
| 45 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 46 | export BUILD_NUMBER="${TIMESTAMP}" |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 47 | shift 2 |
| 48 | |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 49 | case $MVN_PHASE in |
| 50 | clean) |
| 51 | echo "==> clean phase script" |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 52 | clean_templated_files |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 53 | clean_tox_files |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 54 | rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 55 | ;; |
| 56 | generate-sources) |
| 57 | echo "==> generate-sources phase script" |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 58 | expand_templates |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 59 | ;; |
| 60 | compile) |
| 61 | echo "==> compile phase script" |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 62 | ;; |
| 63 | test) |
| 64 | echo "==> test phase script" |
cluckenbaugh | fffe41c | 2021-02-11 18:26:30 -0500 | [diff] [blame^] | 65 | 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 Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 86 | ;; |
| 87 | package) |
| 88 | echo "==> package phase script" |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 89 | ;; |
| 90 | install) |
| 91 | echo "==> install phase script" |
Lusheng Ji | f7e6476 | 2017-10-12 05:16:59 +0000 | [diff] [blame] | 92 | case $MVN_PROJECT_MODULEID in |
| 93 | bootstrap) |
| 94 | upload_files_of_extension sh |
| 95 | ;; |
| 96 | esac |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 97 | ;; |
| 98 | deploy) |
| 99 | echo "==> deploy phase script" |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 100 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 101 | case $MVN_PROJECT_MODULEID in |
| 102 | bootstrap) |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 103 | # build docker image from Docker file (under module dir) and push to registry |
Lusheng Ji | f7e6476 | 2017-10-12 05:16:59 +0000 | [diff] [blame] | 104 | upload_files_of_extension sh |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 105 | build_and_push_docker |
| 106 | ;; |
Jack Lucas | 5fe1308 | 2020-02-07 15:45:42 -0500 | [diff] [blame] | 107 | 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 Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 108 | build_and_push_docker |
| 109 | ;; |
Lusheng Ji | 6c11793 | 2018-04-03 15:07:58 -0400 | [diff] [blame] | 110 | scripts|cloud_init|heat) |
Julien Barbot | bfa1bbe | 2018-08-20 18:42:48 +0200 | [diff] [blame] | 111 | # upload all sh file under the root of module |
Lusheng Ji | 6c11793 | 2018-04-03 15:07:58 -0400 | [diff] [blame] | 112 | 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 Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 115 | ;; |
| 116 | *) |
| 117 | echo "====> unknown mvn project module" |
| 118 | ;; |
| 119 | esac |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 120 | ;; |
| 121 | *) |
| 122 | echo "==> unprocessed phase" |
| 123 | ;; |
| 124 | esac |
| 125 | |