123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- name: Run clang-format
- description: Runs clang-format and checks for any changes introduced by it
- inputs:
- failCondition:
- description: Controls whether failed checks also fail the workflow run
- required: false
- default: never
- workingDirectory:
- description: Working directory for checks
- required: false
- default: ${{ github.workspace }}
- runs:
- using: composite
- steps:
- - name: Check Runner Operating System 🏃♂️
- if: runner.os == 'Windows'
- shell: bash
- run: |
- : Check Runner Operating System 🏃♂️
- echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner."
- exit 2
- - name: Check for Changed Files ✅
- uses: ./.github/actions/check-changes
- id: checks
- with:
- checkGlob: "'*.c' '*.h' '*.cpp' '*.hpp' '*.m' '*.mm'"
- diffFilter: 'ACM'
- - name: Install Dependencies 🛍️
- if: runner.os == 'Linux' && fromJSON(steps.checks.outputs.hasChangedFiles)
- shell: bash
- run: |
- : Install Dependencies 🛍️
- echo ::group::Install Dependencies
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- echo "/home/linuxbrew/.linuxbrew/opt/clang-format@17/bin" >> $GITHUB_PATH
- brew install --quiet zsh
- echo ::endgroup::
- - name: Run clang-format 🐉
- if: fromJSON(steps.checks.outputs.hasChangedFiles)
- id: result
- shell: zsh --no-rcs --errexit --pipefail {0}
- working-directory: ${{ inputs.workingDirectory }}
- env:
- CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }}
- run: |
- : Run clang-format 🐉
- if (( ${+RUNNER_DEBUG} )) setopt XTRACE
- print ::group::Install clang-format-17
- brew install --quiet obsproject/tools/clang-format@17
- print ::endgroup::
- print ::group::Run clang-format-17
- local -a changes=(${(s:,:)CHANGED_FILES//[\[\]\'\"]/})
- ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check ${changes}
- print ::endgroup::
|