language: rust
sudo: false

# We aim to test all the following in any combination:
# - standard tests, benches, documentation, all available features
# - pinned stable, latest stable, beta and nightly Rust releases
# - Linux, OS X, Android, iOS, bare metal (i.e. no_std)
# - x86_64, ARMv7, a Big-Endian arch (MIPS)
matrix:
  include:
    - rust: 1.22.0
      install:
      script:
        - cargo test --tests --no-default-features
        - cargo test --package rand_core --no-default-features
        - cargo test --features serde1,log
    - rust: stable
      os: osx
      install:
      script:
        - cargo test --tests --no-default-features
        - cargo test --package rand_core --no-default-features
        - cargo test --features serde1,log
    - rust: beta
      install:
      script:
        - cargo test --tests --no-default-features
        - cargo test --package rand_core --no-default-features
        - cargo test --features serde1,log
    - rust: nightly
      install:
        - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
      before_script:
        - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
      script:
        - cargo test --tests --no-default-features --features=alloc
        - cargo test --package rand_core --no-default-features --features=alloc,serde1
        - cargo test --features serde1,log,nightly,alloc
        - cargo test --all --benches
        # remove cached documentation, otherwise files from previous PRs can get included
        - rm -rf target/doc
        - cargo doc --no-deps --all --all-features
        - cargo deadlinks --dir target/doc
      after_success:
        - travis-cargo --only nightly doc-upload

    - rust: nightly
      install:
        - rustup target add wasm32-unknown-unknown
        # Use cargo-update since we need a real update-or-install command
        # Only install if not already installed:
        #- cargo --list | egrep "\binstall-update$" -q || cargo install cargo-update
        #- cargo install-update -i cargo-web
        # Cargo has errors with sub-commands so ignore updating for now:
        - cargo --list | egrep "^\s*web$" -q || cargo install cargo-web
      script:
        - cargo web test --target wasm32-unknown-unknown --nodejs --features=stdweb

    - rust: nightly
      install:
        - rustup target add thumbv6m-none-eabi
      script:
        # Bare metal target; no std; only works on nightly
        - cargo build --no-default-features --target thumbv6m-none-eabi --release

    # Trust cross-built/emulated targets. We must repeat all non-default values.
    - rust: stable
      sudo: required
      dist: trusty
      services: docker
      env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
    - rust: stable
      sudo: required
      dist: trusty
      services: docker
      env: TARGET=mips-unknown-linux-gnu
    - rust: stable
      sudo: required
      dist: trusty
      services: docker
      env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
    - rust: stable
      os: osx
      sudo: required
      dist: trusty
      services: docker
      env: TARGET=armv7-apple-ios DISABLE_TESTS=1

before_install:
  - set -e
  - rustup self update

# Used by all Trust targets; others must override:
install:
  - sh utils/ci/install.sh
  - source ~/.cargo/env || true
script:
  - bash utils/ci/script.sh

after_script: set +e

cache: cargo
before_cache:
  # Travis can't cache files that are not readable by "others"
  - chmod -R a+r $HOME/.cargo

env:
  global:
    secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY="

notifications:
  email:
    on_success: never
