-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
action.yml
52 lines (48 loc) · 2.01 KB
/
action.yml
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
52
name: "clang-format Check"
description: "Use clang-format to see if your C/C++/Protobuf code is formatted according to project guidelines."
branding:
icon: "check-circle"
color: "blue"
inputs:
clang-format-version:
description: 'The major version of clang-format that you want to use.'
required: false
default: '13'
check-path:
description: 'The path to the directory you want to check for correct C/C++/Protobuf formatting. Default is the full repository.'
required: false
default: '.'
exclude-regex:
description: 'A regex to exclude files or directories that should not be checked. Default is empty.'
required: false
default: ''
fallback-style:
description: 'The fallback style for clang-format if no .clang-format file exists in your repository.'
required: false
default: 'llvm'
include-regex:
description: 'A regex to override the C/C++/Protobuf/CUDA filetype regex. that should be checked. Default results in the regex defined in `check.sh`.'
required: false
default: ''
runs:
using: "composite"
steps:
- run: |
"${{ github.action_path }}/check.sh" "${{ inputs.clang-format-version }}" "${{ inputs.check-path }}" "${{ inputs.fallback-style }}" "${{ inputs.exclude-regex }}" "${{ inputs.include-regex }}"
shell: bash
- name: Save PR head commit SHA
if: failure() && github.event_name == 'pull_request'
shell: bash
run: |
SHA="${{ github.event.pull_request.head.sha }}"
echo "SHA=$SHA" >> $GITHUB_ENV
- name: Save latest commit SHA if not PR
if: failure() && github.event_name != 'pull_request'
shell: bash
run: echo "SHA=${{ github.sha }}" >> $GITHUB_ENV
- name: Report failure in job summary
if: failure()
run: |
DEEPLINK="${{ github.server_url }}/${{ github.repository }}/commit/${{ env.SHA }}"
echo -e "Format check failed on commit [${GITHUB_SHA:0:8}]($DEEPLINK) with files:\n$(<$GITHUB_WORKSPACE/failing-files.txt)" >> $GITHUB_STEP_SUMMARY
shell: bash