language: go

dist: bionic

# https://docs.travis-ci.com/user/caching/
cache:
  directories:
    - NimBinaries
    - p2pdCache

git:
  # when multiple CI builds are queued, the tested commit needs to be in the last X commits cloned with "--depth X"
  depth: 10

go: "1.14.x"

matrix:
  include:
    # Due to Travis new pricing we want to dedicate the resources we have
    # for ARM64 testing, hence Linux/Mac on AMD are commented out
    # https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing

    # - os: linux
    #   arch: amd64
    #   env:
    #     - NPROC=2
    #   before_install:
    #     - export GOPATH=$HOME/go
    # - os: osx
    #   env:
    #     - NPROC=2
    #   before_install:
    #     - export GOPATH=$HOME/go

    - os: linux
      dist: bionic
      arch: arm64
      env:
        - NPROC=6 # Worth trying more than 2 parallel jobs: https://travis-ci.community/t/no-cache-support-on-arm64/5416/8
        # (also used to get a different cache key than the amd64 one)
      before_install:
        - export GOPATH=$HOME/go

install:
  # build nim from our own branch - this to avoid the day-to-day churn and
  # regressions of the fast-paced Nim development while maintaining the
  # flexibility to apply patches
  - curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
  - env MAKE="make -j${NPROC}" bash build_nim.sh Nim csources dist/nimble NimBinaries
  - export PATH="$PWD/Nim/bin:$GOPATH/bin:$PATH"

  # install and build go-libp2p-daemon
  - bash scripts/build_p2pd.sh p2pdCache v0.3.0

script:
  - nimble install -y --depsOnly
  - nimble test
  - nimble examples_build