# This is a format job. Pre-commit has a first-party GitHub action, so we use
# that: https://github.com/pre-commit/action

name: Format

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
    - master
    - stable
    - "v*"

permissions:
  contents: read

env:
  FORCE_COLOR: 3
  # For cmake:
  VERBOSE: 1

jobs:
  pre-commit:
    name: Format
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7
    - uses: actions/setup-python@v7
      with:
        python-version: "3.x"
    - name: Add matchers
      run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
    - uses: pre-commit/action@v3.0.1

  clang-tidy:
    # When making changes here, please also review the "Clang-Tidy" section
    # in .github/CONTRIBUTING.md and update as needed.
    name: Clang-Tidy
    runs-on: ubuntu-latest
    container: silkeh/clang:20
    steps:
    - uses: actions/checkout@v7

    - name: Install requirements
      run: apt-get update && apt-get install -y git python3-dev python3-pytest ninja-build

    - name: Configure
      run: cmake --preset tidy
    - name: Build
      run: cmake --build --preset tidy

    - name: Embedded
      run: cmake --build --preset tidy -t cpptest
