version: 2
jobs:
  build:
    docker:
      - image: pandoc/latex

    steps:
      - checkout

      - run:
          name: Setup dependencies
          command:
            apk add make texlive-xetex ttf-dejavu

      - run:
          name: Build all formats
          command:
            make all

      - run:
          name: Check if epub exists
          command:
            test -s build/epub/book.epub

      - run:
          name: Check if html exists
          command:
            test -s build/html/book.html &&
            test -s build/html/images/cover.png &&
            test -s build/html/images/seagull.png

      - run:
          name: Check if pdf exists
          command:
            test -s build/pdf/book.pdf

      - run:
          name: Check if docx exists
          command:
            test -s build/docx/book.docx
