gh-ost/script/cibuild-gh-ost-build-deploy-tarball

48 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-08-15 08:10:48 +00:00
#!/bin/bash
2019-08-15 08:10:48 +00:00
output_fold() {
# Exit early if no label provided
if [ -z "$1" ]; then
echo "output_fold(): requires a label argument."
return
fi
2019-08-15 08:10:48 +00:00
exit_value=0 # exit_value is used to record exit status of the given command
label=$1 # human-readable label describing what's being folded up
shift 1 # having retrieved the output_fold()-specific arguments, strip them off $@
2019-08-15 08:10:48 +00:00
# Only echo the tags when in CI_MODE
if [ "$CI_MODE" ]; then
echo "%%%FOLD {$label}%%%"
fi
2019-08-15 08:10:48 +00:00
# run the remaining arguments. If the command exits non-0, the `||` will
# prevent the `-e` flag from seeing the failure exit code, and we'll see
# the second echo execute
"$@" || exit_value=$?
2019-08-15 08:10:48 +00:00
# Only echo the tags when in CI_MODE
if [ "$CI_MODE" ]; then
echo "%%%END FOLD%%%"
fi
2019-08-15 08:10:48 +00:00
# preserve the exit code from the subcommand.
return $exit_value
}
2019-08-15 08:10:48 +00:00
function cleanup() {
echo
echo "%%%FOLD {Shutting down services...}%%%"
docker-compose down
echo "%%%END FOLD%%%"
}
2019-08-15 08:10:48 +00:00
trap cleanup EXIT
2019-08-15 08:10:48 +00:00
export CI_MODE=true
output_fold "Bootstrapping container..." docker-compose build
output_fold "Running tests..." docker-compose run --rm app
docker-compose run -e BUILD_ARTIFACT_DIR=$BUILD_ARTIFACT_DIR -v $BUILD_ARTIFACT_DIR:$BUILD_ARTIFACT_DIR app script/build-deploy-tarball