Skip to content

Setup clang format for C code #13

Setup clang format for C code

Setup clang format for C code #13

Workflow file for this run

name: C Code Formatting Check
on:
push:
paths:
- '**.c'
- '**.h'
- '.clang-format'
- '.github/workflows/clang-format.yml'
pull_request:
paths:
- '**.c'
- '**.h'
- '.clang-format'
- '.github/workflows/clang-format.yml'
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: none
- name: Set working directory as safe
run: git config --global --add safe.directory $(pwd)
- name: Set up permission
run: chmod -R o-w /opt/hostedtoolcache/Ruby
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool
- name: Install clang-format 20
run: |
# Download pre-built binary directly
cd /tmp
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.1/clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04.tar.xz
tar xf clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04.tar.xz
sudo cp clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04/bin/clang-format /usr/local/bin/clang-format
clang-format --version
- name: Install Re2c
run: |
cd /tmp
curl -L https://github.com/skvadrik/re2c/archive/refs/tags/3.1.tar.gz > re2c-3.1.tar.gz
tar xf re2c-3.1.tar.gz
cd re2c-3.1
autoreconf -i -W all
./configure
make
sudo make install
- name: Update rubygems & bundler
run: |
ruby -v
gem update --system
- name: bin/setup
run: |
bin/setup
- name: Check C code formatting
run: |
clang-format --version
bundle exec rake templates
bundle exec rake format:c_verbose || (echo "Run 'rake format:c' locally to fix these issues" && exit 1)