Reorganize Travis tests

This commit is contained in:
JAremko 2017-07-25 21:01:32 +03:00
parent 3c03c4893b
commit f11f927485
2 changed files with 136 additions and 148 deletions

View File

@ -36,131 +36,116 @@ ln -sf ~/.emacs.d "${TRAVIS_BUILD_DIR}"
cd ~/.emacs.d cd ~/.emacs.d
echo "Pwd $(pwd)" echo "Pwd $(pwd)"
echo_headline () {
printf '=%.0s' {1..70}
printf "\n$1\n"
printf '=%.0s' {1..70}
echo
}
# Formatting conventions tests # Formatting conventions tests
if [ ! -z "$FORMATTING" ]; then if [ ! -z "$FORMATTING" ]; then
echo "TRAVIS_COMMIT_RANGE: ${TRAVIS_COMMIT_RANGE}" echo "TRAVIS_COMMIT_RANGE: ${TRAVIS_COMMIT_RANGE}"
first_commit=`echo ${TRAVIS_COMMIT_RANGE} | sed -r 's/\..*//'` first_commit=`echo ${TRAVIS_COMMIT_RANGE} | sed -r 's/\..*//'`
git diff --name-only "${first_commit}" HEAD > /tmp/changed_files git diff --name-only "${first_commit}" HEAD > /tmp/changed_files
case "${FORMATTING}" in
space-test) echo_headline "Testing changed ORG files with spacefmt"
echo "Testing for trailing and all sorts of broken white spaces" cp ~/.emacs.d/core/templates/.spacemacs.template ~/
git reset -q "${first_commit}" mv ~/.spacemacs.template ~/.spacemacs
git add -N . while read p
git diff --check --color > space_test_result do
if [[ -s space_test_result ]]; then if [ -f "$p" ]; then
cat space_test_result if [ ${p: -4} == ".org" ]; then
exit 1 echo "Checking $p file"
fi ./core/tools/spacefmt/spacefmt -f "$p"
echo "No bad spaces detected" if [ $? -ne 0 ]; then
exit 0 echo "spacefmt failed"
;; exit 2
spacefmt) fi
echo "Testing changed ORG files with spacefmt" fi
cp ~/.emacs.d/core/templates/.spacemacs.template ~/ fi
mv ~/.spacemacs.template ~/.spacemacs done </tmp/changed_files
while read p git diff --color HEAD > spacefmt_result
do if [[ -s spacefmt_result ]]; then
if [ -f "$p" ]; then echo_headline "PLEASE APPLY CHANGES BELOW:"
if [ ${p: -4} == ".org" ]; then cat spacefmt_result
echo "Checking $p file" exit 1
./core/tools/spacefmt/spacefmt -f "$p" fi
if [ $? -ne 0 ]; then echo "All changed files comply with spacefmt"
echo "spacefmt failed"
exit 2 echo_headline "Testing for trailing and all sorts of broken white spaces"
fi git reset -q "${first_commit}"
fi git add -N .
fi git diff --check --color > space_test_result
done </tmp/changed_files if [[ -s space_test_result ]]; then
git diff --color HEAD > spacefmt_result cat space_test_result
if [[ -s spacefmt_result ]]; then exit 1
printf '=%.0s' {1..70} fi
printf "\nPLEASE APPLY CHANGES BELOW:\n" echo "No bad spaces detected"
printf '=%.0s' {1..70} exit 0
echo
cat spacefmt_result
exit 1
fi
echo "All changed files comply with spacefmt"
exit 0
;;
esac
fi fi
# If we are pushing changes to the master branch, # If we are pushing changes to the master or develop branch,
# open PR to syl20bnr/${PUBLISH} with Spacemacs # open PR to syl20bnr/${PUBLISH} with Spacemacs
# documentation exported as HTML and formatted with spacefmt # documentation exported as HTML and formatted with spacefmt
if [ $TRAVIS_SECURE_ENV_VARS = true ] && [ ! -z "$PUBLISH" ] && [ $TRAVIS_PULL_REQUEST = false ]; then if [ $TRAVIS_SECURE_ENV_VARS = true ] && [ ! -z "$PUBLISH" ] && [ $TRAVIS_PULL_REQUEST = false ]; then
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$PUBLISH" != "spacemacs.org" ] || if [ "$TRAVIS_BRANCH" = "master" ] && [ "$PUBLISH" != "spacemacs.org" ] ||
[ "$TRAVIS_BRANCH" = "develop" ] && [ "$PUBLISH" != "develop.spacemacs.org" ]; then [ "$TRAVIS_BRANCH" = "develop" ] && [ "$PUBLISH" != "develop.spacemacs.org" ]; then
echo "branch is \"${TRAVIS_BRANCH}\", won't publish to \"${PUBLISH}\" repository!" echo "branch is \"${TRAVIS_BRANCH}\", won't publish to \"${PUBLISH}\" repository!"
exit 0 exit 0
fi fi
printf '=%.0s' {1..70}
printf "\n FORMATTING DOCUMENTATION:\n" echo_headline "FORMATTING DOCUMENTATION:"
printf '=%.0s' {1..70} cp ~/.emacs.d/tests/doc/dotspacemacs.el ~/dotspacemacs.el
echo mv ~/dotspacemacs.el ~/.spacemacs
cp ~/.emacs.d/tests/doc/dotspacemacs.el ~/dotspacemacs.el ./core/tools/spacefmt/spacefmt doc
mv ~/dotspacemacs.el ~/.spacemacs if [ $? -ne 0 ]; then
./core/tools/spacefmt/spacefmt doc echo "spacefmt exited with: $?"
if [ $? -ne 0 ]; then exit 2
echo "spacefmt exited with: $?" fi
exit 2
fi echo_headline "EXPORTING DOCUMENTATION:"
printf '=%.0s' {1..70} emacs -batch -l init.el > /dev/null 2>&1
printf "\n EXPORTING DOCUMENTATION:\n" emacs -batch -l init.el -l core/core-documentation.el -f spacemacs/publish-doc
printf '=%.0s' {1..70} if [ $? -ne 0 ]; then
echo echo "spacemacs/publish-doc failed"
emacs -batch -l init.el > /dev/null 2>&1 exit 2
emacs -batch -l init.el -l core/core-documentation.el -f spacemacs/publish-doc fi
if [ $? -ne 0 ]; then git config --global user.name "${BOT_NAME}"
echo "spacemacs/publish-doc failed" git config --global user.email "${BOT_EMAIL}"
exit 2 git config --global push.default simple
fi git config --global hub.protocol https
git config --global user.name "${BOT_NAME}" export GITHUB_TOKEN=$BOT_TK
git config --global user.email "${BOT_EMAIL}" git clone "https://github.com/syl20bnr/${PUBLISH}.git" -b gh-pages "/tmp/${PUBLISH}"
git config --global push.default simple rsync -avh ~/.emacs.d/export/ "/tmp/${PUBLISH}"
git config --global hub.protocol https git add -N .
export GITHUB_TOKEN=$BOT_TK
git clone "https://github.com/syl20bnr/${PUBLISH}.git" -b gh-pages "/tmp/${PUBLISH}" cd "/tmp/${PUBLISH}"
rsync -avh ~/.emacs.d/export/ "/tmp/${PUBLISH}" if ! git diff-files --quiet --; then
git add -N . echo_headline "COMMITTING CHANGES TO ${BOT_NAME}/${PUBLISH}:"
cd "/tmp/${PUBLISH}" git diff --color HEAD
if ! git diff-files --quiet --; then curl -L https://github.com/github/hub/releases/download/v2.2.9/hub-linux-amd64-2.2.9.tgz | tar \
printf '=%.0s' {1..70} --strip-components=2 -xz --wildcards -C /tmp/ "*hub"
printf "\n COMMITTING CHANGES TO ${BOT_NAME}/${PUBLISH}:\n" /tmp/hub add --all
printf '=%.0s' {1..70} /tmp/hub commit -m "doc update:$(date -u)"
echo /tmp/hub fork
git diff --color HEAD mkdir -p ~/.ssh
curl -L https://github.com/github/hub/releases/download/v2.2.9/hub-linux-amd64-2.2.9.tgz | tar \ printf "Host github.com\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n" \
--strip-components=2 -xz --wildcards -C /tmp/ "*hub" > ~/.ssh/config
/tmp/hub add --all git remote set-url "${BOT_NAME}" \
/tmp/hub commit -m "doc update:$(date -u)" "https://${BOT_NAME}:${BOT_TK}@github.com/${BOT_NAME}/${PUBLISH}.git"
/tmp/hub fork /tmp/hub push -f "${BOT_NAME}" gh-pages
mkdir -p ~/.ssh
printf "Host github.com\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n" \ echo_headline "OPENING PR TO syl20bnr/${PUBLISH}.git"
> ~/.ssh/config echo "Documentation updates (autoexport)" > msg
git remote set-url "${BOT_NAME}" \ echo "beep beep boop... Beep?" >> msg
"https://${BOT_NAME}:${BOT_TK}@github.com/${BOT_NAME}/${PUBLISH}.git" /tmp/hub pull-request -F msg
/tmp/hub push -f "${BOT_NAME}" gh-pages echo "DONE!"
printf '=%.0s' {1..70} exit 0
printf "\n OPENING PR TO syl20bnr/${PUBLISH}.git\n" else
printf '=%.0s' {1..70} echo "NOTHING TO COMMIT!"
echo exit 0
echo "Documentation updates (autoexport)" > msg fi
echo "beep beep boop... Beep?" >> msg
/tmp/hub pull-request -F msg
printf '=%.0s' {1..70}
printf "\n DONE!\n"
printf '=%.0s' {1..70}
echo
exit 0
else
printf '=%.0s' {1..70}
printf "\n NOTHING TO COMMIT!\n"
printf '=%.0s' {1..70}
echo
exit 0
fi
fi fi
# Emacs tests # Emacs tests
@ -168,9 +153,8 @@ for test in "${TESTS[@]}"; do
rm -rf ~/.emacs.d/elpa rm -rf ~/.emacs.d/elpa
rm -rf ~/.emacs.d/.cache rm -rf ~/.emacs.d/.cache
rm -f ~/.spacemacs rm -f ~/.spacemacs
testdir=~/.emacs.d/tests/$test testdir=~/.emacs.d/tests/$test
echo "Running '$test' in '$testdir' folder" echo_headline "Running '$test' in '$testdir' folder"
if [ -f $testdir/dotspacemacs.el ]; then if [ -f $testdir/dotspacemacs.el ]; then
cp $testdir/dotspacemacs.el ~/.spacemacs cp $testdir/dotspacemacs.el ~/.spacemacs
fi fi

View File

@ -1,35 +1,39 @@
language: generic language: generic
sudo: false sudo: false
branches: branches:
only: only:
- master - master
- develop - develop
before_install: before_install:
- if [ ! -z "$EVM_EMACS" ]; then curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw
> x.sh && source ./x.sh; fi > /tmp/x.sh && source /tmp/x.sh
- if [ ! -z "$EVM_EMACS" ]; then evm install $EVM_EMACS --use --skip; fi - evm install $EVM_EMACS --use --skip
env: env:
matrix: matrix:
- FORMATTING=space-test - FORMATTING=doc EVM_EMACS=emacs-25.1-travis
- FORMATTING=spacefmt EVM_EMACS=emacs-25.1-travis - TESTS=core EVM_EMACS=emacs-24.4-travis
- TESTS=core EVM_EMACS=emacs-24.4-travis - TESTS=core EVM_EMACS=emacs-24.5-travis
- TESTS=core EVM_EMACS=emacs-24.5-travis - TESTS=core EVM_EMACS=emacs-25.1-travis
- TESTS=core EVM_EMACS=emacs-25.1-travis - TESTS=core EVM_EMACS=emacs-git-snapshot-travis
- TESTS=core EVM_EMACS=emacs-git-snapshot-travis - TESTS=doc EVM_EMACS=emacs-24.4-travis
- TESTS=doc EVM_EMACS=emacs-24.4-travis - TESTS=doc EVM_EMACS=emacs-24.5-travis
- TESTS=doc EVM_EMACS=emacs-24.5-travis - TESTS=doc EVM_EMACS=emacs-25.1-travis
- TESTS=doc EVM_EMACS=emacs-25.1-travis - TESTS=doc EVM_EMACS=emacs-git-snapshot-travis
- TESTS=doc EVM_EMACS=emacs-git-snapshot-travis - TESTS=doc-edn EVM_EMACS=emacs-25.1-travis
- TESTS=doc-edn EVM_EMACS=emacs-25.1-travis - PUBLISH=spacemacs.org EVM_EMACS=emacs-25.1-travis
- PUBLISH=spacemacs.org EVM_EMACS=emacs-25.1-travis BOT_NAME=emacspace BOT_EMAIL=emacspace@gmail.com - PUBLISH=develop.spacemacs.org EVM_EMACS=emacs-25.1-travis
- PUBLISH=develop.spacemacs.org EVM_EMACS=emacs-25.1-travis BOT_NAME=emacspace BOT_EMAIL=emacspace@gmail.com global:
global: - secure: "M8NF1Uw7VGkLdNmWiUF4T+VOJXwN8KCKVQb45/BWVpGm88Rcfom/9bxRTUme8VYuzIavph32QF+P9KyhX8aj2p2FMItNnxiEySzap5UrLrNiwB6ZxbQglMJj0yMQKASynNBai9KKI7mYlsM5jRpFJ9OSgj7Ko00RIFpO3EpJ+kE="
- secure: "M8NF1Uw7VGkLdNmWiUF4T+VOJXwN8KCKVQb45/BWVpGm88Rcfom/9bxRTUme8VYuzIavph32QF+P9KyhX8aj2p2FMItNnxiEySzap5UrLrNiwB6ZxbQglMJj0yMQKASynNBai9KKI7mYlsM5jRpFJ9OSgj7Ko00RIFpO3EpJ+kE=" - BOT_NAME=emacspace
- BOT_EMAIL=emacspace@gmail.com
matrix: matrix:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- env: TESTS=core EVM_EMACS=emacs-git-snapshot-travis - env: TESTS=core EVM_EMACS=emacs-git-snapshot-travis
- env: TESTS=doc EVM_EMACS=emacs-24.4-travis - env: TESTS=doc EVM_EMACS=emacs-24.4-travis
- env: TESTS=doc EVM_EMACS=emacs-24.5-travis - env: TESTS=doc EVM_EMACS=emacs-24.5-travis
- env: TESTS=doc EVM_EMACS=emacs-git-snapshot-travis - env: TESTS=doc EVM_EMACS=emacs-git-snapshot-travis
- env: TESTS=doc-edn EVM_EMACS=emacs-25.1-travis
- env: PUBLISH=spacemacs.org EVM_EMACS=emacs-25.1-travis
- env: PUBLISH=develop.spacemacs.org EVM_EMACS=emacs-25.1-travis
script: "./.travis-build.sh" script: "./.travis-build.sh"