# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
steps:
  - label: "build-gnu-x86"
    commands:
     - cargo build --release
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "build-gnu-arm"
    commands:
     - cargo build --release
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "build-musl-x86"
    commands:
     - cargo build --release --target x86_64-unknown-linux-musl
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "build-musl-arm"
    commands:
     - cargo build --release --target aarch64-unknown-linux-musl
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "style"
    command: cargo fmt --all -- --check
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "unittests-gnu-x86"
    commands:
     - cargo test --all-features --workspace
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "unittests-gnu-arm"
    commands:
     - cargo test --all-features --workspace
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "unittests-musl-x86"
    command:
     - cargo test --all-features --workspace --target x86_64-unknown-linux-musl
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "unittests-musl-arm"
    command:
     - cargo test --all-features --workspace --target aarch64-unknown-linux-musl
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "clippy-x86"
    commands:
     - cargo clippy --all -- -D warnings
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "check-warnings-x86"
    commands:
      - RUSTFLAGS="-D warnings" cargo check --all-targets --all-features --workspace
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "check-warnings-arm"
    command:
     - RUSTFLAGS="-D warnings" cargo check --all-targets --all-features --workspace
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true

  - label: "coverage-x86"
    commands:
      - pytest rust-vmm-ci/integration_tests/test_coverage.py
    retry:
      automatic: false
    agents:
      platform: x86_64.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "coverage-arm"
    commands:
      - pytest rust-vmm-ci/integration_tests/test_coverage.py
    skip: "Currently this test is very unreliable. Kcov on aarch64 needs fixing."
    retry:
      automatic: false
    agents:
      platform: arm.metal
      os: linux
    plugins:
      - docker#v3.0.1:
          privileged: true
          image: "rustvmm/dev:v8"
          always-pull: true
          volumes:
            - "/tmp:/tmp"

  - label: "commit-format"
    commands:
      - pytest rust-vmm-ci/integration_tests/test_commit_format.py
    if: build.env("BUILDKITE_REPO") !~ /^git@/
    retry:
      automatic: false
    agents:
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true
          propagate-environment: true

  - label: "cargo-audit"
    commands:
      - cargo audit -q
    retry:
      automatic: false
    agents:
      os: linux
    plugins:
      - docker#v3.0.1:
          image: "rustvmm/dev:v8"
          always-pull: true
          propagate-environment: true
