|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +VAGRANT_FOLDER="./tests/Acceptance/Vagrant" |
| 4 | + |
| 5 | +if [ $# -gt 0 ]; then |
| 6 | + |
| 7 | + # Spin up given development environment |
| 8 | + if [ "$1" == "up" ]; then |
| 9 | + cd "$VAGRANT_FOLDER/$2" && \ |
| 10 | + shift 2 && \ |
| 11 | + VALET_ENVIRONMENT=development vagrant up "$@" |
| 12 | + |
| 13 | + # SSH into the given development environment |
| 14 | + elif [ "$1" == "ssh" ]; then |
| 15 | + cd "$VAGRANT_FOLDER/$2" && \ |
| 16 | + shift 2 && \ |
| 17 | + vagrant ssh "$@" |
| 18 | + |
| 19 | + # Switch off given development environment |
| 20 | + elif [ "$1" == "down" ]; then |
| 21 | + cd "$VAGRANT_FOLDER/$2" && \ |
| 22 | + shift 2 && \ |
| 23 | + vagrant halt "$@" |
| 24 | + |
| 25 | + # Destroy given development environment |
| 26 | + elif [ "$1" == "destroy" ]; then |
| 27 | + cd "$VAGRANT_FOLDER/$2" && \ |
| 28 | + shift 2 && \ |
| 29 | + vagrant destroy "$@" |
| 30 | + |
| 31 | + # Destroy all development environments |
| 32 | + elif [ "$1" == "destroy-all" ]; then |
| 33 | + for DIRECTORY in `find $VAGRANT_FOLDER -maxdepth 1 -type d`; do |
| 34 | + if [[ "$DIRECTORY" != $VAGRANT_FOLDER ]]; then |
| 35 | + ./develop destroy ${DIRECTORY##*/} -f |
| 36 | + fi |
| 37 | + done |
| 38 | + |
| 39 | + # Run Acceptance tests against given environment |
| 40 | + elif [ "$1" == "test" ]; then |
| 41 | + ./develop up $2 && \ |
| 42 | + ./develop ssh $2 --command "bash ~/cpriego-valet-linux/tests/Acceptance/vagrant.sh" |
| 43 | + |
| 44 | + # Run Acceptance tests against ALL environments |
| 45 | + elif [ "$1" == "test-all" ]; then |
| 46 | + for DIRECTORY in `find $VAGRANT_FOLDER -maxdepth 1 -type d`; do |
| 47 | + if [[ "$DIRECTORY" != $VAGRANT_FOLDER ]]; then |
| 48 | + echo -e "\033[44m ${DIRECTORY##*/} \033[0m" |
| 49 | + |
| 50 | + ./develop test ${DIRECTORY##*/} && \ |
| 51 | + ./develop down ${DIRECTORY##*/} |
| 52 | + fi |
| 53 | + done |
| 54 | + |
| 55 | + # Run Acceptance tests against ALL environments in parallel |
| 56 | + elif [ "$1" == "test-all-parallel" ]; then |
| 57 | + for DIRECTORY in `find $VAGRANT_FOLDER -maxdepth 1 -type d`; do |
| 58 | + if [[ "$DIRECTORY" != $VAGRANT_FOLDER ]]; then |
| 59 | + gnome-terminal --tab \ |
| 60 | + --command="bash -c \"./develop test ${DIRECTORY##*/} && ./develop down ${DIRECTORY##*/}; read\"" |
| 61 | + fi |
| 62 | + done |
| 63 | + |
| 64 | + fi |
| 65 | + |
| 66 | +else |
| 67 | + # Display usage |
| 68 | + echo -e "Usage: ./develop [action] [arguments]\n" |
| 69 | + echo -e "Available actions:" |
| 70 | + |
| 71 | + # ./develop up {OS_NAME} |
| 72 | + echo -e "\tup {OS_NAME}" |
| 73 | + echo -e "\t\tSpin up a development environment using vagrant and SSH into it." |
| 74 | + echo -e -n "\t\tAvailable OSes: " |
| 75 | + for DIRECTORY in `find $VAGRANT_FOLDER -maxdepth 1 -type d`; do |
| 76 | + if [[ "$DIRECTORY" != $VAGRANT_FOLDER ]]; then |
| 77 | + echo -e -n "${DIRECTORY##*/} " |
| 78 | + fi |
| 79 | + done |
| 80 | + echo |
| 81 | + |
| 82 | + # ./develop ssh {OS_NAME} |
| 83 | + echo -e "\tssh {OS_NAME}" |
| 84 | + echo -e "\t\tSSH into the given development environment." |
| 85 | + |
| 86 | + # ./develop down {OS_NAME} |
| 87 | + echo -e "\tdown {OS_NAME}" |
| 88 | + echo -e "\t\tSwitch off given development environment. This does NOT destroy the box." |
| 89 | + |
| 90 | + # ./develop destroy {OS_NAME} |
| 91 | + echo -e "\tdestroy {OS_NAME}" |
| 92 | + echo -e "\t\tDestroy given development environment." |
| 93 | + |
| 94 | + # ./develop destroy-all |
| 95 | + echo -e "\tdestroy-all" |
| 96 | + echo -e "\t\tDestroy all development environments." |
| 97 | + |
| 98 | + # ./develop test {OS_NAME} |
| 99 | + echo -e "\ttest {OS_NAME}" |
| 100 | + echo -e "\t\tRun Acceptance tests against a given OS." |
| 101 | + |
| 102 | + # ./develop test-all |
| 103 | + echo -e "\ttest-all" |
| 104 | + echo -e "\t\tRun Acceptance tests against ALL OSes." |
| 105 | + |
| 106 | + # ./develop test-all-parallel |
| 107 | + echo -e "\ttest-all-parallel" |
| 108 | + echo -e "\t\tRun Acceptance tests against ALL OSes in parellel. Requires gnome-terminal." |
| 109 | + |
| 110 | +fi |
0 commit comments