Bin Sun | 7245fce | 2018-03-09 10:20:17 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2018 VMware Corporation. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
| 17 | set -e |
| 18 | |
| 19 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 20 | |
| 21 | export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml} |
| 22 | MVN_PROJECT_MODULEID="$1" |
| 23 | MVN_PHASE="$2" |
| 24 | |
| 25 | |
| 26 | FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" |
| 27 | if [ "$MVN_PROJECT_MODULEID" == "__" ]; then |
| 28 | MVN_PROJECT_MODULEID="" |
| 29 | fi |
| 30 | |
| 31 | if [ -z "$WORKSPACE" ]; then |
| 32 | WORKSPACE=$(pwd) |
| 33 | fi |
| 34 | |
| 35 | # mvn phase in life cycle |
| 36 | MVN_PHASE="$2" |
| 37 | |
| 38 | |
| 39 | echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" |
| 40 | echo "MVN_PHASE is [$MVN_PHASE]" |
| 41 | echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" |
| 42 | echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" |
| 43 | echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" |
| 44 | |
| 45 | run_tox_test() |
| 46 | { |
| 47 | set -x |
| 48 | CURDIR=$(pwd) |
| 49 | TOXINIS=$(find . -name "tox.ini") |
| 50 | for TOXINI in "${TOXINIS[@]}"; do |
| 51 | DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev) |
| 52 | cd "${CURDIR}/${DIR}" |
| 53 | rm -rf ./venv-tox ./.tox |
Bin Yang | aa74454 | 2019-08-21 04:15:42 +0000 | [diff] [blame] | 54 | virtualenv ./venv-tox --python=python3 |
Bin Sun | 7245fce | 2018-03-09 10:20:17 +0800 | [diff] [blame] | 55 | source ./venv-tox/bin/activate |
| 56 | pip install --upgrade pip |
| 57 | pip install --upgrade tox argparse |
| 58 | pip freeze |
liboNet | efb2229 | 2019-03-20 03:10:03 +0800 | [diff] [blame] | 59 | cd ${CURDIR} |
Bin Sun | 7245fce | 2018-03-09 10:20:17 +0800 | [diff] [blame] | 60 | tox -e cover |
| 61 | deactivate |
| 62 | cd .. |
| 63 | rm -rf ./venv-tox ./.tox |
| 64 | done |
| 65 | } |
| 66 | |
| 67 | |
| 68 | case $MVN_PHASE in |
| 69 | clean) |
| 70 | echo "==> clean phase script" |
| 71 | rm -rf ./venv-* |
| 72 | ;; |
| 73 | test) |
| 74 | echo "==> test phase script" |
| 75 | run_tox_test |
| 76 | ;; |
| 77 | *) |
| 78 | echo "==> unprocessed phase" |
| 79 | ;; |
| 80 | esac |
| 81 | |