-
-
Notifications
You must be signed in to change notification settings - Fork 247
51 lines (47 loc) · 1.68 KB
/
Copy pathclang-format.yml
File metadata and controls
51 lines (47 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Code Style Check
on:
pull_request_target:
paths:
- '**.c'
- '**.cpp'
- '**.h'
- '**.hpp'
- '.clang-format'
jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# Security note: Checking out fork code with pull_request_target is safe here
# because clang-format only parses source files for formatting, it does not
# execute any code. No build scripts or PR code are run.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Run cpp-linter
uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: 'file'
tidy-checks: '-*'
version: '18'
files-changed-only: true
lines-changed-only: false
# Disable thread-comments to avoid 403 errors
# The commits comments API requires contents:write which is unsafe with pull_request_target
# Use step-summary and file-annotations for feedback instead
thread-comments: false
step-summary: true
file-annotations: true
extensions: 'c,cpp,h,hpp'
- name: Fail if formatting issues found
if: steps.linter.outputs.format-checks-failed > 0
run: |
echo "::error::Found ${{ steps.linter.outputs.format-checks-failed }} formatting issues"
exit 1