2017-08-31 18:42:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
## Shared script part for CircleCI
|
|
|
|
##
|
2017-08-31 14:26:04 +00:00
|
|
|
## Copyright (c) 2012-2014 Sylvain Benner
|
2021-07-01 10:22:42 +00:00
|
|
|
## Copyright (c) 2014-2021 Sylvain Benner & Contributors
|
2017-08-31 14:26:04 +00:00
|
|
|
##
|
|
|
|
## Author: Eugene Yaremenko
|
|
|
|
## URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
##
|
|
|
|
## This file is not part of GNU Emacs.
|
|
|
|
##
|
|
|
|
## License: GPLv3
|
|
|
|
|
2020-06-21 13:07:13 +00:00
|
|
|
# Vars
|
|
|
|
dev_b="develop"
|
|
|
|
mst_b="master"
|
|
|
|
prj_owner="syl20bnr"
|
|
|
|
prj_repo="spacemacs"
|
2020-09-06 12:11:59 +00:00
|
|
|
api_URL_root="https://api.github.com"
|
|
|
|
|
|
|
|
upstream_data_URL_root="${api_URL_root}/"
|
|
|
|
upstream_data_URL_root+="repos/"
|
2020-06-21 13:07:13 +00:00
|
|
|
upstream_data_URL_root+="${prj_owner}/"
|
|
|
|
upstream_data_URL_root+="${prj_repo}"
|
2020-09-06 12:11:59 +00:00
|
|
|
|
2020-06-21 13:07:13 +00:00
|
|
|
CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
|
|
|
|
pr_data_URL="${upstream_data_URL_root}/pulls/${CIRCLE_PR_NUMBER}"
|
|
|
|
upstream_data_URL="${upstream_data_URL_root}/branches/develop"
|
2020-09-06 12:11:59 +00:00
|
|
|
|
|
|
|
pr_file_list_URL="${api_URL_root}/"
|
|
|
|
pr_file_list_URL+="repos/"
|
|
|
|
pr_file_list_URL+="${prj_owner}/"
|
|
|
|
pr_file_list_URL+="${prj_repo}/"
|
|
|
|
pr_file_list_URL+="pulls/"
|
|
|
|
pr_file_list_URL+="${CIRCLE_PR_NUMBER}/"
|
|
|
|
pr_file_list_URL+="files"
|
2020-06-21 13:07:13 +00:00
|
|
|
|
|
|
|
# Helpers
|
2017-08-31 14:26:04 +00:00
|
|
|
echo_headline () {
|
2017-08-31 18:42:19 +00:00
|
|
|
printf '=%.0s' {1..80}
|
|
|
|
printf "\n$1\n"
|
|
|
|
printf '=%.0s' {1..80}
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2020-06-21 13:07:13 +00:00
|
|
|
select_changed_orgs () {
|
|
|
|
changed_f_as_args=()
|
|
|
|
while read p
|
|
|
|
do
|
|
|
|
if [ -f "$p" ]; then
|
|
|
|
if [ ${p: -4} == ".org" ]; then
|
|
|
|
changed_f_as_args+=("${p}")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done </tmp/changed_files
|
|
|
|
}
|
2018-08-22 12:25:45 +00:00
|
|
|
|
2020-06-23 16:11:09 +00:00
|
|
|
fail_when_undefined_pr_number () {
|
2020-06-21 13:07:13 +00:00
|
|
|
if [[ -z "${CIRCLE_PR_NUMBER// }" ]]; then
|
2020-06-24 00:31:48 +00:00
|
|
|
echo "CircleCI didn't set CIRCLE_PR_NUMBER"
|
|
|
|
echo "nor CIRCLE_PULL_REQUEST."
|
2020-06-23 16:11:09 +00:00
|
|
|
echo "Job restart sometimes helps."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
skip_when_branch_update () {
|
|
|
|
if [[ "${IS_BRANCH_UPDATE}" == "yes" ]]; then
|
2020-06-21 13:07:13 +00:00
|
|
|
echo "Skipping for branch update."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|
2018-08-22 12:25:45 +00:00
|
|
|
|
2021-06-30 16:19:45 +00:00
|
|
|
skip_when_non_official_repo () {
|
|
|
|
if [[ "${CIRCLE_PROJECT_REPONAME}" != "${prj_repo}" || \
|
|
|
|
"${CIRCLE_PROJECT_USERNAME}" != "${prj_owner}" ]]; then
|
|
|
|
echo "Skipping for non official repository."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-08-31 18:42:19 +00:00
|
|
|
cleanup () {
|
2021-06-30 16:19:45 +00:00
|
|
|
rm -rf ~/.emacs.d/elpa ~/.emacs.d/.cache /tmp/* ~/.spacemacs
|
2017-08-31 14:26:04 +00:00
|
|
|
}
|