build: &BUILD
  cargo_cache:
    folder: $HOME/.cargo/registry
    fingerprint_script: cat Cargo.lock || echo ""
  build_script:
    - . $HOME/.cargo/env || true
    - rustup component add clippy
    - cargo check --all-targets --features=tokio-runtime,file-lock,unprivileged
    - cargo check --all-targets --features=async-io-runtime,file-lock,unprivileged
    #    - RUSTDOCFLAGS="--cfg docsrs" cargo doc --features=file-lock,unprivileged,tokio-runtime # disable until doc_cfg and doc_auto_cfg are stable
    - cargo doc --features=file-lock,unprivileged,tokio-runtime
    - cargo clippy --all-targets --features=tokio-runtime,file-lock,unprivileged
    - cargo clippy --all-targets --features=async-io-runtime,file-lock,unprivileged
  before_cache_script: rm -rf $HOME/.cargo/registry/index


task:
  name: FreeBSD
  freebsd_instance:
    image: freebsd-13-3-release-amd64
  setup_script:
    - fetch https://sh.rustup.rs -o rustup.sh
    - sh rustup.sh -y --profile=minimal
    - . $HOME/.cargo/env
  << : *BUILD

task:
  name: MacOS
  macos_instance:
    image: ghcr.io/cirruslabs/macos-sonoma-base:latest
  setup_script:
    - curl https://sh.rustup.rs -o rustup.sh
    - sh rustup.sh -y --profile=minimal
    - . $HOME/.cargo/env
  << : *BUILD

task:
  name: Linux
  container:
   image: rust:latest
  << : *BUILD

minver_task:
  depends_on:
    - FreeBSD
    - Linux
    - MacOS
  freebsd_instance:
    image: freebsd-13-2-release-amd64
  setup_script:
    - fetch https://sh.rustup.rs -o rustup.sh
    - sh rustup.sh -y --default-toolchain nightly --profile=minimal
    - . $HOME/.cargo/env
  test_script:
    - . $HOME/.cargo/env || true
    - cargo update -Zdirect-minimal-versions
    - cargo check --all-targets --features=tokio-runtime,file-lock,unprivileged
    - cargo check --all-targets --features=async-io-runtime,file-lock,unprivileged
