Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ignore third_party code from clang-format checks
third_party/*
test/third_party/*
system/lib/libc/musl
system/lib/libcxx
system/lib/libcxxabi
system/lib/libunwind
system/lib/mimalloc
system/lib/llvm-libc
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,18 @@ jobs:
echo "-- This failure is only a warning and can be ignored"
exit 1
fi

clang-format-diff:
env:
LLVM_VERSION: 19
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Fetch all history for all tags and branches
with:
fetch-depth: 0
- name: Install clang-format
run: |
sudo apt-get install clang-format-19
sudo update-alternatives --install /usr/bin/git-clang-format git-clang-format /usr/bin/git-clang-format-19 100
- run: tools/maint/clang-format-diff.sh origin/$GITHUB_BASE_REF
22 changes: 22 additions & 0 deletions tools/maint/clang-format-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Based on binaryen/scripts/clang-format-diff.sh
# TODO(sbc): Switch to pre-packaged github actions once we find one that
# is mature enough for our needs.

set -o errexit
set -o pipefail
set -o xtrace

if [ -n "$1" ]; then
BRANCH="$1"
else
BRANCH="@{upstream}"
fi

MERGE_BASE=$(git merge-base $BRANCH HEAD)
FORMAT_ARGS=${MERGE_BASE}
if [ -n "$LLVM_VERSION" ]; then
FORMAT_ARGS="--binary=clang-format-${LLVM_VERSION} ${FORMAT_ARGS}"
fi

git clang-format ${FORMAT_ARGS} --diff
Loading