forked from cpp-linter/cpp-linter-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
121 lines (120 loc) · 5.29 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: C/C++ Linter
description: Lint C/C++ code with clang-format and clang-tidy then post annotations and comments with faulty results.
author: shenxianpeng
branding:
icon: "check-circle"
color: "green"
inputs:
thread-comments:
description: Set this option to false to disable the use of thread comments as feedback. Defaults to false.
required: false
default: false
file-annotations:
description: Set this option to false to disable the use of file annotations as feedback. Defaults to true.
required: false
default: true
style:
description: >
The style rules to use (defaults to 'llvm').
Set this to 'file' to have clang-format use the closest relative .clang-format file.
required: false
default: "llvm"
extensions:
description: >
The file extensions to run the action against.
This comma-separated string defaults to 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx'.
required: false
default: "c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx"
tidy-checks:
description: >
A string of regex-like patterns specifying what checks clang-tidy will use.
This defaults to 'boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*'. See also clang-tidy docs for more info.
required: false
default: "boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*"
repo-root:
description: >
The relative path to the repository root directory. The default value '.' is relative to the runner's GITHUB_WORKSPACE environment variable.
required: false
default: "."
version:
description: "The desired version of the clang tools to use. Accepted options are strings which can be 15, 14, 13, 12, 11, 10, 9, or 8. Defaults to 12."
required: false
default: "12"
verbosity:
description: A hidden option to control the action's log verbosity. This is the `logging` level (defaults to DEBUG).
required: false
default: "10"
lines-changed-only:
description: Set this option to 'true' to only analyze changes in the event's diff. Defaults to 'false'.
required: false
default: false
files-changed-only:
description: Set this option to 'false' to analyze any source files in the repo. Defaults to 'true'.
required: false
default: true
ignore:
description: >
Set this option with string of path(s) to ignore.
- In the case of multiple paths, you can use a pipe character ('|')
to separate the multiple paths. Multiple lines are forbidden as input to this option.
- This can also have files, but the file's relative path has to be specified
as well.
- There is no need to use './' for each entry; a blank string ('') represents
the repo-root path (specified by the `repo-root` input option).
- Path(s) containing a space should be inside single quotes.
- Submodules are automatically ignored.
- Prefix a path with a bang (`!`) to make it explicitly not ignored - order of
multiple paths does take precedence. The `!` prefix can be applied to
submodules if desired.
- Glob patterns are not supported here. All asterisk characters ('*') are literal.
required: false
default: ".github"
database:
description: The directory containing compile_commands.json file.
required: false
default: ""
extra-args:
description: A string of extra arguments passed to clang-tidy for use as compiler arguments. Multiple arguments are separated by spaces so the argument name and value should use an '=' sign instead of a space.
required: false
default: ""
outputs:
checks-failed:
description: An integer that can be used as a boolean value to indicate if all checks failed.
value: ${{ steps.cpp-linter.outputs.checks-failed }}
runs:
using: "composite"
steps:
- name: Install action dependencies
shell: bash
run: |
if [[ "${{runner.os}}" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }} || true
fi
if [[ "${{runner.os}}" == "macOS" ]];then
python3 -m venv '${{ github.action_path }}/venv'
source '${{ github.action_path }}/venv/bin/activate'
fi
python3 -m pip install -r '${{ github.action_path }}/requirements.txt'
clang-tools -i ${{ inputs.version }} -b
- name: Run cpp-linter
id: cpp-linter
shell: bash
run: |
if [[ "${{runner.os}}" == "macOS" ]];then
source '${{ github.action_path }}/venv/bin/activate'
fi
cpp-linter \
--style="${{ inputs.style }}" \
--extensions=${{ inputs.extensions }} \
--tidy-checks="${{ inputs.tidy-checks }}" \
--repo-root=${{ inputs.repo-root }} \
--version=${{ inputs.version }} \
--verbosity=${{ inputs.verbosity }} \
--lines-changed-only=${{ inputs.lines-changed-only }} \
--files-changed-only=${{ inputs.files-changed-only }} \
--thread-comments=${{ inputs.thread-comments }} \
--ignore="${{ inputs.ignore }}" \
--database=${{ inputs.database }} \
--file-annotations=${{ inputs.file-annotations }} \
--extra-arg="${{ inputs.extra-args }}"