# The procedure for testing GNU Emacs was kindly taken from:
# https://github.com/purcell/emacs.d

dist: trusty
language: ruby

before_install:
  - git clone https://github.com/rejeep/evm.git $HOME/.evm
  - export PATH=$HOME/.evm/bin:$PATH

  # mu4e
  - sudo apt-get -qq update
  - sudo apt-get install -y maildir-utils
  - pushd /tmp
  - wget https://github.com/djcb/mu/releases/download/v1.0/mu-1.0.tar.xz
  - tar xJvf mu-1.0.tar.xz
  - sudo cp -r mu-1.0/mu4e /usr/share/emacs/site-lisp/
  - popd

  - evm config path /tmp
  - evm install $EVM_EMACS --use --skip

  # shellcheck
  - sudo apt-get install -y shellcheck

  # rubocop
  - gem install rubocop

env:
  - EVM_EMACS=emacs-25.3-travis
  - EVM_EMACS=emacs-26.1-travis
  # GNU Emacs 26.2 refuses to work on Travis because of the bug on fetching
  # elpa.gnu.org. It works locally for me.
  - EVM_EMACS=emacs-git-snapshot-travis

matrix:
  allow_failures:
    - env: EVM_EMACS=emacs-git-snapshot-travis

script:
  # Testing GNU Emacs
  - git clone https://github.com/mssola/soria.git
  - cp soria/soria-theme.el .emacs.d/soria-theme.el
  - lsb_release -a && cd .emacs.d && ./test-emacs.sh

  # Testing scripts
  - cd ../bin/test && ./test.sh

  # Shellcheck
  - cd ../.. && find . -name "*.sh" ! -name ".gitcompletion.sh" ! -name ".hgcompletion.sh" -not -path "./.emacs.d/*" -exec shellcheck \{\} \+

  # Ruby style
  - rubocop
