forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible-test - Update import test and sanity requirements. (ansible#7…
…6308) * Add script to freeze sanity requirements. * Declare sanity test requirements and freeze * Use pinned requirements for import.plugin test. * Expand scope of import test for ansible-core. * Add ignores for galaxy import errors. * Update test-constraints sanity test.
- Loading branch information
Showing
42 changed files
with
380 additions
and
176 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
4 changes: 4 additions & 0 deletions
4
changelogs/fragments/ansible-test-sanity-requirements-update.yaml
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,4 @@ | ||
minor_changes: | ||
- ansible-test - Declare public dependencies of ansible-core and use to limit unguarded imports in plugins. | ||
- ansible-test - Requirements for the plugin import test are now frozen. | ||
- ansible-test - Update sanity test requirements. |
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,112 @@ | ||
#!/usr/bin/env python | ||
# PYTHON_ARGCOMPLETE_OK | ||
"""Generate frozen sanity test requirements from source requirements files.""" | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import dataclasses | ||
import pathlib | ||
import subprocess | ||
import tempfile | ||
import typing as t | ||
import venv | ||
|
||
try: | ||
import argcomplete | ||
except ImportError: | ||
argcomplete = None | ||
|
||
|
||
FILE = pathlib.Path(__file__).resolve() | ||
ROOT = FILE.parent.parent | ||
SELF = FILE.relative_to(ROOT) | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class SanityTest: | ||
name: str | ||
requirements_path: pathlib.Path | ||
source_path: pathlib.Path | ||
|
||
def freeze_requirements(self) -> None: | ||
with tempfile.TemporaryDirectory() as venv_dir: | ||
venv.create(venv_dir, with_pip=True) | ||
|
||
python = pathlib.Path(venv_dir, 'bin', 'python') | ||
pip = [python, '-m', 'pip', '--disable-pip-version-check'] | ||
env = dict() | ||
|
||
pip_freeze = subprocess.run(pip + ['freeze'], env=env, check=True, capture_output=True, text=True) | ||
|
||
if pip_freeze.stdout: | ||
raise Exception(f'Initial virtual environment is not empty:\n{pip_freeze.stdout}') | ||
|
||
subprocess.run(pip + ['install', 'wheel'], env=env, check=True) # make bdist_wheel available during pip install | ||
subprocess.run(pip + ['install', '-r', self.source_path], env=env, check=True) | ||
|
||
pip_freeze = subprocess.run(pip + ['freeze'], env=env, check=True, capture_output=True, text=True) | ||
|
||
requirements = f'# edit "{self.source_path.name}" and generate with: {SELF} --test {self.name}\n{pip_freeze.stdout}' | ||
|
||
with open(self.requirements_path, 'w') as requirement_file: | ||
requirement_file.write(requirements) | ||
|
||
@staticmethod | ||
def create(path: pathlib.Path) -> SanityTest: | ||
return SanityTest( | ||
name=path.stem.replace('sanity.', '').replace('.requirements', ''), | ||
requirements_path=path, | ||
source_path=path.with_suffix('.in'), | ||
) | ||
|
||
|
||
def main() -> None: | ||
tests = find_tests() | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'--test', | ||
metavar='TEST', | ||
dest='test_names', | ||
action='append', | ||
choices=[test.name for test in tests], | ||
help='test requirements to update' | ||
) | ||
|
||
if argcomplete: | ||
argcomplete.autocomplete(parser) | ||
|
||
args = parser.parse_args() | ||
test_names: set[str] = set(args.test_names or []) | ||
|
||
tests = [test for test in tests if test.name in test_names] if test_names else tests | ||
|
||
for test in tests: | ||
print(f'===[ {test.name} ]===') | ||
test.freeze_requirements() | ||
|
||
|
||
def find_tests() -> t.List[SanityTest]: | ||
globs = ( | ||
'test/lib/ansible_test/_data/requirements/sanity.*.txt', | ||
'test/sanity/code-smell/*.requirements.txt', | ||
) | ||
|
||
tests: t.List[SanityTest] = [] | ||
|
||
for glob in globs: | ||
tests.extend(get_tests(pathlib.Path(glob))) | ||
|
||
return sorted(tests, key=lambda test: test.name) | ||
|
||
|
||
def get_tests(glob: pathlib.Path) -> t.List[SanityTest]: | ||
path = pathlib.Path(ROOT, glob.parent) | ||
pattern = glob.name | ||
|
||
return [SanityTest.create(item) for item in path.glob(pattern)] | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
3 changes: 3 additions & 0 deletions
3
test/lib/ansible_test/_data/requirements/sanity.ansible-doc.in
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,3 @@ | ||
jinja2 # ansible-core requirement | ||
packaging # ansible-core requirement | ||
pyyaml # ansible-core requirement |
13 changes: 6 additions & 7 deletions
13
test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
jinja2 == 3.0.1 # ansible-core requirement | ||
pyyaml == 5.4.1 # ansible-core requirement | ||
packaging == 21.0 # ansible-doc requirement | ||
|
||
# dependencies | ||
MarkupSafe == 2.0.1 | ||
pyparsing == 2.4.7 | ||
# edit "sanity.ansible-doc.in" and generate with: hacking/update-sanity-requirements.py --test ansible-doc | ||
Jinja2==3.0.3 | ||
MarkupSafe==2.0.1 | ||
packaging==21.2 | ||
pyparsing==2.4.7 | ||
PyYAML==6.0 |
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,2 @@ | ||
antsibull-changelog | ||
docutils < 0.18 # match version required by sphinx in the docs-build sanity test |
17 changes: 8 additions & 9 deletions
17
test/lib/ansible_test/_data/requirements/sanity.changelog.txt
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
antsibull-changelog == 0.9.0 | ||
|
||
# dependencies | ||
pyyaml == 5.4.1 | ||
docutils == 0.17.1 | ||
packaging == 21.0 | ||
pyparsing == 2.4.7 | ||
rstcheck == 3.3.1 | ||
semantic-version == 2.8.5 | ||
# edit "sanity.changelog.in" and generate with: hacking/update-sanity-requirements.py --test changelog | ||
antsibull-changelog==0.12.0 | ||
docutils==0.17.1 | ||
packaging==21.2 | ||
pyparsing==2.4.7 | ||
PyYAML==6.0 | ||
rstcheck==3.3.1 | ||
semantic-version==2.8.5 |
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 @@ | ||
pyyaml # needed for yaml_to_json.py |
2 changes: 2 additions & 0 deletions
2
test/lib/ansible_test/_data/requirements/sanity.import.plugin.in
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,2 @@ | ||
jinja2 # ansible-core requirement | ||
pyyaml # ansible-core requirement |
4 changes: 4 additions & 0 deletions
4
test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt
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,4 @@ | ||
# edit "sanity.import.plugin.in" and generate with: hacking/update-sanity-requirements.py --test import.plugin | ||
Jinja2==3.0.3 | ||
MarkupSafe==2.0.1 | ||
PyYAML==6.0 |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pyyaml == 5.4.1 # needed for yaml_to_json.py | ||
# edit "sanity.import.in" and generate with: hacking/update-sanity-requirements.py --test import | ||
PyYAML==6.0 |
1 change: 1 addition & 0 deletions
1
test/lib/ansible_test/_data/requirements/sanity.integration-aliases.in
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 @@ | ||
pyyaml |
3 changes: 2 additions & 1 deletion
3
test/lib/ansible_test/_data/requirements/sanity.integration-aliases.txt
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pyyaml == 5.4.1 | ||
# edit "sanity.integration-aliases.in" and generate with: hacking/update-sanity-requirements.py --test integration-aliases | ||
PyYAML==6.0 |
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 @@ | ||
pycodestyle |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pycodestyle == 2.6.0 | ||
# edit "sanity.pep8.in" and generate with: hacking/update-sanity-requirements.py --test pep8 | ||
pycodestyle==2.8.0 |
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,2 @@ | ||
pylint == 2.9.3 # currently vetted version | ||
pyyaml # needed for collection_detail.py |
19 changes: 9 additions & 10 deletions
19
test/lib/ansible_test/_data/requirements/sanity.pylint.txt
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
pylint == 2.9.3 | ||
pyyaml == 5.4.1 # needed for collection_detail.py | ||
|
||
# dependencies | ||
astroid == 2.6.6 | ||
isort == 5.9.3 | ||
lazy-object-proxy == 1.6.0 | ||
mccabe == 0.6.1 | ||
toml == 0.10.2 | ||
wrapt == 1.12.1 | ||
# edit "sanity.pylint.in" and generate with: hacking/update-sanity-requirements.py --test pylint | ||
astroid==2.6.6 | ||
isort==5.10.1 | ||
lazy-object-proxy==1.6.0 | ||
mccabe==0.6.1 | ||
pylint==2.9.3 | ||
PyYAML==6.0 | ||
toml==0.10.2 | ||
wrapt==1.12.1 |
2 changes: 2 additions & 0 deletions
2
test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.in
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,2 @@ | ||
pyyaml | ||
voluptuous |
5 changes: 3 additions & 2 deletions
5
test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pyyaml == 5.4.1 | ||
voluptuous == 0.12.1 | ||
# edit "sanity.runtime-metadata.in" and generate with: hacking/update-sanity-requirements.py --test runtime-metadata | ||
PyYAML==6.0 | ||
voluptuous==0.12.2 |
3 changes: 3 additions & 0 deletions
3
test/lib/ansible_test/_data/requirements/sanity.validate-modules.in
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,3 @@ | ||
jinja2 # ansible-core requirement | ||
pyyaml # needed for collection_detail.py | ||
voluptuous |
11 changes: 5 additions & 6 deletions
11
test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
jinja2 == 3.0.1 # ansible-core requirement | ||
pyyaml == 5.4.1 # needed for collection_detail.py | ||
voluptuous == 0.12.1 | ||
|
||
# dependencies | ||
MarkupSafe == 2.0.1 | ||
# edit "sanity.validate-modules.in" and generate with: hacking/update-sanity-requirements.py --test validate-modules | ||
Jinja2==3.0.3 | ||
MarkupSafe==2.0.1 | ||
PyYAML==6.0 | ||
voluptuous==0.12.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 @@ | ||
yamllint |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
yamllint == 1.26.0 | ||
|
||
# dependencies | ||
pathspec == 0.9.0 | ||
pyyaml == 5.4.1 | ||
# edit "sanity.yamllint.in" and generate with: hacking/update-sanity-requirements.py --test yamllint | ||
pathspec==0.9.0 | ||
PyYAML==6.0 | ||
yamllint==1.26.3 |
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
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,2 @@ | ||
pyyaml | ||
voluptuous |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pyyaml == 5.4.1 | ||
voluptuous == 0.12.1 | ||
# edit "botmeta.requirements.in" and generate with: hacking/update-sanity-requirements.py --test botmeta | ||
PyYAML==6.0 | ||
voluptuous==0.12.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,2 @@ | ||
jinja2 # ansible-core requirement | ||
pyyaml |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
jinja2 == 3.0.1 # ansible-core requirement | ||
pyyaml == 5.4.1 | ||
|
||
# dependencies | ||
MarkupSafe == 2.0.1 | ||
# edit "deprecated-config.requirements.in" and generate with: hacking/update-sanity-requirements.py --test deprecated-config | ||
Jinja2==3.0.3 | ||
MarkupSafe==2.0.1 | ||
PyYAML==6.0 |
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,8 @@ | ||
jinja2 | ||
pyyaml | ||
resolvelib < 0.6.0 | ||
sphinx == 4.2.0 | ||
sphinx-notfound-page | ||
sphinx-ansible-theme | ||
straight.plugin | ||
antsibull |
Oops, something went wrong.