Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 1 | #! /usr/bin/env bash |
| 2 | |
| 3 | # COPYRIGHT NOTICE STARTS HERE |
| 4 | |
Bartek Grzybowski | cecf6cf | 2021-04-08 16:18:43 +0200 | [diff] [blame] | 5 | # Copyright 2019-2021 © Samsung Electronics Co., Ltd. |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 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 | # COPYRIGHT NOTICE ENDS HERE |
| 20 | |
| 21 | # |
Bartek Grzybowski | cb3f68d | 2020-01-16 09:24:46 +0100 | [diff] [blame] | 22 | # This is a main wrapper script to run Molecule tests. |
| 23 | # Main usage is for the CI to keep interface stable and the way to call |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 24 | # Molecule can be adjusted in this script independently. |
| 25 | # |
| 26 | |
Mateusz Pilat | 9c9be6f | 2019-05-06 17:12:36 +0200 | [diff] [blame] | 27 | set -e |
| 28 | |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 29 | SCRIPT_DIR=$(dirname "${0}") |
| 30 | LOCAL_PATH=$(readlink -f "$SCRIPT_DIR") |
| 31 | |
| 32 | ROLE_PATH=$1 |
Mateusz Pilat | b0f546a | 2019-05-08 13:33:46 +0200 | [diff] [blame] | 33 | MOLECULE_CONTAINER=${MOLECULE_CONTAINER:-false} |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 34 | |
| 35 | echo "Build all pre-build images" |
Mateusz Pilat | f030b06 | 2020-05-20 14:58:50 +0200 | [diff] [blame] | 36 | ${LOCAL_PATH}/../images/docker/build-all.sh > image_build.log |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 37 | |
| 38 | # Use Molecule container |
| 39 | if [ "${MOLECULE_CONTAINER}" == "true" ]; then |
| 40 | echo "Build Molecule-dev docker container" |
| 41 | ${LOCAL_PATH}/../molecule-docker/build.sh |
| 42 | MOLECULE_BINARY=${LOCAL_PATH}/../bin/molecule.sh |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 43 | else # Install Molecule natively in the target platform |
| 44 | echo "Install Molecule with virtualenv" |
| 45 | source ${LOCAL_PATH}/../bin/install-molecule.sh |
Bartek Grzybowski | cecf6cf | 2021-04-08 16:18:43 +0200 | [diff] [blame] | 46 | MOLECULE_BINARY="molecule --version" |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 47 | fi |
| 48 | |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 49 | cd ${ROLE_PATH} |
Mateusz Pilat | 9c9be6f | 2019-05-06 17:12:36 +0200 | [diff] [blame] | 50 | ${MOLECULE_BINARY} --version |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 51 | ${MOLECULE_BINARY} test --all |
Bartek Grzybowski | cb3f68d | 2020-01-16 09:24:46 +0100 | [diff] [blame] | 52 | docker volume prune --force |
Samuli Silvius | cceed25 | 2019-04-16 15:41:26 +0300 | [diff] [blame] | 53 | cd - |