Last active
May 19, 2022 14:51
-
-
Save brianjbayer/ca686b934cf931b20215a6914aba040e to your computer and use it in GitHub Desktop.
Simple bash script to test my sample-login-... Ruby projects running natively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
prompt-to-proceed () { | |
read -p "Do you wish to proceed (Press any key to continue or 'n' to exit)? " response | |
if [[ $response == 'n' ]] || [[ $response == 'N' ]]; then | |
echo " buh-bye" | |
echo "" | |
exit | |
fi | |
echo "" | |
} | |
run_command () { | |
command_to_run="$@" | |
echo " Executing [${command_to_run}]..." | |
$command_to_run | |
echo " ... [${command_to_run}] completed" | |
echo "" | |
} | |
set_browser_env () { | |
export BROWSER="$@" | |
echo "BROWSER=${BROWSER-unset}" | |
} | |
set_headless_env () { | |
export HEADLESS="$@" | |
echo "HEADLESS=${HEADLESS-unset}" | |
} | |
load_if_dotenv_file () { | |
if [[ -f .env ]]; then | |
echo "Found .env file, loading it" | |
export $(cat .env | xargs) | |
echo "" | |
fi | |
} | |
### MAIN ### | |
# Exit script on any errors | |
set -e | |
echo "Testing the NATIVE sample project - macOS only" | |
echo "" | |
load_if_dotenv_file | |
echo "Running bundle install - DO NOT COMMIT Gemfile.lock" | |
prompt-to-proceed | |
run_command bundle install | |
echo "" | |
echo "Testing default" | |
run_command bundle exec rake | |
echo "Testing Chrome" | |
set_browser_env chrome | |
run_command bundle exec rake | |
echo "Testing Chrome Headless" | |
set_browser_env chrome | |
set_headless_env | |
run_command bundle exec rake | |
set_headless_env false | |
echo "Testing Edge" | |
set_browser_env edge | |
run_command bundle exec rake | |
echo "Testing Edge Headless" | |
set_browser_env edge | |
set_headless_env foo | |
run_command bundle exec rake | |
set_headless_env false | |
echo "Testing Firefox" | |
set_browser_env firefox | |
run_command bundle exec rake | |
echo "Testing Firefox Headless" | |
set_browser_env firefox | |
set_headless_env true | |
run_command bundle exec rake | |
set_headless_env false | |
echo "Testing Safari" | |
set_browser_env safari | |
run_command bundle exec rake | |
echo "--- ALL TESTS PASSED ---" | |
echo "" | |
echo "Doing git checkout of Gemfile.lock" | |
prompt-to-proceed | |
run_command git checkout Gemfile.lock | |
echo "" | |
echo "--- FIN ---" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment