From 0925e685ef96a9ba38c3907c7d1806552cc760e1 Mon Sep 17 00:00:00 2001 From: Vaibhav Thakkar Date: Tue, 1 Aug 2023 00:35:52 +0530 Subject: [PATCH 1/2] Run git-clang-format on PR only --- .github/workflows/ci.yml | 33 --------------------- .github/workflows/clang-format.yml | 46 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/clang-format.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef1cd6bb5..6bceefa0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,39 +14,6 @@ concurrency: cancel-in-progress: true jobs: - precheckin: - runs-on: ubuntu-22.04 - steps: - - name: Checkout PR branch - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - name: Install clang-format - run: | - curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - echo "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list - sudo apt update - sudo apt install -y clang-format-15 - - name: Download git-clang-format - run: | - wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/git-clang-format - chmod +x git-clang-format - - name: Run git-clang-format - run: | - PR_BASE=$(git rev-list ${{ github.event.pull_request.head.sha }} ^${{ github.event.pull_request.base.sha }} | tail --lines 1 | xargs -I {} git rev-parse {}~1) - echo "running git clang-format against $PR_BASE commit" - git \ - -c color.ui=always \ - -c diff.wsErrorHighlight=all \ - -c color.diff.whitespace='red reverse' \ - clang-format-15 --diff --binary clang-format-15 --commit $PR_BASE -- demos/ include/ lib/ tools/ || \ - (echo "Please run the following git-clang-format locally to fix the formatting: \n - git clang-format origin/master -- demos/ include/ lib/ tools/" && exit 1) build: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 000000000..827cc6436 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,46 @@ +name: clang-format + +on: + pull_request: + paths: + - '**.h' + - '**.cpp' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + precheckin: + runs-on: ubuntu-22.04 + steps: + - name: Checkout PR branch + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + - name: Install clang-format + run: | + curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + echo "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list + sudo apt update + sudo apt install -y clang-format-15 + - name: Download git-clang-format + run: | + wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/git-clang-format + chmod +x git-clang-format + - name: Run git-clang-format + run: | + PR_BASE=$(git rev-list ${{ github.event.pull_request.head.sha }} ^${{ github.event.pull_request.base.sha }} | tail --lines 1 | xargs -I {} git rev-parse {}~1) + echo "running git clang-format against $PR_BASE commit" + git \ + -c color.ui=always \ + -c diff.wsErrorHighlight=all \ + -c color.diff.whitespace='red reverse' \ + clang-format-15 --diff --binary clang-format-15 --commit $PR_BASE -- demos/ include/ lib/ tools/ || \ + (echo "Please run the following git-clang-format locally to fix the formatting: \n + git clang-format origin/master -- demos/ include/ lib/ tools/" && exit 1) From bb085a5c89452e45ddb819e851b4cabafc83ae55 Mon Sep 17 00:00:00 2001 From: Vaibhav Thakkar Date: Tue, 1 Aug 2023 01:06:21 +0530 Subject: [PATCH 2/2] Fix clang-tidy review check --- .clang-tidy | 4 ++-- .github/workflows/clang-tidy-review-post.yml | 2 +- .github/workflows/clang-tidy-review.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 909c32d10..38a6a3ca3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -29,11 +29,11 @@ Checks: > CheckOptions: - key: readability-identifier-naming.ClassCase - value: CamelCase + value: aNy_CasE - key: readability-identifier-naming.FunctionCase value: aNy_CasE - key: readability-identifier-naming.MemberCase - value: CamelCase + value: aNy_CasE - key: readability-identifier-naming.ParameterCase value: aNy_CasE - key: readability-identifier-naming.UnionCase diff --git a/.github/workflows/clang-tidy-review-post.yml b/.github/workflows/clang-tidy-review-post.yml index fe9b015b8..147976e36 100644 --- a/.github/workflows/clang-tidy-review-post.yml +++ b/.github/workflows/clang-tidy-review-post.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Post review comments id: post-review - uses: ZedThree/clang-tidy-review/post@v0.13.1 + uses: ZedThree/clang-tidy-review/post@v0.13.2 with: max_comments: 10 diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml index 8502f5943..9bda570c1 100644 --- a/.github/workflows/clang-tidy-review.yml +++ b/.github/workflows/clang-tidy-review.yml @@ -23,11 +23,11 @@ jobs: version: "12.0.0" - name: Run clang-tidy - uses: ZedThree/clang-tidy-review@v0.13.1 + uses: ZedThree/clang-tidy-review@v0.13.2 id: review with: build_dir: build - exclude: "test/*" + exclude: "test/*,benchmark/*" split_workflow: true cmake_command: > pip install cmake lit &&