Created
March 30, 2016 19:29
-
-
Save apcera-code/0f13548f3bec154dbcc78fbdacb2f48d to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -e | |
export TMPDIR=/tmp | |
# Download the package to stage | |
echo "Downloading to /app" | |
curl $STAGER_URL/data > $TMPDIR/raw.tar.gz 2>/dev/null | |
cd /app | |
tar xzf $TMPDIR/raw.tar.gz --strip-components=1 app | |
# Make sure we have rspec tests | |
if [[ ! -d spec ]]; then | |
echo "No spec folder found. Not a valid project." | |
curl -X POST $STAGER_URL/failed | |
exit 1 | |
fi | |
# Run bundler to install test dependencies | |
echo "-----> Running bundle install for test dependencies" | |
bundle install --without development --path vendor/bundle \ | |
--binstubs vendor/bundle/bin --deployment | |
# Run tests | |
echo "-----> Running tests" | |
set +e | |
bundle exec rspec | |
rspec_exit=$? | |
set -e | |
# Check the exit code | |
if [[ $rspec_exit != 0 ]]; then | |
echo "-----> Rspec failed!" | |
curl -X POST $STAGER_URL/failed | |
exit $rspec_exit | |
fi | |
# Success, mark stager done | |
echo "-----> Rspec tests passed." | |
curl -X POST $STAGER_URL/done >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For reference, this bash script is in reference to the following article about Package Staging and results in the following Terminal Output