summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2023-07-11 23:40:47 +0200
committerGitHub <noreply@github.com>2023-07-11 23:40:47 +0200
commit876be11f8ce8330e823d740b01ff8c72034427ce (patch)
tree062d1422407a16df959c376197fae29a3d1e7b59
parentRemove `docs` and `examples` directories (#81011) (diff)
downloadansible-876be11f8ce8330e823d740b01ff8c72034427ce.tar.xz
ansible-876be11f8ce8330e823d740b01ff8c72034427ce.zip
Add pymarkdown sanity test for core (#81220)
* Clean up markdown * Add pymarkdown sanity test for core * Update unit test SHA
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md6
-rw-r--r--hacking/README.md20
-rw-r--r--hacking/azp/README.md10
-rw-r--r--hacking/backport/README.md9
-rw-r--r--hacking/deprecated_issue_template.md17
-rw-r--r--hacking/ticket_stubs/bug_internal_api.md4
-rw-r--r--hacking/ticket_stubs/bug_wrong_repo.md30
-rw-r--r--hacking/ticket_stubs/collections.md4
-rw-r--r--hacking/ticket_stubs/no_thanks.md5
-rw-r--r--hacking/ticket_stubs/pr_duplicate.md5
-rw-r--r--hacking/ticket_stubs/pr_merged.md2
-rw-r--r--hacking/ticket_stubs/proposal.md7
-rw-r--r--hacking/ticket_stubs/question_not_bug.md7
-rw-r--r--hacking/ticket_stubs/resolved.md2
-rw-r--r--hacking/ticket_stubs/wider_discussion.md11
-rw-r--r--lib/ansible/galaxy/data/container/README.md8
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/failure/README.md1
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/ps_only/README.md1
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.md1
-rw-r--r--test/lib/ansible_test/_internal/commands/sanity/__init__.py10
-rw-r--r--test/sanity/code-smell/pymarkdown.config.json11
-rw-r--r--test/sanity/code-smell/pymarkdown.json7
-rw-r--r--test/sanity/code-smell/pymarkdown.py64
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.in1
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.txt7
-rw-r--r--test/sanity/ignore.txt23
-rw-r--r--test/support/README.md2
-rw-r--r--test/units/cli/test_data/collection_skeleton/README.md2
-rw-r--r--test/units/cli/test_data/collection_skeleton/docs/My Collection.md2
-rw-r--r--test/units/galaxy/test_collection.py2
30 files changed, 213 insertions, 68 deletions
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 5652e79d1c..62566fa6e1 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,23 +1,29 @@
##### SUMMARY
+
<!--- Describe the change below, including rationale and design decisions -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
##### ISSUE TYPE
+
<!--- Pick one below and delete the rest -->
+
- Bugfix Pull Request
- Docs Pull Request
- Feature Pull Request
- Test Pull Request
##### COMPONENT NAME
+
<!--- Write the short name of the module, plugin, task or feature below -->
##### ADDITIONAL INFORMATION
+
<!--- 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 -->
<!--- Paste verbatim command output below, e.g. before and after your change -->
+
```paste below
```
diff --git a/hacking/README.md b/hacking/README.md
index d9f4c89619..51f17202ed 100644
--- a/hacking/README.md
+++ b/hacking/README.md
@@ -9,14 +9,18 @@ ansible from a git checkout using python >= 3.10.
First, set up your environment to run from the checkout:
- $ source ./hacking/env-setup
+```shell
+source ./hacking/env-setup
+```
You will need some basic prerequisites installed. If you do not already have them
and do not wish to install them from your operating system package manager, you
can install them from pip
- $ easy_install pip # if pip is not already available
- $ pip install -r requirements.txt
+```shell
+easy_install pip # if pip is not already available
+pip install -r requirements.txt
+```
From there, follow ansible instructions on docs.ansible.com as normal.
@@ -28,7 +32,9 @@ a module outside of the ansible program, locally, on the current machine.
Example:
- $ ./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hi"
+```shell
+./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hi"
+```
This is a good way to insert a breakpoint into a module, for instance.
@@ -45,8 +51,10 @@ parent:
Use:
- $ ./hacking/test-module.py -m module \
- -a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'
+```shell
+./hacking/test-module.py -m module \
+ -a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'
+```
return_skeleton_generator.py
----------------------------
diff --git a/hacking/azp/README.md b/hacking/azp/README.md
index 5784848228..6e833fefaf 100644
--- a/hacking/azp/README.md
+++ b/hacking/azp/README.md
@@ -34,25 +34,31 @@ Reducing incidental test coverage, and eventually removing incidental tests invo
1. Run the entire test suite with code coverage enabled.
This is done automatically each day on Azure Pipelines.
The URLs and statuses of the most recent such test runs can be found with:
+
```shell
hacking/azp/get_recent_coverage_runs.py <optional branch name>
```
+
The branch name defaults to `devel`.
2. Download code coverage data from Azure Pipelines for local analysis.
Example:
+
```shell
# download results to ansible/ansible directory under cwd
# substitute the correct run number for the Azure Pipelines coverage run you want to download
hacking/azp/download.py 14075 --artifacts --run-metadata -v
```
+
3. Analyze code coverage data to see which portions of the code are covered by each test.
Example:
- ```shell script
+
+ ```shell
# make sure ansible-test is in $PATH
source hacking/env-setup
# run the script using whichever directory results were downloaded into
hacking/azp/incidental.py 14075/
```
+
4. Create new intentional tests, or extend existing ones, to cover code that is currently covered by incidental tests.
Reports are created by default in a ``test/results/.tmp/incidental/{hash}/reports/`` directory.
The ``{hash}`` value is based on the input files used to generate the report.
@@ -90,7 +96,7 @@ If the coverage is for Python code a comment on the right side will indicate the
Below is an example of a report:
-```
+```text
Target: incidental_win_psexec
GitHub: https://github.com/ansible/ansible/blob/6994ef0b554a816f02e0771cb14341a421f7cead/test/integration/targets/incidental_win_psexec
diff --git a/hacking/backport/README.md b/hacking/backport/README.md
index 587ae26450..3fb212b33e 100644
--- a/hacking/backport/README.md
+++ b/hacking/backport/README.md
@@ -6,26 +6,25 @@ variable called `GITHUB_TOKEN`.
To generate a Github token, go to https://github.com/settings/tokens/new
-### `backport_of_line_adder.py`
+## `backport_of_line_adder.py`
This script will attempt to add a reference line ("Backport of ...") to a new
backport PR.
It is called like this:
-```
+```shell
./backport_of_line_adder.py <backport> <original PR>
```
However, it contains some logic to try to automatically deduce the original PR
for you. You can trigger that logic by making the second argument be `auto`.
-```
+```shell
./backport_of_line_adder.py 12345 auto
```
-... for example, will look for an appropriate reference to add to backport PR
-#12345.
+... for example, will look for an appropriate reference to add to backport PR #12345.
The script will prompt you before making any changes, and give you a chance to
review the PR that it is about to reference.
diff --git a/hacking/deprecated_issue_template.md b/hacking/deprecated_issue_template.md
index 45a8d37ad0..b0f53ac103 100644
--- a/hacking/deprecated_issue_template.md
+++ b/hacking/deprecated_issue_template.md
@@ -1,34 +1,43 @@
##### SUMMARY
+
%(component)s contains call to Display.deprecated or AnsibleModule.deprecate and is scheduled for removal
-```
+```text
%(line)s
```
##### ISSUE TYPE
- - Bug Report
+
+- Bug Report
##### COMPONENT NAME
-```
+
+```text
%(path)s
```
##### ANSIBLE VERSION
-```
+
+```text
%(version)s
```
##### CONFIGURATION
+
N/A
##### OS / ENVIRONMENT
+
N/A
##### STEPS TO REPRODUCE
+
N/A
##### EXPECTED RESULTS
+
N/A
##### ACTUAL RESULTS
+
N/A
diff --git a/hacking/ticket_stubs/bug_internal_api.md b/hacking/ticket_stubs/bug_internal_api.md
index 2b3568fc92..76a3bb085c 100644
--- a/hacking/ticket_stubs/bug_internal_api.md
+++ b/hacking/ticket_stubs/bug_internal_api.md
@@ -13,11 +13,11 @@ but this does not seem to match that case.
If you really need a stable API target to use Ansible, consider using ansible-runner:
- * https://github.com/ansible/ansible-runner
+* https://github.com/ansible/ansible-runner
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you once again for this and your interest in Ansible!
diff --git a/hacking/ticket_stubs/bug_wrong_repo.md b/hacking/ticket_stubs/bug_wrong_repo.md
index 8ea5ca01d7..b711e85f3a 100644
--- a/hacking/ticket_stubs/bug_wrong_repo.md
+++ b/hacking/ticket_stubs/bug_wrong_repo.md
@@ -4,35 +4,33 @@ Thanks very much for your interest in Ansible. It means a lot to us.
This appears to be something that should be filed against another project or bug tracker. Here's why:
- * FILL IN
+* FILL IN
<< CHOOSE AS APPROPRIATE >>
- * https://github.com/ansible-community/ansible-lint
- * https://github.com/ansible/ansible-runner
- * https://github.com/ansible/ansible-navigator
- * https://github.com/ansible-community/antsibull
- * https://github.com/ansible-community/ara
- * https://github.com/ansible/awx
- * https://github.com/ansible-collections/community.general
- * https://github.com/ansible-community/molecule
- * For AAP or Tower licensees report issues via your Red Hat representative or https://issues.redhat.com
+* https://github.com/ansible-community/ansible-lint
+* https://github.com/ansible/ansible-runner
+* https://github.com/ansible/ansible-navigator
+* https://github.com/ansible-community/antsibull
+* https://github.com/ansible-community/ara
+* https://github.com/ansible/awx
+* https://github.com/ansible-collections/community.general
+* https://github.com/ansible-community/molecule
+* For AAP or Tower licensees report issues via your Red Hat representative or https://issues.redhat.com
If you can stop by the tracker or forum for one of those projects, we'd appreciate it.
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
Should you still wish to discuss things further, or if you disagree with our thought process, please stop by one of our two mailing lists:
- * https://groups.google.com/forum/#!forum/ansible-devel
- * Matrix: [#devel:ansible.im](https://matrix.to/#/#devel:ansible.im)
- * IRC: #ansible-devel on [irc.libera.chat](https://libera.chat/)
+* https://groups.google.com/forum/#!forum/ansible-devel
+* Matrix: [#devel:ansible.im](https://matrix.to/#/#devel:ansible.im)
+* IRC: #ansible-devel on [irc.libera.chat](https://libera.chat/)
We'd be happy to discuss things.
See this page for a complete list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you once again!
-
-
diff --git a/hacking/ticket_stubs/collections.md b/hacking/ticket_stubs/collections.md
index 57ab46f11a..eecd8151f1 100644
--- a/hacking/ticket_stubs/collections.md
+++ b/hacking/ticket_stubs/collections.md
@@ -4,13 +4,13 @@ Thank you very much for your submission to Ansible. It means a lot to us that yo
Since Ansible 2.10 we are no longer accepting new modules/plugins into Ansible core. However, we recommend looking into providing this functionality through Ansible Galaxy via Ansible Collections. You can find more information about collections at:
- * https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html.
+* https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html.
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
The mailing list and irc are great ways to ask questions, or post if you don't think this particular issue is resolved.
See this page for a complete and up to date list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you once again for this and your interest in Ansible!
diff --git a/hacking/ticket_stubs/no_thanks.md b/hacking/ticket_stubs/no_thanks.md
index 3cae1c84f5..2e2143fe61 100644
--- a/hacking/ticket_stubs/no_thanks.md
+++ b/hacking/ticket_stubs/no_thanks.md
@@ -5,15 +5,14 @@ Thanks very much for your submission to Ansible. It means a lot to us that you'
Unfortunately, we're not sure if we want this feature in the program, and I don't want this to seem confrontational.
Our reasons for this are:
- * (A) INSERT ITEM HERE
+* (A) INSERT ITEM HERE
However, we're absolutely always up for discussion.
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
In the future, sometimes starting a discussion on the development list prior to implementing a feature can make getting things included a little easier, but it's not always necessary.
Thank you once again for this and your interest in Ansible!
-
diff --git a/hacking/ticket_stubs/pr_duplicate.md b/hacking/ticket_stubs/pr_duplicate.md
index ef692a0b01..01a2a72809 100644
--- a/hacking/ticket_stubs/pr_duplicate.md
+++ b/hacking/ticket_stubs/pr_duplicate.md
@@ -4,7 +4,7 @@ Thanks very much for your submission to Ansible. It means a lot to us that you'
It looks like the work from this pull request is a duplicate of the following PR(s):
- * INSERT PR(S) HERE
+* INSERT PR(S) HERE
Based on this, we are going to close this PR in favor of the above as a consolidated location to keep track of the issue.
@@ -15,7 +15,6 @@ In the future, sometimes starting a discussion on the development list prior to
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you once again for this and your interest in Ansible!
-
diff --git a/hacking/ticket_stubs/pr_merged.md b/hacking/ticket_stubs/pr_merged.md
index 52c671f9f1..0183ee9063 100644
--- a/hacking/ticket_stubs/pr_merged.md
+++ b/hacking/ticket_stubs/pr_merged.md
@@ -10,6 +10,6 @@ The mailing list and irc are great ways to ask questions, or post if you don't t
See this page for a complete and up to date list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you!
diff --git a/hacking/ticket_stubs/proposal.md b/hacking/ticket_stubs/proposal.md
index 5e5275f24d..25d4cb403f 100644
--- a/hacking/ticket_stubs/proposal.md
+++ b/hacking/ticket_stubs/proposal.md
@@ -8,12 +8,11 @@ https://github.com/ansible/proposals/blob/master/proposals_process_proposal.md
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
The mailing list and irc are great ways to ask questions, or post if you don't think this particular issue is resolved.
- * #ansible-devel on [irc.libera.chat](https://libera.chat/)
- * https://groups.google.com/forum/#!forum/ansible-devel
-
+* #ansible-devel on [irc.libera.chat](https://libera.chat/)
+* https://groups.google.com/forum/#!forum/ansible-devel
Or check this page for a more complete list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you!
diff --git a/hacking/ticket_stubs/question_not_bug.md b/hacking/ticket_stubs/question_not_bug.md
index 10f70fff3c..f4b143fbb6 100644
--- a/hacking/ticket_stubs/question_not_bug.md
+++ b/hacking/ticket_stubs/question_not_bug.md
@@ -4,16 +4,15 @@ Thanks very much for your interest in Ansible. It means a lot to us.
This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.
- * IRC: #ansible on [irc.libera.chat](https://libera.chat/)
- * mailing list: https://groups.google.com/forum/#!forum/ansible-project
+* IRC: #ansible on [irc.libera.chat](https://libera.chat/)
+* mailing list: https://groups.google.com/forum/#!forum/ansible-project
See this page for a complete and up to date list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
If don't you think this particular issue is resolved, you should still stop by there first, we'd appreciate it.
This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.
Thank you once again and we look forward to seeing you on the list or IRC. Thanks!
-
diff --git a/hacking/ticket_stubs/resolved.md b/hacking/ticket_stubs/resolved.md
index 1d132dc3c7..8eedbcfc15 100644
--- a/hacking/ticket_stubs/resolved.md
+++ b/hacking/ticket_stubs/resolved.md
@@ -11,6 +11,6 @@ The mailing list and irc are great ways to ask questions, or post if you don't t
See this page for a complete list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you!
diff --git a/hacking/ticket_stubs/wider_discussion.md b/hacking/ticket_stubs/wider_discussion.md
index 05a6a3d16b..74585816fc 100644
--- a/hacking/ticket_stubs/wider_discussion.md
+++ b/hacking/ticket_stubs/wider_discussion.md
@@ -5,18 +5,17 @@ Thanks very much for your submission to Ansible. It means a lot to us.
We are interested in this idea and would like to see a wider discussion on it on one of our lists.
Reasons for this include:
- * INSERT REASONS!
+* INSERT REASONS!
Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time.
Can you please post on ansible-development list so we can talk about this idea with the wider group?
- * https://groups.google.com/forum/#!forum/ansible-devel
- * Matrix: [#devel:ansible.im](https://matrix.to/#/#devel:ansible.im)
- * #ansible-devel on [irc.libera.chat](https://libera.chat/)
+* https://groups.google.com/forum/#!forum/ansible-devel
+* Matrix: [#devel:ansible.im](https://matrix.to/#/#devel:ansible.im)
+* #ansible-devel on [irc.libera.chat](https://libera.chat/)
For other alternatives, check this page for a more complete list of communication channels and their purposes:
- * https://docs.ansible.com/ansible/latest/community/communication.html
+* https://docs.ansible.com/ansible/latest/community/communication.html
Thank you once again for this and your interest in Ansible!
-
diff --git a/lib/ansible/galaxy/data/container/README.md b/lib/ansible/galaxy/data/container/README.md
index 1b66bdb5a2..f9b791eefc 100644
--- a/lib/ansible/galaxy/data/container/README.md
+++ b/lib/ansible/galaxy/data/container/README.md
@@ -3,7 +3,7 @@
Adds a <SERVICE_NAME> service to your [Ansible Container](https://github.com/ansible/ansible-container) project. Run the following commands
to install the service:
-```
+```shell
# Set the working directory to your Ansible Container project root
$ cd myproject
@@ -15,7 +15,8 @@ $ ansible-container install <USERNAME.ROLE_NAME>
- [Ansible Container](https://github.com/ansible/ansible-container)
- An existing Ansible Container project. To create a project, simply run the following:
- ```
+
+ ```shell
# Create an empty project directory
$ mkdir myproject
@@ -28,7 +29,6 @@ $ ansible-container install <USERNAME.ROLE_NAME>
- Continue listing any prerequisites here...
-
## Role Variables
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set
@@ -45,5 +45,3 @@ BSD
## Author Information
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
-
-
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/failure/README.md b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/failure/README.md
index bf1003fa9e..d158a98721 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/failure/README.md
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/failure/README.md
@@ -1,3 +1,4 @@
README
------
+
This is a simple collection used to test failures with ``ansible-test sanity --test validate-modules``.
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/ps_only/README.md b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/ps_only/README.md
index bbdd513882..9c1c1c34f2 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/ps_only/README.md
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/ps_only/README.md
@@ -1,3 +1,4 @@
README
------
+
This is a simple PowerShell-only collection used to verify that ``ansible-test`` works on a collection.
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.md b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.md
index d8138d3b5b..67b8a83ba9 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.md
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.md
@@ -1,3 +1,4 @@
README
------
+
This is a simple collection used to verify that ``ansible-test`` works on a collection.
diff --git a/test/lib/ansible_test/_internal/commands/sanity/__init__.py b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
index 26822e0710..067d3f0130 100644
--- a/test/lib/ansible_test/_internal/commands/sanity/__init__.py
+++ b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
@@ -878,6 +878,7 @@ class SanityCodeSmellTest(SanitySingleVersion):
self.__include_directories: bool = self.config.get('include_directories')
self.__include_symlinks: bool = self.config.get('include_symlinks')
self.__py2_compat: bool = self.config.get('py2_compat', False)
+ self.__error_code: str | None = self.config.get('error_code', None)
else:
self.output = None
self.extensions = []
@@ -893,6 +894,7 @@ class SanityCodeSmellTest(SanitySingleVersion):
self.__include_directories = False
self.__include_symlinks = False
self.__py2_compat = False
+ self.__error_code = None
if self.no_targets:
mutually_exclusive = (
@@ -912,6 +914,11 @@ class SanityCodeSmellTest(SanitySingleVersion):
raise ApplicationError('Sanity test "%s" option "no_targets" is mutually exclusive with options: %s' % (self.name, ', '.join(problems)))
@property
+ def error_code(self) -> t.Optional[str]:
+ """Error code for ansible-test matching the format used by the underlying test program, or None if the program does not use error codes."""
+ return self.__error_code
+
+ @property
def all_targets(self) -> bool:
"""True if test targets will not be filtered using includes, excludes, requires or changes. Mutually exclusive with no_targets."""
return self.__all_targets
@@ -995,6 +1002,8 @@ class SanityCodeSmellTest(SanitySingleVersion):
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
elif self.output == 'path-message':
pattern = '^(?P<path>[^:]*): (?P<message>.*)$'
+ elif self.output == 'path-line-column-code-message':
+ pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<code>[^:]*): (?P<message>.*)$'
else:
raise ApplicationError('Unsupported output type: %s' % self.output)
@@ -1024,6 +1033,7 @@ class SanityCodeSmellTest(SanitySingleVersion):
path=m['path'],
line=int(m.get('line', 0)),
column=int(m.get('column', 0)),
+ code=m.get('code'),
) for m in matches]
messages = settings.process_errors(messages, paths)
diff --git a/test/sanity/code-smell/pymarkdown.config.json b/test/sanity/code-smell/pymarkdown.config.json
new file mode 100644
index 0000000000..afe83a35c0
--- /dev/null
+++ b/test/sanity/code-smell/pymarkdown.config.json
@@ -0,0 +1,11 @@
+{
+ "plugins": {
+ "line-length": {
+ "line_length": 160,
+ "code_block_line_length": 160
+ },
+ "first-line-heading": {
+ "enabled": false
+ }
+ }
+}
diff --git a/test/sanity/code-smell/pymarkdown.json b/test/sanity/code-smell/pymarkdown.json
new file mode 100644
index 0000000000..986848db4b
--- /dev/null
+++ b/test/sanity/code-smell/pymarkdown.json
@@ -0,0 +1,7 @@
+{
+ "output": "path-line-column-code-message",
+ "error_code": "ansible-test",
+ "extensions": [
+ ".md"
+ ]
+}
diff --git a/test/sanity/code-smell/pymarkdown.py b/test/sanity/code-smell/pymarkdown.py
new file mode 100644
index 0000000000..721c8937ef
--- /dev/null
+++ b/test/sanity/code-smell/pymarkdown.py
@@ -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()
diff --git a/test/sanity/code-smell/pymarkdown.requirements.in b/test/sanity/code-smell/pymarkdown.requirements.in
new file mode 100644
index 0000000000..f0077713f6
--- /dev/null
+++ b/test/sanity/code-smell/pymarkdown.requirements.in
@@ -0,0 +1 @@
+pymarkdownlnt
diff --git a/test/sanity/code-smell/pymarkdown.requirements.txt b/test/sanity/code-smell/pymarkdown.requirements.txt
new file mode 100644
index 0000000000..896f166dac
--- /dev/null
+++ b/test/sanity/code-smell/pymarkdown.requirements.txt
@@ -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
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 5a3c1f4d48..bdb7dd69ac 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -178,3 +178,26 @@ test/units/utils/collection_loader/fixtures/collections_masked/ansible_collectio
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/test_collection_loader.py pylint:undefined-variable # magic runtime local var splatting
+.github/CONTRIBUTING.md pymarkdown:line-length
+hacking/backport/README.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/bug_internal_api.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/bug_wrong_repo.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/collections.md pymarkdown:line-length
+hacking/ticket_stubs/collections.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/guide_newbie_about_gh_and_contributing_to_ansible.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/no_thanks.md pymarkdown:line-length
+hacking/ticket_stubs/no_thanks.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/pr_duplicate.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/pr_merged.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/proposal.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/question_not_bug.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/resolved.md pymarkdown:no-bare-urls
+hacking/ticket_stubs/wider_discussion.md pymarkdown:no-bare-urls
+lib/ansible/galaxy/data/apb/README.md pymarkdown:line-length
+lib/ansible/galaxy/data/container/README.md pymarkdown:line-length
+lib/ansible/galaxy/data/default/role/README.md pymarkdown:line-length
+lib/ansible/galaxy/data/network/README.md pymarkdown:line-length
+README.md pymarkdown:line-length
+test/integration/targets/ansible-vault/invalid_format/README.md pymarkdown:no-bare-urls
+test/support/README.md pymarkdown:no-bare-urls
+test/units/cli/test_data/role_skeleton/README.md pymarkdown:line-length
diff --git a/test/support/README.md b/test/support/README.md
index 850bc9214d..d5244823d1 100644
--- a/test/support/README.md
+++ b/test/support/README.md
@@ -1,4 +1,4 @@
-# IMPORTANT!
+# IMPORTANT
Files under this directory are not actual plugins and modules used by Ansible
and as such should **not be modified**. They are used for testing purposes
diff --git a/test/units/cli/test_data/collection_skeleton/README.md b/test/units/cli/test_data/collection_skeleton/README.md
index 4cfd8afef8..2e3e4ce571 100644
--- a/test/units/cli/test_data/collection_skeleton/README.md
+++ b/test/units/cli/test_data/collection_skeleton/README.md
@@ -1 +1 @@
-A readme \ No newline at end of file
+A readme
diff --git a/test/units/cli/test_data/collection_skeleton/docs/My Collection.md b/test/units/cli/test_data/collection_skeleton/docs/My Collection.md
index 6fa917f23e..0d6781bc71 100644
--- a/test/units/cli/test_data/collection_skeleton/docs/My Collection.md
+++ b/test/units/cli/test_data/collection_skeleton/docs/My Collection.md
@@ -1 +1 @@
-Welcome to my test collection doc for {{ namespace }}. \ No newline at end of file
+Welcome to my test collection doc for {{ namespace }}.
diff --git a/test/units/galaxy/test_collection.py b/test/units/galaxy/test_collection.py
index 6f0622a7b8..991184aec1 100644
--- a/test/units/galaxy/test_collection.py
+++ b/test/units/galaxy/test_collection.py
@@ -824,7 +824,7 @@ def test_build_with_symlink_inside_collection(collection_input):
actual_file = secure_hash_s(linked_file_obj.read())
linked_file_obj.close()
- assert actual_file == '63444bfc766154e1bc7557ef6280de20d03fcd81'
+ assert actual_file == '08f24200b9fbe18903e7a50930c9d0df0b8d7da3' # shasum test/units/cli/test_data/collection_skeleton/README.md
def test_publish_no_wait(galaxy_server, collection_artifact, monkeypatch):