name: Code Style (C++) 

on:
  # push trigger not needed for linting, we do not allow direct pushes to master
  pull_request:
    paths:
      - '*/**'    # matches all files not in root
      - '!**.md'
      - '!.ci/**'
      - '!.github/**'
      - '!.husky/**'
      - '!.tx/**'
      - '!doc/**'
      - '!webclient/**'
      - '.ci/lint_cpp.sh'
      - '.github/workflows/desktop-lint.yml'
      - '.clang-format'
      - '.cmake-format.json'
      - 'format.sh'

jobs:
  format:
    runs-on: ubuntu-22.04

    steps:
    - name: Checkout
      uses: actions/checkout@v6
      with:
        fetch-depth: 20 # should be enough to find merge base

    - name: Install dependencies
      shell: bash
      run: |
        sudo apt-get update
        sudo apt-get install -y --no-install-recommends clang-format cmake-format shellcheck

    - name: Check code formatting
      shell: bash
      run: ./.ci/lint_cpp.sh
