Skip to content

Update README.md

Update README.md #89

Workflow file for this run

name: Clang-Format Check
# This workflow verifies that all tracked C/C++ files in the repository
# are formatted according to the .clang-format rules.
#
# It uses:
# - clang-format (installed via apt)
# - a Go-based helper (cmd/clang-filter) via `go run`
# - the shell script `./clang-format.sh` to orchestrate everything
#
# The workflow runs:
# - on every push to any branch
# - on every pull request
on:
push:
branches:
- "**"
pull_request:
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
#########################################################################
# 1) Check out the repository so we have access to:
# - source files
# - .clang-format
# - .clang-format-ignore
# - cmd/clang-filter
# - clang-format.sh
#########################################################################
- name: Check out repository
uses: actions/checkout@v4
with:
# Full git history is not strictly required for formatting,
# but some tools or future changes might rely on it.
fetch-depth: 0
#########################################################################
# 2) Install clang-format on the runner.
#
# We rely on Ubuntu's clang-format package. If you require a specific
# version, you can pin it here or use a prebuilt toolchain image.
#########################################################################
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Show clang-format version
run: clang-format --version
#########################################################################
# 3) Set up Go toolchain for `go run ./cmd/clang-filter`
#
# The Go helper uses github.com/sabhiram/go-gitignore to implement
# gitignore-style rules for .clang-format-ignore.
#########################################################################
- name: Set up Go
uses: actions/setup-go@v5
with:
# Use a reasonably recent Go version. Adjust as needed.
go-version: '1.22.x'
# Optional but recommended: download all Go module dependencies up front.
# This avoids doing network fetches during `go run` and can speed up CI.
- name: Download Go modules
run: go mod download
#########################################################################
# 4) Run clang-format in CHECK mode via the shell script.
#
# The script:
# - collects tracked C/C++ files (git ls-files)
# - filters them via `go run ./cmd/clang-filter` using .clang-format-ignore
# - runs clang-format in CHECK mode (no in-place changes)
# - prints per-file errors using GitHub Actions "::error" annotations
# - fails the job (exit 1) if any file is misformatted
#########################################################################
- name: Run clang-format in check mode
run: |
chmod +x ./clang-format.sh
./clang-format.sh check