language: c
addons:
  apt:
    packages:
    - lcov
    - linux-libc-dev
    - libuv1-dev
    - liblz4-dev
    - btrfs-progs
    - xfsprogs
    - zfsutils-linux

jobs:
  include:
  - if: type != pull_request
    compiler: gcc
    dist: bionic
    arch: s390x

  - if: type == pull_request
    compiler: gcc
    dist: bionic
    arch: arm64

  - if: type != pull_request
    compiler: clang
    dist: bionic
    arch: ppc64le

before_script:
  - git clone --depth 1 https://github.com/edlund/amalgamate.git
  - export PATH=$PATH:$PWD/amalgamate

script:
  - autoreconf -i
  - |
    if [ $TRAVIS_CPU_ARCH = "s390x" ] || [ $TRAVIS_CPU_ARCH = "arm64" ]; then
      ./configure --enable-example --enable-debug
    else
      ./configure --enable-example --enable-debug --enable-sanitize
    fi
  - amalgamate.py --config=amalgamation.json --source=$(pwd)
  - $CC raft.c -c -D_GNU_SOURCE -DHAVE_LINUX_AIO_ABI_H -Wall -Wextra -Wpedantic -fpic
  - ./test/lib/fs.sh setup
  - make check $(./test/lib/fs.sh detect) || (cat ./test-suite.log && false)
  - ./test/lib/fs.sh teardown
