language: generic
sudo: required

matrix:
  include:
    - os: linux
      dist: xenial
      env:
        - OCAML_VERSION=4.14.0
        - VCPKG_ROOT=vcpkg
    - os: linux
      dist: xenial
      env:
        - OCAML_VERSION=4.11.2
        - VCPKG_ROOT=vcpkg
    - os: linux
      dist: focal
      env:
        - OCAML_VERSION=4.14.0
        - VCPKG_ROOT=vcpkg
    - os: linux
      dist: focal
      env:
        - OCAML_VERSION=4.11.2
        - VCPKG_ROOT=vcpkg
    # - os: osx
    #  osx_image: xcode10.1

# TODO: enable macOS builds
# `brew update` downloads too many packages for the provided macOS image
# and that sometimes causes build breaks because of time-outs.
# Without this command we get an old opam version (1.x) which is not satisfactory.

addons:
  apt:
    packages:
    - sudo
    - ocaml
    - curl
    - build-essential
    - m4
    - pkg-config
    - zlib1g-dev
    - libgmp-dev
    - libssl-dev
    - libboost-system-dev
    - libboost-test-dev
    - libpcre3-dev
    - aspcud
    # Needed to install shellcheck from its GitHub binary releases
    - xz-utils
  homebrew:
    brewfile: true
    update: true
cache:
  directories:
  - $HOME/.opam
  - $HOME/openssl
  # see this awesome answer for caching with Homebrew: https://stackoverflow.com/a/53331571/2747511
  # TODO: we might want to implement everything useful from the answer
  - $HOME/Library/Caches/Homebrew
before_cache:
  - if [ $TRAVIS_OS_NAME = osx ]; then brew cleanup; fi
branches:
  only:
    - master
    - /^release-v.*$/
before_install:
- if [ $TRAVIS_OS_NAME = linux ]; then ./scripts/install_secp256k1.sh; fi
- if [ $TRAVIS_OS_NAME = linux ]; then ./scripts/install_opam2_ubuntu.sh; fi
- if [ $TRAVIS_OS_NAME = linux ]; then ./scripts/install_shellcheck_ubuntu.sh; fi
- if [ $TRAVIS_OS_NAME = linux ]; then bash ./scripts/install_cmake_ubuntu.sh; fi
- make opamdep-ci
- rm $HOME/.opam/log/*
script:
- if [ $TRAVIS_OS_NAME = osx ]; then ulimit -n 1024; fi
- eval $(opam env)
- make test
- make test_server
- make coveralls
- make lint
# check Scilla is installable as an opam package
- opam install . --yes
