From a3b7fdfe55af89fc65c632f8136ef1d5bd55fa26 Mon Sep 17 00:00:00 2001 From: philipportner Date: Sat, 28 Sep 2024 17:33:19 +0200 Subject: [PATCH] [ci] adds clang-format action (#833) This patch adds an action that runs clang-format on pushes to main and when opening pull requests. The action runs `clang-format` with version `18.1.8` on the `src/` and `test/` folders. If the pushed code contains ill-formatted code, the actions displays the diff. Also adds the required steps in order to install clang-format-18 in the Dockerfile. --- .github/workflows/clang-format-check.yml | 20 ++++++++++++++++++++ containers/daphne-dev.Dockerfile | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/clang-format-check.yml diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml new file mode 100644 index 000000000..3eace5bea --- /dev/null +++ b/.github/workflows/clang-format-check.yml @@ -0,0 +1,20 @@ +name: check-clang-format + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.18.1 + with: + source: 'src test' + exclude: './third_party ./external' + extensions: 'h,cpp' + clangFormatVersion: 18.1.3 diff --git a/containers/daphne-dev.Dockerfile b/containers/daphne-dev.Dockerfile index d56fb8002..c50a7c375 100644 --- a/containers/daphne-dev.Dockerfile +++ b/containers/daphne-dev.Dockerfile @@ -33,8 +33,9 @@ RUN apt-get -qq -y update && apt-get -y upgrade && apt-get -y --no-install-recom build-essential clang gfortran lld llvm llvm-18-tools ninja-build openjdk-11-jdk-headless pkg-config python3-numpy python3-pandas \ vim nano rsync sudo iputils-ping virtualenv openssh-server iproute2 git htop gdb lldb lld gpg-agent net-tools \ software-properties-common ca-certificates file unzip wget tar zstd \ - ccache python3-pip python3-networkx python3-dev graphviz-dev \ + ccache python3-pip python3-networkx python3-dev graphviz-dev clang-format \ && apt-get clean && rm -rf /var/lib/apt/lists/* + COPY --from=daphneeu/daphne-deps /usr/local/bin/ /usr/local/bin/ COPY --from=daphneeu/daphne-deps /usr/local/include/ /usr/local/include/ COPY --from=daphneeu/daphne-deps /usr/local/lib/ /usr/local/lib/