dist: bionic

# Work around broken Travis Crystal image
addons:
  apt:
    packages:
      - gcc
      - pkg-config
      - git
      - tzdata
      - libpcre3-dev
      - libevent-dev
      - libyaml-dev
      - libgmp-dev
      - libssl-dev
      - libxml2-dev

jobs:
  include:
    - stage: build
      # TODO: Shallowly clone again once the .git folder is no longer required for building
      git:
        depth: false
      language: crystal
      crystal: latest
      before_install:
        - crystal --version
        - shards update
        - shards install
      install:
        - crystal build --warnings all --error-on-warnings src/invidious.cr
      script:
        - crystal tool format --check
        - crystal spec

    - stage: build_docker
      # TODO: Shallowly clone again once the .git folder is no longer required for building
      git:
        depth: false
      language: minimal
      services:
        - docker
      install:
        - docker-compose build
      script:
        - docker-compose up -d
        - while curl -Isf http://localhost:3000; do sleep 1; done