From cc28556c011097ba03f0cdb1b5d96d36bbc15066 Mon Sep 17 00:00:00 2001 From: Sirui Mu Date: Tue, 3 Dec 2024 15:25:11 +0800 Subject: [PATCH] [gccjit][ci] enable code formatting checks in CI --- .github/workflows/build.yml | 13 +++++++++++++ check-format.sh | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100755 check-format.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 957d4a0..487e01a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,19 @@ name: Build on: [push, pull_request] jobs: + check-format: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Install code formatters + run: | + sudo apt-get update + sudo apt-get install clang-format git + + - name: Check code formatting + run: ./check-format.sh + build: runs-on: ubuntu-24.04 env: diff --git a/check-format.sh b/check-format.sh new file mode 100755 index 0000000..e3a49c1 --- /dev/null +++ b/check-format.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -eu + +diff=$(git clang-format -q --extensions c,cc,cpp,h,hpp --diff HEAD~1) +if [[ -n diff ]]; then + # clang-format outputs some diff, which indicates the commit is not properly + # formatted. + exit 1 +fi