Skip to content

Commit d622b2b

Browse files
authored
generate inputs-outputs doc (#216)
* don't error out on new I/O options; add prompts for failed assertions * allow use of latest tag in minimum-version of docs/actions.yml
1 parent 184ae89 commit d622b2b

File tree

7 files changed

+324
-291
lines changed

7 files changed

+324
-291
lines changed

action.yml

+146-62
Original file line numberDiff line numberDiff line change
@@ -5,106 +5,190 @@ branding:
55
icon: "check-circle"
66
color: "green"
77
inputs:
8-
thread-comments:
9-
description: >-
10-
Set this option to 'true' or 'false' to enable or disable the use of
11-
thread comments as feedback. Set this to 'update' to update an existing comment
12-
if one exists; the value 'true' will always delete an old comment and post a new one
13-
if necessary. Defaults to false.
14-
required: false
15-
default: 'false'
16-
no-lgtm:
17-
description: >-
18-
Set this option to true or false to enable or disable the use of a thread comment that
19-
basically says 'Looks Good To Me' (when all checks pass). Defaults to true.
20-
See `thread-comments` option for further details.
21-
required: false
22-
default: true
23-
step-summary:
24-
description: >
25-
Set this option to true to append content as part of workflow's job summary. Defaults to false.
26-
27-
See implementation details in GitHub's documentation about
28-
[Adding a job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).
29-
This option is independent of the `thread-comments` option, rather this option uses the same content that
30-
the `thread-comments` option would use.
31-
required: false
32-
default: false
33-
file-annotations:
34-
description: Set this option to false to disable the use of file annotations as feedback. Defaults to true.
35-
required: false
36-
default: true
378
style:
38-
description: >
39-
The style rules to use (defaults to 'llvm').
40-
Set this to 'file' to have clang-format use the closest relative .clang-format file.
9+
description: |
10+
The style rules to use.
11+
12+
- Set this to `file` to have clang-format use the closest relative .clang-format file.
13+
- Set this to a blank string (`''`) to disable the use of clang-format entirely.
14+
- Any code style supported by the specified version of clang-format.
4115
required: false
4216
default: "llvm"
4317
extensions:
44-
description: >
45-
The file extensions to run the action against.
46-
This comma-separated string defaults to 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx'.
18+
description: The file extensions to run the action against. This is a comma-separated string.
4719
required: false
4820
default: "c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx"
4921
tidy-checks:
50-
description: >
51-
A string of regex-like patterns specifying what checks clang-tidy will use.
52-
This defaults to 'boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*'. See also clang-tidy docs for more info.
22+
description: |
23+
Comma-separated list of globs with optional `-` prefix.
24+
Globs are processed in order of appearance in the list.
25+
Globs without `-` prefix add checks with matching names to the set,
26+
globs with the `-` prefix remove checks with matching names from the set of enabled checks.
27+
This option's value is appended to the value of the 'Checks' option in a .clang-tidy file (if any).
28+
29+
- It is possible to disable clang-tidy entirely by setting this option to `'-*'`.
30+
- It is also possible to rely solely on a .clang-tidy config file by specifying this option as a blank string (`''`).
5331
required: false
5432
default: "boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*"
5533
repo-root:
5634
description: >
57-
The relative path to the repository root directory. The default value '.' is relative to the runner's GITHUB_WORKSPACE environment variable.
35+
The relative path to the repository root directory.
36+
This path is relative to the path designated as the runner's `GITHUB_WORKSPACE` environment variable.
5837
required: false
59-
default: "."
38+
default: '.'
6039
version:
61-
description: "The desired version of the clang tools to use. Accepted options are strings which can be 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8 or 7. Defaults to 12."
40+
description: |
41+
The desired version of the [clang-tools](https://github.com/cpp-linter/clang-tools-pip) to use.
42+
Accepted options are strings which can be 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8 or 7.
43+
44+
- Set this option to a blank string (`''`) to use the platform's default installed version.
45+
- This value can also be a path to where the clang tools are installed (if using a custom install location).
6246
required: false
63-
default: "12"
47+
default: 12
6448
verbosity:
65-
description: A hidden option to control the action's log verbosity. This is the `logging` level (defaults to `info`).
49+
description: |
50+
This controls the action's verbosity in the workflow's logs.
51+
Supported options are `info` or `debug`.
52+
This option does not affect the verbosity of resulting thread comments or file annotations.
53+
54+
The verbosity can also be engaged by enabling debug logs when
55+
[re-running jobs or workflows](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs).
6656
required: false
6757
default: info
6858
lines-changed-only:
69-
description: Set this option to 'true' to only analyze changes in the event's diff. Defaults to 'false'.
59+
description: |
60+
This controls what part of the files are analyzed. The following values are accepted:
61+
62+
- `false`: All lines in a file are analyzed.
63+
- `true`: Only lines in the diff that contain additions are analyzed.
64+
- `diff`: All lines in the diff are analyzed (including unchanged lines but not subtractions).
65+
66+
!!! info "Important"
67+
This feature requires special permissions to perform successfully.
68+
See our [documented permissions](permissions.md)
7069
required: false
7170
default: false
7271
files-changed-only:
73-
description: Set this option to 'false' to analyze any source files in the repo. Defaults to 'true'.
72+
description: |
73+
Set this option to false to analyze any source files in the repo.
74+
This is automatically enabled if [`lines-changed-only`](#lines-changed-only) is enabled.
75+
76+
!!! info "Important"
77+
This feature requires special permissions to perform successfully.
78+
See our [documented permissions](permissions.md)
7479
required: false
7580
default: true
7681
ignore:
77-
description: >
82+
description: |
7883
Set this option with string of path(s) to ignore.
7984
80-
- In the case of multiple paths, you can use a pipe character ('|')
81-
to separate the multiple paths. Multiple lines are forbidden as input to this option.
85+
- In the case of multiple paths, you can use a pipe character (`|`)
86+
to separate the multiple paths. Multiple lines are forbidden as an input to this option;
87+
it must be a single string.
8288
- This can also have files, but the file's relative path has to be specified
8389
as well.
84-
- There is no need to use './' for each entry; a blank string ('') represents
85-
the repo-root path (specified by the `repo-root` input option).
86-
- Path(s) containing a space should be inside single quotes.
87-
- Submodules are automatically ignored.
88-
- Prefix a path with a bang (`!`) to make it explicitly not ignored - order of
89-
multiple paths does take precedence. The `!` prefix can be applied to
90-
submodules if desired.
91-
- Glob patterns are not supported here. All asterisk characters ('*') are literal.
92-
required: false
93-
default: ".github"
90+
- There is no need to use `./` for each entry; a blank string (`''`) represents
91+
the [`repo-root`](#repo-root) path.
92+
- Submodules are automatically ignored. Hidden directories (beginning with a `.`) are also ignored
93+
automatically.
94+
- Prefix a path with a bang (`!`) to make it explicitly _not_ ignored. The order of
95+
multiple paths does _not_ take precedence. The `!` prefix can be applied to
96+
a submodule's path (if desired) but not hidden directories.
97+
- Glob patterns are not supported here. All asterisk characters (`*`) are literal.
98+
required: false
99+
default: '.github'
100+
thread-comments:
101+
description: |
102+
This controls the behavior of posted thread comments as feedback. The following options are supported:
103+
104+
- `true`: enable the use of thread comments. This will always delete an outdated thread comment and post a new comment (triggering a notification for every comment).
105+
- `update`: update an existing thread comment if one already exists. This option does not trigger a new notification for every thread comment update.
106+
- `false`: disable the use of thread comments.
107+
108+
!!! info "Important"
109+
This feature requires special permissions to perform successfully.
110+
See our [documented permissions](permissions.md)
111+
112+
> [!NOTE]
113+
> If run on a private repository, then this feature is disabled because the GitHub REST API behaves differently for thread comments on a private repository.
114+
required: false
115+
default: 'false'
116+
no-lgtm:
117+
description: |
118+
Set this option to true or false to enable or disable the use of a
119+
thread comment or pull request review that basically says 'Looks Good To Me' (when all checks pass).
120+
The default value, `true` means no LGTM comment posted.
121+
122+
See [`thread-comments`](#thread-comments), [`tidy-review`](#tidy-review),
123+
and [`format-review`](#format-review) options for further details.
124+
required: false
125+
default: true
126+
step-summary:
127+
description: |
128+
Set this option to true to append content as part of workflow's job summary.
129+
130+
See implementation details in GitHub's documentation about
131+
[Adding a job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).
132+
This option is independent of the [`thread-comments`](#thread-comments) option,
133+
rather this option uses the same content that the
134+
[`thread-comments`](#thread-comments) option would use.
135+
136+
> [!NOTE]
137+
> The [`no-lgtm`](#no-lgtm) option is _not_ applied to step summaries.
138+
required: false
139+
default: false
140+
file-annotations:
141+
description: |
142+
Set this option to false to disable the use of file annotations as feedback.
143+
required: false
144+
default: true
94145
database:
95-
description: The directory containing compile_commands.json file.
146+
description: The directory containing compilation database (like compile_commands.json) file.
96147
required: false
97148
default: ""
98149
extra-args:
99-
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.
150+
description: |
151+
A string of extra arguments passed to clang-tidy for use as compiler arguments.
152+
Multiple arguments are separated by spaces so the argument name and value should
153+
use an `=` sign instead of a space.
154+
155+
!!! example
156+
157+
``` yaml
158+
extra-args: '-std=c++17 -Wall'
159+
```
160+
This will be passed to clang-tidy as multiple `--extra-arg` options:
161+
```
162+
clang-tidy --extra-arg=-std=c++17 --extra-arg=-Wall
163+
```
100164
required: false
101165
default: ""
102166
tidy-review:
103-
description: Set this to true to enable PR reviews from clang-tidy. See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html
167+
description: |
168+
Set this option to `true` to enable Pull Request reviews from clang-tidy.
169+
170+
!!! info "Important"
171+
This feature requires special permissions to perform successfully.
172+
See our [documented permissions](permissions.md).
173+
174+
See also [the PR review feature caveats](pr-review-caveats.md).
175+
176+
> [!NOTE]
177+
> The [`no-lgtm`](#no-lgtm) option is applicable to Pull Request reviews.
104178
required: false
105179
default: false
106180
format-review:
107-
description: Set this to true to enable PR reviews from clang-format.See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html
181+
description: |
182+
Set this option to `true` to enable Pull Request reviews from clang-format.
183+
184+
!!! info "Important"
185+
This feature requires special permissions to perform successfully.
186+
See our [documented permissions](permissions.md).
187+
188+
See also [the PR review feature caveats](pr-review-caveats.md).
189+
190+
> [!NOTE]
191+
> The [`no-lgtm`](#no-lgtm) option is applicable to Pull Request reviews.
108192
required: false
109193
default: false
110194
outputs:

docs/action.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# file to hold metadata about the action.yml inputs and outputs
2+
inputs:
3+
style:
4+
minimum-version: '1.2.0'
5+
extensions:
6+
minimum-version: '1.2.0'
7+
tidy-checks:
8+
minimum-version: '1.2.0'
9+
repo-root:
10+
minimum-version: '1.2.0'
11+
version:
12+
minimum-version: '1.2.0'
13+
verbosity:
14+
minimum-version: '1.3.0'
15+
lines-changed-only:
16+
minimum-version: '1.5.0'
17+
required-permission: 'content: read #file-changes'
18+
files-changed-only:
19+
minimum-version: '1.3.0'
20+
required-permission: 'content: read #file-changes'
21+
ignore:
22+
minimum-version: '1.3.0'
23+
thread-comments:
24+
minimum-version: '2.6.2'
25+
required-permission: 'issues: write #thread-comments'
26+
no-lgtm:
27+
minimum-version: '2.6.2'
28+
step-summary:
29+
minimum-version: '2.6.0'
30+
file-annotations:
31+
minimum-version: '1.4.3'
32+
database:
33+
minimum-version: '1.4.0'
34+
extra-args:
35+
minimum-version: '2.1.0'
36+
tidy-review:
37+
experimental: true
38+
minimum-version: '2.9.0'
39+
required-permission: 'pull_request: write #pull-request-reviews'
40+
format-review:
41+
minimum-version: '2.9.0'
42+
required-permission: 'pull_request: write #pull-request-reviews'
43+
outputs:
44+
checks-failed:
45+
minimum-version: '1.2.0'
46+
clang-tidy-checks-failed:
47+
minimum-version: '2.7.2'
48+
clang-format-checks-failed:
49+
minimum-version: '2.7.2'

docs/badge_hook.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""A mkdocs hook that injects an HTML syntax used to generate badges at build time."""
2+
23
import re
34
from re import Match
45
from mkdocs.config.defaults import MkDocsConfig
@@ -30,11 +31,13 @@ def replace(match: Match):
3031
# -----------------------------------------------------------------------------
3132
# Helper functions
3233

34+
3335
def _badge_for_flags(arg, page: Page, files: Files):
3436
if arg == "experimental":
3537
return _badge_for_experimental(page, files)
3638
raise ValueError(f"Unsupported badge flag: {arg}")
3739

40+
3841
# Create badge
3942
def _badge(icon: str, text: str = ""):
4043
return "".join(
@@ -50,10 +53,12 @@ def _badge(icon: str, text: str = ""):
5053
# Create badge for version
5154
def _badge_for_version(text: str, page: Page, files: Files):
5255
icon = "material-tag-outline"
53-
href = f"https://github.com/cpp-linter/cpp-linter-action/releases/v{text}"
56+
href = "https://github.com/cpp-linter/cpp-linter-action/releases/" + (
57+
f"v{text}" if text[0:1].isdigit() else text
58+
)
5459
return _badge(
55-
icon=f'[:{icon}:]({href} "required version")',
56-
text=f'[{text}]({href} "required version")',
60+
icon=f'[:{icon}:]({href} "minimum version")',
61+
text=f'[{text}]({href} "minimum version")',
5762
)
5863

5964

0 commit comments

Comments
 (0)