name: Coding Style
on: [pull_request, workflow_dispatch]

jobs:
  back:
    name: "Lint Back"
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./back
    steps:
      - uses: actions/checkout@v4

      - name: Check coding style
        run: |
          dotnet tool restore
          dotnet csharpier . --check

  front:
    name: "Lint Front"
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./front
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 18.x
          cache: yarn
          cache-dependency-path: front/yarn.lock

      - name: Install dependencies
        run: yarn install --immutable

      - name: Lint
        run: yarn lint && yarn format

  scanner:
    name: "Lint scanner"
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./scanner
    steps:
      - uses: actions/checkout@v4

      - uses: chartboost/ruff-action@v1
        with:
          args: format --check

  transcoder:
    name: "Lint transcoder"
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./transcoder
    steps:
      - uses: actions/checkout@v4

      - name: Run go fmt
        run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
