mirror of https://github.com/ansible/ansible.git
Add pymarkdown sanity test for core (#81220)
* Clean up markdown * Add pymarkdown sanity test for core * Update unit test SHApull/81221/head
parent
72e038e823
commit
876be11f8c
@ -1,23 +1,29 @@
|
|||||||
##### SUMMARY
|
##### SUMMARY
|
||||||
|
|
||||||
<!--- Describe the change below, including rationale and design decisions -->
|
<!--- Describe the change below, including rationale and design decisions -->
|
||||||
|
|
||||||
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
|
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
|
||||||
|
|
||||||
##### ISSUE TYPE
|
##### ISSUE TYPE
|
||||||
|
|
||||||
<!--- Pick one below and delete the rest -->
|
<!--- Pick one below and delete the rest -->
|
||||||
|
|
||||||
- Bugfix Pull Request
|
- Bugfix Pull Request
|
||||||
- Docs Pull Request
|
- Docs Pull Request
|
||||||
- Feature Pull Request
|
- Feature Pull Request
|
||||||
- Test Pull Request
|
- Test Pull Request
|
||||||
|
|
||||||
##### COMPONENT NAME
|
##### COMPONENT NAME
|
||||||
|
|
||||||
<!--- Write the short name of the module, plugin, task or feature below -->
|
<!--- Write the short name of the module, plugin, task or feature below -->
|
||||||
|
|
||||||
##### ADDITIONAL INFORMATION
|
##### ADDITIONAL INFORMATION
|
||||||
|
|
||||||
<!--- Include additional information to help people understand the change here -->
|
<!--- Include additional information to help people understand the change here -->
|
||||||
<!--- A step-by-step reproduction of the problem is helpful if there is no related issue -->
|
<!--- A step-by-step reproduction of the problem is helpful if there is no related issue -->
|
||||||
|
|
||||||
<!--- Paste verbatim command output below, e.g. before and after your change -->
|
<!--- Paste verbatim command output below, e.g. before and after your change -->
|
||||||
|
|
||||||
```paste below
|
```paste below
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -1,34 +1,43 @@
|
|||||||
##### SUMMARY
|
##### SUMMARY
|
||||||
|
|
||||||
%(component)s contains call to Display.deprecated or AnsibleModule.deprecate and is scheduled for removal
|
%(component)s contains call to Display.deprecated or AnsibleModule.deprecate and is scheduled for removal
|
||||||
|
|
||||||
```
|
```text
|
||||||
%(line)s
|
%(line)s
|
||||||
```
|
```
|
||||||
|
|
||||||
##### ISSUE TYPE
|
##### ISSUE TYPE
|
||||||
- Bug Report
|
|
||||||
|
- Bug Report
|
||||||
|
|
||||||
##### COMPONENT NAME
|
##### COMPONENT NAME
|
||||||
```
|
|
||||||
|
```text
|
||||||
%(path)s
|
%(path)s
|
||||||
```
|
```
|
||||||
|
|
||||||
##### ANSIBLE VERSION
|
##### ANSIBLE VERSION
|
||||||
```
|
|
||||||
|
```text
|
||||||
%(version)s
|
%(version)s
|
||||||
```
|
```
|
||||||
|
|
||||||
##### CONFIGURATION
|
##### CONFIGURATION
|
||||||
|
|
||||||
N/A
|
N/A
|
||||||
|
|
||||||
##### OS / ENVIRONMENT
|
##### OS / ENVIRONMENT
|
||||||
|
|
||||||
N/A
|
N/A
|
||||||
|
|
||||||
##### STEPS TO REPRODUCE
|
##### STEPS TO REPRODUCE
|
||||||
|
|
||||||
N/A
|
N/A
|
||||||
|
|
||||||
##### EXPECTED RESULTS
|
##### EXPECTED RESULTS
|
||||||
|
|
||||||
N/A
|
N/A
|
||||||
|
|
||||||
##### ACTUAL RESULTS
|
##### ACTUAL RESULTS
|
||||||
|
|
||||||
N/A
|
N/A
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
README
|
README
|
||||||
------
|
------
|
||||||
|
|
||||||
This is a simple collection used to test failures with ``ansible-test sanity --test validate-modules``.
|
This is a simple collection used to test failures with ``ansible-test sanity --test validate-modules``.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
README
|
README
|
||||||
------
|
------
|
||||||
|
|
||||||
This is a simple PowerShell-only collection used to verify that ``ansible-test`` works on a collection.
|
This is a simple PowerShell-only collection used to verify that ``ansible-test`` works on a collection.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
README
|
README
|
||||||
------
|
------
|
||||||
|
|
||||||
This is a simple collection used to verify that ``ansible-test`` works on a collection.
|
This is a simple collection used to verify that ``ansible-test`` works on a collection.
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"line-length": {
|
||||||
|
"line_length": 160,
|
||||||
|
"code_block_line_length": 160
|
||||||
|
},
|
||||||
|
"first-line-heading": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"output": "path-line-column-code-message",
|
||||||
|
"error_code": "ansible-test",
|
||||||
|
"extensions": [
|
||||||
|
".md"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
"""Sanity test for Markdown files."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import typing as t
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
paths = sys.argv[1:] or sys.stdin.read().splitlines()
|
||||||
|
|
||||||
|
cmd = [
|
||||||
|
sys.executable,
|
||||||
|
'-m', 'pymarkdown',
|
||||||
|
'--config', pathlib.Path(__file__).parent / 'pymarkdown.config.json',
|
||||||
|
'--strict-config',
|
||||||
|
'scan',
|
||||||
|
] + paths
|
||||||
|
|
||||||
|
process = subprocess.run(
|
||||||
|
cmd,
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
|
capture_output=True,
|
||||||
|
check=False,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
if process.stderr:
|
||||||
|
print(process.stderr.strip(), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not (stdout := process.stdout.strip()):
|
||||||
|
return
|
||||||
|
|
||||||
|
pattern = re.compile(r'^(?P<path_line_column>[^:]*:[0-9]+:[0-9]+): (?P<code>[^:]*): (?P<message>.*) \((?P<aliases>.*)\)$')
|
||||||
|
matches = parse_to_list_of_dict(pattern, stdout)
|
||||||
|
results = [f"{match['path_line_column']}: {match['aliases'].split(', ')[0]}: {match['message']}" for match in matches]
|
||||||
|
|
||||||
|
print('\n'.join(results))
|
||||||
|
|
||||||
|
|
||||||
|
def parse_to_list_of_dict(pattern: re.Pattern, value: str) -> list[dict[str, t.Any]]:
|
||||||
|
matched = []
|
||||||
|
unmatched = []
|
||||||
|
|
||||||
|
for line in value.splitlines():
|
||||||
|
match = re.search(pattern, line)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
matched.append(match.groupdict())
|
||||||
|
else:
|
||||||
|
unmatched.append(line)
|
||||||
|
|
||||||
|
if unmatched:
|
||||||
|
raise Exception('Pattern {pattern!r} did not match values:\n' + '\n'.join(unmatched))
|
||||||
|
|
||||||
|
return matched
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1 @@
|
|||||||
|
pymarkdownlnt
|
@ -0,0 +1,7 @@
|
|||||||
|
# edit "pymarkdown.requirements.in" and generate with: hacking/update-sanity-requirements.py --test pymarkdown
|
||||||
|
application-properties==0.6.0
|
||||||
|
Columnar==1.4.1
|
||||||
|
pymarkdownlnt==0.9.11
|
||||||
|
toolz==0.12.0
|
||||||
|
typing_extensions==4.5.0
|
||||||
|
wcwidth==0.2.6
|
@ -1 +1 @@
|
|||||||
A readme
|
A readme
|
||||||
|
@ -1 +1 @@
|
|||||||
Welcome to my test collection doc for {{ namespace }}.
|
Welcome to my test collection doc for {{ namespace }}.
|
||||||
|
Loading…
Reference in New Issue