name: CI 

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  schedule:
  - cron: '0 0 * * *'

env:
  CARGO_TERM_COLOR: always

jobs:
  main:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        rust: ["1.81", stable, beta, nightly]
        features: ["", "--features=std"]
        abort: [false]
        include:
        - os: ubuntu-latest
          rust: nightly
          features: "--features=abort"
          abort: true
        - os: ubuntu-latest
          rust: nightly
          features: "--features=abort,std"
          abort: true
        - os: windows-latest
          rust: nightly
          features: "--features=abort"
          abort: true
        - os: windows-latest
          rust: nightly
          features: "--features=abort,std"
          abort: true
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}
        override: true
    - run: "rustup component add clippy"
    - uses: actions/checkout@v2
    - run: "cargo build --verbose --no-default-features ${{ matrix.features }}"
    - run: "cargo test --verbose --tests --no-default-features ${{ matrix.features }}"
      if: "${{ !matrix.abort }}"
    - run: "cargo test --verbose --doc --no-default-features ${{ matrix.features }}"
      if: "${{ !matrix.abort }}"
    - run: "cargo doc --verbose --no-default-features ${{ matrix.features }}"
    - run: "cargo build --verbose --release --no-default-features ${{ matrix.features }}"
    - run: "cargo outdated --verbose --root-deps-only --exit-code 1 ${{ matrix.features }}"
    - run: "cargo clippy --verbose --no-default-features ${{ matrix.features }}"
  ensure_no_std:
    strategy:
      fail-fast: false
      matrix:
        include:
        - os: ubuntu-latest
          triple: x86_64-unknown-linux-gnu
        - os: windows-latest
          triple: x86_64-pc-windows-msvc
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly
        override: true
    - run: "rustup component add rust-src --toolchain nightly-${{ matrix.triple }}"
    - uses: actions/checkout@v2
    - run: "cargo +nightly build --verbose -Z build-std=core,panic_abort --target ${{ matrix.triple }} --release"
      working-directory: ensure_no_std
    - run: "./ensure_no_std/target/${{ matrix.triple }}/release/ensure_no_std"
