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/run

89 lines
2.2 KiB
Text
Raw Normal View History

2017-08-07 04:07:33 +00:00
#!/bin/bash
# Run script for Circle CI integration
#
## Copyright (c) 2012-2014 Sylvain Benner
## Copyright (c) 2014-2017 Sylvain Benner & Contributors
##
## Author: Eugene Yaremenko
## URL: https://github.com/syl20bnr/spacemacs
##
## This file is not part of GNU Emacs.
##
## License: GPLv3
2017-08-07 04:07:33 +00:00
if [[ -z "${CIRCLE_PR_NUMBER// }" ]]; then
echo "Skipping check for internal PRs"
exit 0
fi
echo_headline () {
printf '=%.0s' {1..70}
printf "\n$1\n"
printf '=%.0s' {1..70}
echo
}
pr_patch_url="https://patch-diff.githubusercontent.com/raw/"
pr_patch_url+="${CIRCLE_PROJECT_USERNAME}/"
pr_patch_url+="${CIRCLE_PROJECT_REPONAME}/pull/"
pr_patch_url+="${CIRCLE_PR_NUMBER}.patch"
curl "${pr_patch_url}" --output /tmp/patch --silent
first_commit=$(echo $(head -n 1 /tmp/patch) | sed -n 's/From \([a-zA-Z0-9]\+\).*/\1/p')
if [[ -z "${first_commit// }" ]]; then
echo "Can't find first commit"
2017-08-07 04:07:33 +00:00
exit 1
else
echo "First commit: ${first_commit}"
fi
git diff --name-only "${first_commit}^" HEAD > /tmp/changed_files
if [ $? -ne 0 ]; then
echo "Git diff failed"
exit 1
fi
echo_headline "Testing changed ORG files with spacefmt"
changed_f_as_args=()
while read p
do
if [ -f "$p" ]; then
if [ ${p: -4} == ".org" ]; then
changed_f_as_args+=("${p}")
echo "Checking $p file"
./core/tools/spacefmt/spacefmt -f "$p"
if [ $? -ne 0 ]; then
echo "spacefmt failed"
exit 2
fi
fi
fi
done </tmp/changed_files
git diff --color HEAD > spacefmt_result
if [[ -s spacefmt_result ]]; then
echo_headline "PLEASE APPLY CHANGES BELOW:"
cat spacefmt_result
exit 1
fi
if [ ${#changed_f_as_args[@]} -ne 0 ]; then
echo_headline "Testing with exporter"
emacs --batch -l ./core/tools/export/run.el test $(printf "%s " "${changed_f_as_args[@]}")
if [ $? -ne 0 ]; then
echo "Documentation needs some fixing ;)"
exit 1
fi
fi
echo_headline "Testing for trailing and all sorts of broken white spaces"
git reset -q "${first_commit}^"
git add -N .
git diff --check --color > space_test_result
if [[ -s space_test_result ]]; then
cat space_test_result
exit 1
fi
echo "No bad spaces detected"
exit 0