From 28f58d74979c0c7338d258b00a1819d3f49a3837 Mon Sep 17 00:00:00 2001 From: "Roy J. Wignarajah" <78163326+rjwignar@users.noreply.github.com> Date: Thu, 4 Jul 2024 01:47:49 -0400 Subject: [PATCH] ci: clang_format.yml lints only modified source files (#196) closes #128 --- .github/workflows/clang_format.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml index c77eb2ba8..7395d9be8 100644 --- a/.github/workflows/clang_format.yml +++ b/.github/workflows/clang_format.yml @@ -24,10 +24,31 @@ jobs: # make sure the parent commit is grabbed as well, because # that's what will get formatted (i.e. the most recent commit) fetch-depth: 2 + # retrieve comma-separated list of modified files + - name: Retrieve changed files + id: changed-files + uses: tj-actions/changed-files@v42.0.5 + with: + files: | + src/**/*.{cpp,h} + include/**/*.{h,hpp} + **/*.hlsl + **/*.hlsli + separator: "," + # process modified files list before passing to clang-format-lint-action + - name: Process changed files list + id: process-list + run: | + CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}" + CHANGED_FILES="${CHANGED_FILES// /\\ }" + CHANGED_FILES=$(echo "$CHANGED_FILES" | tr ',' ' ') + echo "::set-output name=changed_files::${CHANGED_FILES}" # format the latest commit - - uses: DoozyX/clang-format-lint-action@v0.16.2 + - name: Format changed files + if: steps.changed-files.outputs.any_changed == 'true' + uses: DoozyX/clang-format-lint-action@v0.17 with: - source: "." + source: "${{ steps.process-list.outputs.changed_files }}" exclude: "extern include" extensions: "h,cpp,c,hlsl,hlsli" clangFormatVersion: 16