next-gen 0.1.1

Safe generators on stable Rust.
name: CI

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  check-readme-is-up-to-date:
    name: "Check the `README.md` is up to date"
    runs-on: ubuntu-latest
    steps:
      - name: Clone repo
        uses: actions/checkout@v2

      - run: ./gen_readme.py

      - run: git diff --exit-code

  # == CHECK == #
  check:
    name: "Check beta stable and MSRV=1.45.0"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust-toolchain:
          - 1.45.0
          - stable
          - beta
        cargo-locked: ["--locked", ""]
        exclude:
          - rust-toolchain: '1.45.0'
            cargo-locked: ''
          - rust-toolchain: 'beta'
            cargo-locked: '--locked'
    steps:
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.rust-toolchain }}
          override: true

      - name: Clone repo
        uses: actions/checkout@v2

      - name: Update `Cargo.lock`
        if: matrix.cargo-locked != '--locked'
        run: cargo update -v

      - name: Cargo check
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: ${{ matrix.cargo-locked }}

  # no_std check
  nostd-test:
    name: 'Ensure crate is indeed `no_std` compatible.'
    runs-on: ubuntu-latest
    steps:
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: default
          override: true
          toolchain: stable

      - name: Clone repo
        uses: actions/checkout@v2

      - name: Cargo build
        uses: danielhenrymantilla/cargo@master
        with:
          command: build
          args: '--target x86_64-unknown-linux-gnu'
          working-directory: ./tests/nostd


  # == BUILD & TEST == #
  build-and-test:
    name: Build and test
    runs-on: ${{ matrix.os }}
    needs: [check, check-readme-is-up-to-date]
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
        rust-toolchain:
          - 1.45.0
          - stable
          - nightly
        include:
          - rust-toolchain: '1.45.0'
            test-args: ''
          - rust-toolchain: 'stable'
            test-args: '--features better-docs'
          - rust-toolchain: 'nightly'
            test-args: '--features nightly'
    steps:
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: default
          override: true
          toolchain: ${{ matrix.rust-toolchain }}

      - name: Clone repo
        uses: actions/checkout@v2

      - name: Cargo test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: ${{ matrix.test-args }}

  # == UI TESTS ==
  ui-test:
    name: UI Tests
    runs-on: ubuntu-latest
    needs: [check]
    steps:
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: default
          override: true
          toolchain: stable

      - name: Clone repo
        uses: actions/checkout@v2

      - name: Cargo UI test
        uses: actions-rs/cargo@v1
        with:
          command: test-ui