From 4d31016e8569a2d0461a099293507681a6661503 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 19 Apr 2022 10:21:25 -0700 Subject: ansible-test - Fix rstcheck compatibility issues. --- changelogs/fragments/ansible-test-rstcheck-pin.yml | 2 ++ .../ansible_test/_data/requirements/constraints.txt | 2 +- test/sanity/code-smell/package-data.requirements.txt | 2 +- test/sanity/code-smell/rstcheck-cli.py | 19 +++++++++++++++++++ test/sanity/code-smell/rstcheck.py | 3 ++- test/sanity/code-smell/rstcheck.requirements.txt | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/ansible-test-rstcheck-pin.yml create mode 100644 test/sanity/code-smell/rstcheck-cli.py diff --git a/changelogs/fragments/ansible-test-rstcheck-pin.yml b/changelogs/fragments/ansible-test-rstcheck-pin.yml new file mode 100644 index 0000000000..1330288b52 --- /dev/null +++ b/changelogs/fragments/ansible-test-rstcheck-pin.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test - Update ``rstcheck`` constraint from ``>= 3.3.1`` to ``== 3.3.1`` to avoid breaking changes in newer releases. diff --git a/test/lib/ansible_test/_data/requirements/constraints.txt b/test/lib/ansible_test/_data/requirements/constraints.txt index 2f216f5f50..2cc45a4102 100644 --- a/test/lib/ansible_test/_data/requirements/constraints.txt +++ b/test/lib/ansible_test/_data/requirements/constraints.txt @@ -13,7 +13,7 @@ urllib3 < 1.24 ; python_version < '2.7' # urllib3 1.24 and later require python pywinrm >= 0.3.0 # message encryption support sphinx < 1.6 ; python_version < '2.7' # sphinx 1.6 and later require python 2.7 or later sphinx <= 2.1.2 ; python_version >= '2.7' # docs team hasn't tested beyond 2.1.2 yet -rstcheck >=3.3.1 # required for sphinx version >= 1.8 +rstcheck == 3.3.1 # required for sphinx version >= 1.8 pygments >= 2.4.0 # Pygments 2.4.0 includes bugfixes for YAML and YAML+Jinja lexers wheel < 0.30.0 ; python_version < '2.7' # wheel 0.30.0 and later require python 2.7 or later pycrypto >= 2.6 # Need features found in 2.6 and greater diff --git a/test/sanity/code-smell/package-data.requirements.txt b/test/sanity/code-smell/package-data.requirements.txt index 41b3b5772a..35fd04901c 100644 --- a/test/sanity/code-smell/package-data.requirements.txt +++ b/test/sanity/code-smell/package-data.requirements.txt @@ -1,4 +1,4 @@ -docutils +docutils == 0.16 # required for sphinx compatibility jinja2 packaging pyyaml # ansible-core requirement diff --git a/test/sanity/code-smell/rstcheck-cli.py b/test/sanity/code-smell/rstcheck-cli.py new file mode 100644 index 0000000000..2464933632 --- /dev/null +++ b/test/sanity/code-smell/rstcheck-cli.py @@ -0,0 +1,19 @@ +"""Wrapper around rstcheck to provide Jinja2 compatibility for Sphinx.""" +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import runpy +import sys + +try: + from jinja2.filters import pass_context as _passctx, pass_environment as _passenv + _mod = sys.modules['jinja2'] + _mod.contextfunction = _passctx + _mod.environmentfilter = _passenv +except ImportError: + pass + +sys.path.remove(os.path.dirname(__file__)) # avoid recursively running sanity test + +runpy.run_module('rstcheck', run_name='__main__', alter_sys=True) diff --git a/test/sanity/code-smell/rstcheck.py b/test/sanity/code-smell/rstcheck.py index 885659c3e4..d3d6e8775e 100755 --- a/test/sanity/code-smell/rstcheck.py +++ b/test/sanity/code-smell/rstcheck.py @@ -3,6 +3,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import os import re import subprocess import sys @@ -19,7 +20,7 @@ def main(): cmd = [ sys.executable, - '-m', 'rstcheck', + os.path.join(os.path.dirname(__file__), 'rstcheck-cli.py'), '--report', 'warning', '--ignore-substitutions', ','.join(ignore_substitutions), ] + paths diff --git a/test/sanity/code-smell/rstcheck.requirements.txt b/test/sanity/code-smell/rstcheck.requirements.txt index 4674b8dffe..4030132759 100644 --- a/test/sanity/code-smell/rstcheck.requirements.txt +++ b/test/sanity/code-smell/rstcheck.requirements.txt @@ -1,2 +1,3 @@ rstcheck +docutils == 0.16 # required for sphinx compatibility sphinx # required for full functionality -- cgit v1.2.1