Skip to content

Instantly share code, notes, and snippets.

@branan
Last active November 14, 2021 04:18
Show Gist options
  • Save branan/ac8dea4c14f853af571567accf878ee9 to your computer and use it in GitHub Desktop.
Save branan/ac8dea4c14f853af571567accf878ee9 to your computer and use it in GitHub Desktop.
set -x
# USAGE
# Set the variables below for your test environment
# Run the following git commands:
# > git bisect start
# > git bisect bad <bad>
# > git bisect good <good>
# > git bisect run agent-bisect.sh
# TODO: can we compute some of these from the BUILD target?
TEST_COMMAND='GEM_SOURCE=http://rubygems.delivery.puppetlabs.net /opt/puppetlabs/puppet/bin/gem install pcp-client -v "= 0.3.1"'
[email protected]
KEY=${HOME}/.ssh/id_rsa-acceptance
BUILD=el-6-x86_64
OUTDIR=output/el/6/PC1/x86_64
INSTALL="rpm -i"
UNINSTALL="rpm -e"
version=$(git describe | sed 's/-/./g')
# If we can't build or install, we exit with the special
# "cannot test" sentinel value for a git bisect
bundle exec build puppet-agent $BUILD || exit 125
pkg_file=$(ls ${OUTDIR}/puppet-agent-${version}*)
pkg_name=$(basename ${pkg_file})
scp -i ${KEY} "${pkg_file}" ${HOST}:/ || exit 125
ssh -i ${KEY} ${HOST} ${INSTALL} "/${pkg_name}" || exit 125
# The result of the actual test command is stored as our final result code
ssh -i ${KEY} ${HOST} ${TEST_COMMAND}
result=$?
# If any of the cleanup steps fail, we have no choice
# but to abort the entire bisect - our test env is
# dirty now :(
ssh -i ${KEY} ${HOST} ${UNINSTALL} puppet-agent || exit 255
ssh -i ${KEY} ${HOST} rm -rf /opt/puppetlabs || exit 255
# hack: We accidentally comitted a build_metadata.json
# We just let these fail - git will barf if something goes wrong
rm ext/build_metadata.json
git checkout -- ext/build_metadata.json
exit $result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment