trigger:
  branches:
    include:
    - '*'
    exclude:
    - master
pr:
- master

jobs:
- job: Linux
  pool:
    vmImage: ubuntu-16.04
  steps:
    - template: ci/azure-test-all.yml
  strategy:
    matrix:
      stable:
        TOOLCHAIN: stable
      beta:
        TOOLCHAIN: beta
      nightly:
        TOOLCHAIN: nightly
  variables:
    OTHER_TARGET: i686-unknown-linux-gnu

- job: macOS
  pool:
    vmImage: macos-10.15
  steps:
    - template: ci/azure-test-all.yml
  variables:
    TOOLCHAIN: stable
    OTHER_TARGET: x86_64-apple-ios

- job: Windows
  pool:
    vmImage: windows-2019
  steps:
    - template: ci/azure-test-all.yml
  strategy:
    matrix:
      x86_64-msvc:
        TOOLCHAIN: stable-x86_64-pc-windows-msvc
        OTHER_TARGET: i686-pc-windows-msvc

- job: rustfmt
  pool:
    vmImage: ubuntu-16.04
  steps:
    - template: ci/azure-install-rust.yml
    - bash: rustup component add rustfmt
      displayName: "Install rustfmt"
    - bash: cargo fmt --all -- --check
      displayName: "Check rustfmt (cargo)"
    - bash: cd crates/cargo-test-macro && cargo fmt --all -- --check
      displayName: "Check rustfmt (cargo-test-macro)"
    - bash: cd crates/cargo-test-support && cargo fmt --all -- --check
      displayName: "Check rustfmt (cargo-test-support)"
    - bash: cd crates/crates-io && cargo fmt --all -- --check
      displayName: "Check rustfmt (crates-io)"
    - bash: cd crates/resolver-tests && cargo fmt --all -- --check
      displayName: "Check rustfmt (resolver-tests)"
    - bash: cd crates/cargo-platform && cargo fmt --all -- --check
      displayName: "Check rustfmt (cargo-platform)"
  variables:
    TOOLCHAIN: stable

- job: resolver
  pool:
    vmImage: ubuntu-16.04
  steps:
    - template: ci/azure-install-rust.yml
    - bash: cargo test --manifest-path crates/resolver-tests/Cargo.toml
      displayName: "Resolver tests"
  variables:
    TOOLCHAIN: stable

- job: build_std
  pool:
    vmImage: ubuntu-16.04
  steps:
    - template: ci/azure-install-rust.yml
    - bash: rustup component add rust-src
      displayName: "Install rust-src"
    - bash: cargo build
    - bash: cargo test --test build-std
      displayName: "tests"
  variables:
    TOOLCHAIN: nightly
    CARGO_RUN_BUILD_STD_TESTS: 1

- job: docs
  pool:
    vmImage: ubuntu-16.04
  steps:
    - template: ci/azure-install-rust.yml
    - bash: |
        set -e
        mkdir mdbook
        curl -Lf https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdbook-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
        echo "##vso[task.prependpath]`pwd`/mdbook"
      displayName: "Install mdbook"
    - bash: cargo doc --no-deps
      displayName: "Build documentation"
    - bash: cd src/doc && mdbook build --dest-dir ../../target/doc
      displayName: "Build mdbook documentation"
  variables:
    TOOLCHAIN: stable
