version: 2.0

# Default actions to perform on each Emacs version
default: &default-steps
  steps:
    - checkout
    - run:
        name: Update APT packages
        command: apt-get update
    - run:
        name: Install prerequisites
        command: apt-get install -y openjdk-8-jre make python git
    - run:
        name: Install cask
        command: curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python
    - run:
        name: Make Cask available on the path
        command: echo 'export PATH="/root/.cask/bin:$PATH"' >> $BASH_ENV
    - run:
        name: Run the tests
        command: make

# Enumerated list of Emacs versions
jobs:
  test-emacs-25:
    docker:
      - image: silex/emacs:25
        entrypoint: bash
    <<: *default-steps

  test-emacs-26:
    docker:
      - image: silex/emacs:26.0
        entrypoint: bash
    <<: *default-steps

  test-emacs-master:
    docker:
      - image: silex/emacs:master
        entrypoint: bash
    <<: *default-steps

# Executing in parallel
workflows:
  version: 2
  ci-test-matrix:
    jobs:
      - test-emacs-25
      - test-emacs-26
      # Testing against master currently hangs on CircleCI
      #- test-emacs-master
