name: Clang Lint CI

concurrency:
  group: lint-${{ github.ref }}
  cancel-in-progress: true

on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/lint.yml'
      - 'src/*.c'
      - 'src/*.h'

env:
  GCC_ARGS: src/*.c src/*.h -lglfw -lGL -lm -lasound -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_NATIVE_INCLUDE_NONE
  GCC_ARGS_VIDEO: -DGLFW_EXPOSE_NATIVE_EGL -DVIDEO_IN
  PACKAGES: "libglfw3-dev libgl-dev libasound2-dev"
  PACKAGES_VIDEO: "libv4l-dev"

jobs:
  lint-no-video:
    runs-on: ubuntu-latest
    steps:
      - name: Install packages
        run: apt update && apt install -y $PACKAGES
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          submodules: 'true'
      - name: gcc
        run: gcc -Wall -Wextra -Werror -Wno-format-truncation -Wno-unused-parameter $GCC_ARGS

  lint-video:
    runs-on: ubuntu-latest
    steps:
      - name: Install packages
        run: apt update && apt install -y $PACKAGES $PACKAGES_VIDEO
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          submodules: 'true'
      - name: gcc
        run: gcc -Wall -Wextra -Werror -Wno-format-truncation $GCC_ARGS $GCC_ARGS_VIDEO
