name: Test

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@master

      - name: Install latest stable Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          default: true
          override: true

      - name: Install minimal stable with clippy and rustfmt
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: rustfmt, clippy

      - name: Run rustfmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Run clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --all

      - name: Run test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all

      - name: Setup dotnet
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '6.0.301'

      - name: Run exmaple and validate
        run: |
          cargo run --example hello_world
          cargo run --example table
          dotnet run --project validator/
