name: Lint

on:
  pull_request:
    types: [opened, synchronize, reopened]
  push:
    branches:
      - master
      - db-abstract

jobs:
  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # Ensure rustfmt is installed and setup problem matcher
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt
      - name: Rustfmt Check
        uses: actions-rust-lang/rustfmt@v1

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: clippy

      - uses: actions/setup-node@v2
        with:
          node-version: "20.0.0"

      - name: Build frontend
        run: make frontend

      - name: clippy Check
        run: cargo clippy --workspace --tests --all-features
