Skip to content

add CI test for clang formatting #6

add CI test for clang formatting

add CI test for clang formatting #6

# SPDX-FileCopyrightText: 2025 CERN
# SPDX-License-Identifier: Apache-2.0
name: Clang-Format Check
on: [pull_request, push]
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# 1) Add the official LLVM repository for clang-format
- name: Add LLVM apt repo
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main"
sudo apt-get update
# 2) Install latest version
- name: Install clang-format
run: |
sudo apt-get install -y clang-format
clang-format --version
# 3) Check formatting
- name: Check formatting
run: |
# Specify file extensions to be checked
FILES=$(git ls-files '*.cpp' '*.h' '*.cu' '*.cuh' '*.hh' '*.cc' '*.icc')
# '-n' checks if files need reformatting
# '--Werror' throws an error if formatting is incorrect
clang-format -style=file -n --Werror $FILES