Skip to content

Instantly share code, notes, and snippets.

@apcera-code
Created March 30, 2016 19:29
Show Gist options
  • Save apcera-code/0f13548f3bec154dbcc78fbdacb2f48d to your computer and use it in GitHub Desktop.
Save apcera-code/0f13548f3bec154dbcc78fbdacb2f48d to your computer and use it in GitHub Desktop.
#!/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
@apcera-code
Copy link
Author

For reference, this bash script is in reference to the following article about Package Staging and results in the following Terminal Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment