services:
  - docker
env:
  - GOPATH=$HOME/go GOROOT=/usr/local/go GO=/usr/local/go/bin/go PATH=/usr/local/go/bin:$PATH
language: c
sudo: required
dist: xenial
addons:
  apt:
    packages:
      - attr
      - automake
      - autotools-dev
      - git
      - make
      - gcc
      - pkg-config
      - wget
      - xz-utils
      - python3.5
      - g++
      - python3-setuptools
      - libdevmapper-dev
      - btrfs-tools
      - go-md2man
before_install:
  - docker pull fedora &
  - docker build -t alpine-build -f Dockerfile.alpine .
  - (wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz && tar xf go1.13.7.linux-amd64.tar.gz && sudo mv go /usr/local)
  - sudo mkdir -p /lower /upper /mnt
  - (cd /; sudo git clone https://github.com/amir73il/unionmount-testsuite.git)
  - (git clone --depth 1 git://github.com/ninja-build/ninja.git && cd ninja && python3.5 ./bootstrap.py && sudo cp ninja /usr/bin)
  - (git clone --depth 1 -b 0.51.1 https://github.com/mesonbuild/meson.git; cd meson; sudo python3.5 ./setup.py install)
  - (git clone --depth 1 https://github.com/sstephenson/bats.git; cd bats; sudo ./install.sh /usr/local)
  - ($GO get github.com/containers/storage; cd $GOPATH/src/github.com/containers/storage; sed -i -e 's|^AUTOTAGS.*$|AUTOTAGS := exclude_graphdriver_devicemapper exclude_graphdriver_btrfs|' Makefile; make GO=$GO containers-storage)
  - (wget https://github.com/libfuse/libfuse/releases/download/fuse-3.6.2/fuse-3.6.2.tar.xz; tar xf fuse-3.6.2.tar.xz; cd fuse-3.6.2; mkdir build; cd build; meson .. --prefix /usr && ninja && sudo ninja install)
script:
  - ./autogen.sh || travis_terminate 1;
  - ./configure || travis_terminate 1;
  - make -j $(nproc) || travis_terminate 1;
  - sudo make -j install; sudo cp fuse-overlayfs /sbin || travis_terminate 1;
  - (cd /unionmount-testsuite; sudo unshare -m ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
  - (cd /unionmount-testsuite; sudo FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 unshare -m ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
  - sudo tests/fedora-installs.sh || travis_terminate 1;
  - sudo tests/unlink.sh || travis_terminate 1;
  - (cd $GOPATH/src/github.com/containers/storage/tests; sudo STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
  - (cd $GOPATH/src/github.com/containers/storage/tests; sudo FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
  - docker run --rm  -v $(pwd):/fuse-overlayfs alpine-build sh -c 'cd /fuse-overlayfs; ./autogen.sh && ./configure && make clean && make'
