This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/.circleci/shared

75 lines
1.8 KiB
Text
Raw Normal View History

#!/usr/bin/env bash
## Shared script part for CircleCI
##
## Copyright (c) 2012-2014 Sylvain Benner
2021-07-01 10:22:42 +00:00
## Copyright (c) 2014-2021 Sylvain Benner & Contributors
##
## 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
prj_owner="${PRJ_OWNER}"
prj_repo="${PRJ_REPO}"
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
echo_headline () {
printf '=%.0s' {1..80}
printf "\n$1\n"
printf '=%.0s' {1..80}
echo
}
exit_if_no_changes () {
if [ ! -f "/tmp/${PUBLISH}.patch" ]; then
echo "\"/tmp/${PUBLISH}.patch\" file doesn't exists. Exiting."
exit 0
fi
if [[ -z $(grep '[^[:space:]]' "/tmp/${PUBLISH}.patch") ]]; then
2021-07-07 12:01:41 +00:00
echo "\"/tmp/${PUBLISH}.patch\" file is empty. Exiting."
exit 0
fi
}
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
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."
echo "Job restart sometimes helps."
exit 1
fi
}