name: lint

on:
  pull_request:
  push:
    branches:
      - master
  schedule:
    # Prime the caches every Monday
    - cron: 0 1 * * MON

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  lint-opam:
    runs-on: ubuntu-latest
    steps:
      - name: Update apt cache
        run: sudo apt-get update
      - name: Checkout tree
        uses: actions/checkout@v6
      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: "5.2"
      - name: Set-up Binaryen
        uses: Aandreba/setup-binaryen@v1.0.0
        with:
          token: ${{ github.token }}
      - run: sh tools/make_opam_dune_lint_dir.sh
      - uses: ocaml/setup-ocaml/lint-opam@v3

  lint-fmt:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v6
      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: "5.2"
      - uses: ocaml/setup-ocaml/lint-fmt@v3

  lint-runtime:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v6
      - name: Set-up Biome
        uses: biomejs/setup-biome@v2
        with:
          version: 2.4.8
      - name: Run biome
        run: biome ci
