version: 2.1

orbs:
  win: circleci/windows@2.2.0

# Default actions to perform on each Emacs version
commands:
  setup:
    steps:
      - checkout
      - run:
          name: Install Eldev
          command: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev > x.sh && source ./x.sh

  macos-setup:
    steps:
      - checkout
      - run:
          name: Install Emacs latest
          command: |
            echo "HOMEBREW_NO_AUTO_UPDATE=1" >> $BASH_ENV
            brew install --cask emacs
      - run:
          name: Install Eldev
          command: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev > x.sh && source ./x.sh

  setup-windows:
    steps:
      - checkout
      - run:
          name: Install Eldev
          command: |
            (iwr https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev.ps1).Content | powershell -command -
  test:
    steps:
      - run:
          name: Run regression tests
          command: eldev -dtT -p test
  lint:
    steps:
      - run:
          name: Run Elisp-lint
          command: eldev lint
      - run:
          name: Byte-compile `.el' files
          command: eldev -dtT compile --warnings-as-errors

jobs:
  test-ubuntu-emacs-28:
    docker:
      - image: silex/emacs:28-ci
        entrypoint: bash
    steps:
      - setup
      - test

  test-ubuntu-emacs-29:
    docker:
      - image: silex/emacs:29-ci
        entrypoint: bash
    steps:
      - setup
      - test

  test-ubuntu-emacs-30:
    docker:
      - image: silex/emacs:30-ci
        entrypoint: bash
    steps:
      - setup
      - test

  test-ubuntu-emacs-master:
    docker:
      - image: silex/emacs:master-ci
        entrypoint: bash
    steps:
      - setup
      - test

  test-macos-emacs-latest:
    macos:
      xcode: "16.2.0"
    steps:
      - macos-setup
      - test

  test-windows-emacs-latest:
    executor: win/default
    steps:
      - run:
          name: Install Emacs latest
          command: |
            choco install emacs
      - setup-windows
      - test

  test-lint:
    docker:
      - image: silex/emacs:30-ci
        entrypoint: bash
    steps:
      - setup
      - lint

workflows:
  version: 2
  ci-test-matrix:
    jobs:
      - test-ubuntu-emacs-28
      - test-ubuntu-emacs-29
      - test-ubuntu-emacs-30
      - test-ubuntu-emacs-master
      - test-lint
      - test-macos-emacs-latest
      - test-windows-emacs-latest
