-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Does the same thing as #210 without maligning action.yml
- Loading branch information
Showing
6 changed files
with
284 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# file to hold metadata about the action.yml inputs and outputs | ||
inputs: | ||
style: | ||
minimum-version: '1.2.0' | ||
extensions: | ||
minimum-version: '1.2.0' | ||
tidy-checks: | ||
minimum-version: '1.2.0' | ||
repo-root: | ||
minimum-version: '1.2.0' | ||
version: | ||
minimum-version: '1.2.0' | ||
verbosity: | ||
minimum-version: '1.3.0' | ||
lines-changed-only: | ||
minimum-version: '1.5.0' | ||
required-permission: 'content: read #file-changes' | ||
files-changed-only: | ||
minimum-version: '1.3.0' | ||
required-permission: 'content: read #file-changes' | ||
ignore: | ||
minimum-version: '1.3.0' | ||
thread-comments: | ||
minimum-version: '2.6.2' | ||
required-permission: 'issues: write #thread-comments' | ||
no-lgtm: | ||
minimum-version: '2.6.2' | ||
step-summary: | ||
minimum-version: '2.6.0' | ||
file-annotations: | ||
minimum-version: '1.4.3' | ||
database: | ||
minimum-version: '1.4.0' | ||
extra-args: | ||
minimum-version: '2.1.0' | ||
tidy-review: | ||
experimental: true | ||
minimum-version: '2.9.0' | ||
required-permission: 'pull_request: write #pull-request-reviews' | ||
format-review: | ||
minimum-version: '2.9.0' | ||
required-permission: 'pull_request: write #pull-request-reviews' | ||
outputs: | ||
checks-failed: | ||
minimum-version: '1.2.0' | ||
clang-tidy-checks-failed: | ||
minimum-version: '2.7.2' | ||
clang-format-checks-failed: | ||
minimum-version: '2.7.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from pathlib import Path | ||
from typing import Union, Dict, Any | ||
import yaml | ||
import mkdocs_gen_files | ||
|
||
FILENAME = "inputs-outputs.md" | ||
|
||
with mkdocs_gen_files.open(FILENAME, "w") as io_doc: | ||
action_yml = Path(__file__).parent.parent / "action.yml" | ||
action_doc = Path(__file__).parent / "action.yml" | ||
a_dict: Dict[str, Any] = yaml.safe_load(action_yml.read_bytes()) | ||
b_dict: Dict[str, Dict[str, Any]] = yaml.safe_load(action_doc.read_bytes()) | ||
|
||
# extract info we need from a_dict and merge into b_dict | ||
for info_key in b_dict: | ||
assert info_key in a_dict and isinstance(a_dict[info_key], dict) | ||
for k, v in a_dict[info_key].items(): | ||
b_dict[info_key][k].update(v) | ||
|
||
doc = "".join( | ||
[ | ||
"---\ntitle: Inputs and Outputs\n---\n\n" | ||
"<!--\n", | ||
" this page was generated from action.yml ", | ||
"using the gen_io_doc.py script.\n", | ||
" CHANGES TO inputs-outputs.md WILL BE LOST & OVERWRITTEN\n-->\n\n", | ||
"# Inputs and Outputs\n\n", | ||
"These are the action inputs and outputs offered by cpp-linter-action.\n", | ||
] | ||
) | ||
assert "inputs" in b_dict | ||
doc += "\n## Inputs\n" | ||
for action_input, input_metadata in b_dict["inputs"].items(): | ||
|
||
doc += f"### `{action_input}`\n\n" | ||
|
||
assert "minimum-version" in input_metadata | ||
min_ver = input_metadata["minimum-version"] | ||
doc += f"<!-- md:version {min_ver} -->\n" | ||
|
||
assert "default" in input_metadata | ||
default: Union[str, bool] = input_metadata["default"] | ||
if isinstance(default, bool): | ||
default = str(default).lower() | ||
elif isinstance(default, str): | ||
default = repr(default) # add quotes around value | ||
doc += f"<!-- md:default {default} -->\n" | ||
|
||
if "experimental" in input_metadata and input_metadata["experimental"] is True: | ||
doc += "<!-- md:flag experimental -->\n" | ||
|
||
if "required-permission" in input_metadata: | ||
permission = input_metadata["required-permission"] | ||
doc += f"<!-- md:permission {permission} -->\n" | ||
|
||
assert "description" in input_metadata | ||
doc += "\n" + input_metadata["description"] + "\n" | ||
|
||
assert "outputs" in b_dict | ||
doc += ( | ||
"\n## Outputs\n\nThis action creates 3 output variables. Even if the linting " | ||
"checks fail for source files this action will still pass, but users' CI " | ||
"workflows can use this action's outputs to exit the workflow early if that is " | ||
"desired.\n" | ||
) | ||
for action_output, output_metadata in b_dict["outputs"].items(): | ||
doc += f"\n### `{action_output}`\n\n" | ||
|
||
assert "minimum-version" in output_metadata | ||
min_ver = output_metadata["minimum-version"] | ||
doc += f"<!-- md:version {min_ver} -->\n" | ||
|
||
|
||
assert "description" in output_metadata | ||
doc += "\n" + output_metadata["description"] + "\n" | ||
|
||
print(doc, file=io_doc) | ||
|
||
mkdocs_gen_files.set_edit_path(FILENAME, "gen_io_doc.py") |
Oops, something went wrong.