jobs:
 - job: test
   displayName: cargo test --{examples,doc,lib}
   strategy:
     matrix:
       Linux-stable:
         vmImage: ubuntu-latest
         rust: stable
       Linux-beta:
         vmImage: ubuntu-latest
         rust: beta
       Linux-nightly:
         vmImage: ubuntu-latest
         rust: nightly
       MacOS:
         vmImage: macOS-10.14
         rust: stable
       Windows:
         vmImage: windows-2019
         rust: stable
   continueOnError: $[eq(variables.rust, 'nightly')]
   pool:
     vmImage: $(vmImage)
   steps:
     - template: install-rust.yml@templates
       parameters:
         rust: $(rust)
     - script: cargo check --all-targets
       displayName: cargo check
     - script: cargo test --examples
       displayName: cargo test --examples
     - script: cargo test --doc
       displayName: cargo test --doc
     - script: cargo test --lib
       displayName: cargo test --lib
     - script: |
         set -e
         rustup component add rustfmt
         cargo fmt --all -- --check
       displayName: cargo fmt --check
       condition: and(eq( variables['rust'], 'beta' ), eq( variables['Agent.OS'], 'Linux' ))
     - script: |
         set -e
         rustup component add clippy
         cargo clippy -- -D warnings
       displayName: cargo clippy
       condition: and(eq( variables['rust'], 'beta' ), eq( variables['Agent.OS'], 'Linux' ))
 # This represents the minimum Rust version supported.
 # Tests are not run as tests may require newer versions of rust.
 - job: msrv
   pool:
     vmImage: ubuntu-latest
   displayName: "Minimum supported Rust version: 1.43.0"
   dependsOn: []
   steps:
     - template: install-rust.yml@templates
       parameters:
         rust: 1.43.0 # nom6 depends on bitvec (1.43+)
     - script: cargo check
       displayName: cargo check
 - job: integration
   displayName: cargo test --tests
   pool:
     vmImage: ubuntu-latest
   services:
     greenmail: greenmail
   steps:
     - template: install-rust.yml@templates
     - script: cargo test --tests
       displayName: cargo test
 - template: coverage.yml@templates
   parameters:
     token: $(CODECOV_TOKEN_SECRET)
     services:
       greenmail: greenmail
     env:
       TEST_HOST: greenmail

resources:
  repositories:
    - repository: templates
      type: github
      name: crate-ci/azure-pipelines
      ref: refs/heads/v0.4
      endpoint: jonhoo
  containers:
   - container: greenmail
     image: greenmail/standalone:1.6.3
     ports:
       - 3025:3025
       - 3110:3110
       - 3143:3143
       - 3465:3465
       - 3993:3993
       - 3995:3995
     env:
       GREENMAIL_OPTS: "-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose"
