name: $(Build.BuildId)
trigger:
  # Always build master
  - v2-master
pr:
  # Enable building pull requests.
  - v2-master
stages:
  - stage: Testing
    jobs:
      - job:
        variables:
          rust: 1.36.0
        strategy:
          matrix:
            Windows 32-bit (MSVC):
              image: vs2017-win2016
              target: i686-pc-windows-msvc
            Windows 64-bit (MSVC):
              image: vs2017-win2016
              target: x86_64-pc-windows-msvc
            Windows 32-bit (MinGW):
              image: vs2017-win2016
              target: i686-pc-windows-gnu
            Windows 64-bit (MinGW):
              image: vs2017-win2016
              target: x86_64-pc-windows-gnu
        pool:
          vmImage: $(image)
        steps:
          - checkout: self
            fetchDepth: 1
            path: clap
            displayName: Checkout repository
          - task: Cache@2
            inputs:
              key: cargo | "$(rust)" | $(target) | Cargo.toml
              path: C:\Rust\.cargo
            displayName: Caching cargo
          - task: Cache@2
            inputs:
              key: compiled | "$(rust)" | $(target) | Cargo.toml
              path: target
            displayName: Caching compiled
          - script: rustup default $(rust)-$(target)
            displayName: Install rust
          - script: cargo test --no-default-features
            displayName: Test without default features
            env:
              RUST_BACKTRACE: full
          - script: cargo test --features "yaml unstable"
            displayName: Test with most features
            env:
              RUST_BACKTRACE: full
          - script: |
              rmdir /Q /S C:\Rust\.cargo\registry\src
              rmdir /Q /S target\.rustc_info.json
              rmdir /Q /S target\debug\examples
              rmdir /Q /S target\debug\incremental
            displayName: Cleaning for cache
            continueOnError: true
