name: lfchring-rs CI

on:
  push:
    branches: [ main ]
    pull_request:
      branches: [ main ]

jobs:
  #check:
  #  name: check
  #  runs-on: ubuntu-latest
  #  steps:
  #    - name: Checkout repository
  #      uses: actions/checkout@v2
  #    - name: Install stable toolchain
  #      uses: actions-rs/toolchain@v1
  #      with:
  #        profile: minimal
  #        toolchain: stable
  #        override: true
  #    - name: Run cargo check
  #      uses: actions-rs/cargo@v1
  #      with:
  #        command: check

  fmt:
    name: rustfmt
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - name: Install rustfmt
        run: rustup component add rustfmt
      - name: Run rustfmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

  clippy:
    name: clippy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - name: Install clippy
        run: rustup component add clippy
      - name: Run clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings

  test:
    name: test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - name: Run cargo test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --workspace

  coverage:
    name: Code coverage
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - name: Run cargo-tarpaulin
        uses: actions-rs/tarpaulin@v0.1
        with:
          args: -v --ignore-tests --timeout 900
