From 38d58f2d8bb8af5516671b42940279d4e582d9c7 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 29 Mar 2026 05:35:25 +0100 Subject: Update actions workflows and add clang format check for PRs (#1418) * Add clang-format workflow for pull request checks * Modify push paths in nightly workflow Updated paths for push event to include all files except specified ones. * Update paths for nightly-server workflow triggers * Modify paths for pull request triggers Update pull request workflow to include specific paths. * Tidy up clang-format installation in workflow --- .github/workflows/clang-format.yml | 48 ++++++++++++++++++++++++++++++++++++ .github/workflows/nightly-server.yml | 11 +++++---- .github/workflows/nightly.yml | 11 +++++---- .github/workflows/pull-request.yml | 10 +++++--- 4 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/clang-format.yml diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 00000000..a01bada4 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,48 @@ +name: Check formatting + +on: + pull_request: + paths: + - '**' + - '!.gitignore' + - '!*.md' + - '!.github/**' + - '.github/workflows/clang-format.yml' + +permissions: + contents: read + pull-requests: write + +jobs: + format-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Fetch base commit + run: git fetch origin ${{ github.event.pull_request.base.sha }} + + - name: Install clang-format-20 + run: | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc + sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" + sudo apt-get install -y -qq clang-format-20 + + - uses: reviewdog/action-setup@v1 + + - name: Check formatting on changed lines + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git clang-format-20 --binary clang-format-20 \ + --diff ${{ github.event.pull_request.base.sha }} -- \ + '*.c' '*.cpp' '*.cc' '*.h' '*.hpp' \ + | reviewdog \ + -name="clang-format" \ + -f=diff \ + -reporter=github-pr-check \ + -fail-level=error \ + -filter-mode=added diff --git a/.github/workflows/nightly-server.yml b/.github/workflows/nightly-server.yml index 5450de9a..0fc20eb1 100644 --- a/.github/workflows/nightly-server.yml +++ b/.github/workflows/nightly-server.yml @@ -5,11 +5,12 @@ on: push: branches: - 'main' - paths-ignore: - - '.gitignore' - - '*.md' - - '.github/**' - - '!.github/workflows/nightly-server.yml' + paths: + - '**' + - '!.gitignore' + - '!*.md' + - '!.github/**' + - '.github/workflows/nightly-server.yml' permissions: contents: write diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 789db3e8..a5b53be0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,11 +5,12 @@ on: push: branches: - 'main' - paths-ignore: - - '.gitignore' - - '*.md' - - '.github/**' - - '!.github/workflows/nightly.yml' + paths: + - '**' + - '!.gitignore' + - '!*.md' + - '!.github/**' + - '.github/workflows/nightly.yml' permissions: contents: write diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9d57f4b4..3b5398a0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,10 +4,12 @@ on: workflow_dispatch: pull_request: types: [opened, reopened, synchronize] - paths-ignore: - - '.gitignore' - - '*.md' - - '.github/*.md' + paths: + - '**' + - '!.gitignore' + - '!*.md' + - '!.github/**' + - '.github/workflows/pull-request.yml' jobs: build: -- cgit v1.2.3