Skip to content

Instantly share code, notes, and snippets.

@bjodah
Created July 17, 2018 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjodah/f3706f476a0b8791c99a65f801c906be to your computer and use it in GitHub Desktop.
Save bjodah/f3706f476a0b8791c99a65f801c906be to your computer and use it in GitHub Desktop.
Convenience script for use with drone (v0.4) cli (http://readme.drone.io/0.4/devs/cli/)
#!/bin/bash -uex
# usage:
#
# $ sudo ./test_repo.sh pycvodes/
#
# $ sudo ./test_repo.sh pynleq2 -e PYNLEQ2_NLEQ2_ROOT_URL=http://secret.example.com/nleq2/
#
# Depends on drone CLI client:
#
# http://readme.drone.io/0.4/devs/cli/
#
BASE_PATH="$(unset CDPATH && cd "$(dirname $0)" && echo $PWD)"
REPO="${1%/}"
REPO_PATH="${BASE_PATH}/${REPO}"
if [[ ! -d ${REPO_PATH} ]]; then
>&2 echo "${REPO_PATH} is not a directory"
exit 1
fi
if [[ ! -f "${REPO_PATH}/.drone.yml" ]]; then
>&2 echo "No .drone.yml file in ${REPO_PATH}"
exit 1
fi
if [[ ! -d "${BASE_PATH}/_ci" ]]; then
mkdir "${BASE_PATH}/_ci"
fi
if [[ -d "${BASE_PATH}/_ci/${REPO}_ci" ]]; then
if [[ -d "${BASE_PATH}/_ci/${REPO}_ci/.git" ]]; then
rm -rf "${BASE_PATH}/_ci/${REPO}_ci/.git"
fi
fi
rsync -rvauP --delete\
--exclude "/build"\
--exclude "/.cache"\
--exclude "*.pyc"\
--exclude "*.so"\
--exclude "/benchmarks/"\
--exclude "/dist/"\
--exclude "/deploy/"\
--exclude "/output/"\
"${REPO_PATH}/" "${BASE_PATH}/_ci/${REPO}_ci/" >/dev/null
cleanup() {
chown -R $(id -u):$(id -g) "${BASE_PATH}/_ci/${REPO}_ci"
}
trap cleanup INT TERM EXIT
( cd ${BASE_PATH}/_ci/${REPO}_ci; git clean -xfd; "${BASE_PATH}/drone" exec --trusted ${@:2} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment