8000 [pull] devel from ansible:devel by pull[bot] · Pull Request #3026 · gundalow/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[pull] devel from ansible:devel #3026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .azure-pipelines/scripts/publish-codecov.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def upload_files(codecov_bin: pathlib.Path, files: t.Tuple[CoverageFile, ...], d
for file in files:
cmd = [
str(codecov_bin),
'--name', file.name,
'--file', str(file.path),
'--name',
file.name,
'--file',
str(file.path),
]

for flag in file.flags:
cmd.extend(['--flags', flag])

Expand Down
13 changes: 8 additions & 5 deletions packaging/cli-doc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def populate_subparser_actions(parser: argparse.ArgumentParser, shared_option_na
@dataclasses.dataclass(frozen=True)
class ActionDoc:
"""Documentation for an action."""

desc: str | None
options: tuple[str, ...]
arg: str | None
Expand All @@ -231,11 +232,13 @@ def get_action_docs(parser: argparse.ArgumentParser) -> list[ActionDoc]:
args = action.dest.upper() if isinstance(action, argparse._StoreAction) else None

if args or action.option_strings:
action_docs.append(ActionDoc(
desc=action.help,
options=tuple(action.option_strings),
arg=args,
))
action_docs.append(
ActionDoc(
desc=action.help,
options=tuple(action.option_strings),
arg=args,
)
)

return action_docs

Expand Down
25 changes: 9 additions & 16 deletions packaging/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,19 @@ def path_to_str(value: t.Any) -> str:


@t.overload
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: t.Literal[True]) -> CompletedProcess:
...
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: t.Literal[True]) -> CompletedProcess: ...


@t.overload
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: t.Literal[False]) -> None:
...
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: t.Literal[False]) -> None: ...


@t.overload
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: bool) -> CompletedProcess | None:
...
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str, capture_output: bool) -> CompletedProcess | None: ...


@t.overload
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str) -> None:
...
def run(*args: t.Any, env: dict[str, t.Any] | None, cwd: pathlib.Path | str) -> None: ...


def run(
Expand Down Expand Up @@ -460,18 +456,15 @@ def apply(self, version: Version) -> Version:


@t.overload
def git(*args: t.Any, capture_output: t.Literal[True]) -> CompletedProcess:
...
def git(*args: t.Any, capture_output: t.Literal[True]) -> CompletedProcess: ...


@t.overload
def git(*args: t.Any, capture_output: t.Literal[False]) -> None:
...
def git(*args: t.Any, capture_output: t.Literal[False]) -> None: ...


@t.overload
def git(*args: t.Any) -> None:
...
def git(*args: t.Any) -> None: ...


def git(*args: t.Any, capture_output: bool = False) -> CompletedProcess | None:
Expand Down Expand Up @@ -1160,8 +1153,8 @@ def generate_summary() -> None:
def generate_changelog() -> None:
"""Generate the changelog and validate the results."""
changelog_requirements = (
ANSIBLE_CHANGELOG_REQUIREMENTS_FILE.read_text() +
ANSIBLE_REQUIREMENTS_FILE.read_text() # TODO: consider pinning the ansible requirements and dependencies
ANSIBLE_CHANGELOG_REQUIREMENTS_FILE.read_text()
+ ANSIBLE_REQUIREMENTS_FILE.read_text() # TODO: consider pinning the ansible requirements and dependencies
)

env = ensure_venv(changelog_requirements)
Expand Down
1 change: 1 addition & 0 deletions test/integration/targets/apt/aliases
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
shippable/posix/group2
destructive
needs/root
skip/freebsd
skip/macos
skip/rhel
1 change: 1 addition & 0 deletions test/integration/targets/become/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ destructive
shippable/posix/group1
context/target
gather_facts/no
needs/root
setup/always/setup_passlib_controller # required for setup_test_user
1 change: 1 addition & 0 deletions test/integration/targets/become_su/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ destructive
shippable/posix/group1
context/target
gather_facts/no
needs/root
needs/target/setup_become_user_pair
needs/target/setup_test_user
setup/always/setup_passlib_controller # required for setup_test_user
Expand Down
1 change: 1 addition & 0 deletions test/integration/targets/become_sudo/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ destructive
shippable/posix/group1
context/target
gather_facts/no
needs/root
needs/target/setup_become_user_pair
needs/target/setup_test_user
setup/always/setup_passlib_controller # required for setup_test_user
1 change: 1 addition & 0 deletions test/integration/targets/deb822_repository/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
destructive
needs/root
shippable/posix/group1
skip/freebsd
skip/osx
Expand Down
1 change: 1 addition & 0 deletions test/integration/targets/hardware_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
destructive
needs/privileged
needs/root
shippable/posix/group4
context/controller
1 change: 1 addition & 0 deletions test/integration/targets/package_facts/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
destructive
needs/root
shippable/posix/group2
skip/macos
1 change: 1 addition & 0 deletions test/integration/targets/slurp/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
shippable/posix/group1
destructive
needs/root
setup/always/setup_passlib_controller # required for setup_test_user
4 changes: 3 additions & 1 deletion test/sanity/code-smell/black.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"prefixes": [
".azure-pipelines/",
"lib/ansible/_internal/",
"lib/ansible/module_utils/_internal/",
"lib/ansible/utils/collection_loader/__init__.py",
"test/sanity/code-smell/black."
"packaging/",
"test/sanity/code-smell/"
],
"extensions": [
".py"
Expand Down
4 changes: 1 addition & 3 deletions test/sanity/code-smell/deprecated-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def main():
data = {}
data['doc'], data['examples'], data['return'], data['metadata'] = get_docstring(plugin, fragment_loader)
for result in find_deprecations(data['doc']):
print(
'%s: %s is scheduled for removal in %s' % (plugin, '.'.join(str(i) for i in result[0][:-2]), result[1])
)
print('%s: %s is scheduled for removal in %s' % (plugin, '.'.join(str(i) for i in result[0][:-2]), result[1]))

base = os.path.join(os.path.dirname(ansible.config.__file__), 'base.yml')
root_path = os.path.dirname(os.path.dirname(os.path.dirname(ansible.__file__)))
Expand Down
40 changes: 21 additions & 19 deletions test/sanity/code-smell/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ def main() -> None:
contexts = (
MyPyContext('ansible-test', ['test/lib/ansible_test/'], controller_python_versions),
MyPyContext('ansible-test', ['test/lib/ansible_test/_util/target/'], remote_only_python_versions),

MyPyContext('ansible-core', ['lib/ansible/'], controller_python_versions),
MyPyContext('ansible-core', ['lib/ansible/modules/', 'lib/ansible/module_utils/'], remote_only_python_versions),

MyPyContext('ansible-core', ['test/units/'], controller_python_versions),
MyPyContext('ansible-core', ['test/units/modules/', 'test/units/module_utils/'], remote_only_python_versions),

MyPyContext('packaging', ['packaging/'], controller_python_versions),
)

Expand All @@ -61,14 +58,16 @@ def main() -> None:

match = re.search(r'^(?P<message>.*) {2}\[(?P<code>.*)]$', message.message)

messages.append(SanityMessage(
message=match.group('message'),
path=message.path,
line=message.line,
column=message.column,
level=message.level,
code=match.group('code'),
))
messages.append(
SanityMessage(
message=match.group('message'),
path=message.path,
line=message.line,
column=message.column,
level=message.level,
code=match.group('code'),
)
)

# FUTURE: provide a way for script based tests to report non-error messages (in this case, notices)

Expand Down Expand Up @@ -172,14 +171,17 @@ def test_context(

parsed = parse_to_list_of_dict(pattern, stdout or '')

messages = [SanityMessage(
level=r['level'],
message=r['message'],
path=r['path'],
line=int(r['line']),
column=int(r.get('column') or '0'),
code='', # extracted from error level messages later
) for r in parsed]
messages = [
SanityMessage(
level=r['level'],
message=r['message'],
path=r['path'],
line=int(r['line']),
column=int(r.get('column') or '0'),
code='', # extracted from error level messages later
)
for r in parsed
]

return messages

Expand Down
3 changes: 1 addition & 2 deletions test/sanity/code-smell/no-unwanted-characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def main():
match = re.search('(\u00a0)', text)

if match:
print('%s:%d:%d: use an ASCII space instead of a Unicode no-break space' % (
path, line + 1, match.start(1) + 1))
print('%s:%d:%d: use an ASCII space instead of a Unicode no-break space' % (path, line + 1, match.start(1) + 1))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion test/sanity/code-smell/no-unwanted-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
continue

ext = os.path.splitext(path)[1]
if ext in ('.yml', ) and any(path.startswith(yaml_directory) for yaml_directory in allow_yaml):
if ext in ('.yml',) and any(path.startswith(yaml_directory) for yaml_directory in allow_yaml):
continue

if ext not in allowed_extensions:
Expand Down
5 changes: 1 addition & 4 deletions test/sanity/code-smell/package-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ def check_files(source: str, expected: list[str], actual: list[str]) -> list[str

filter_fuzzy_matches(missing, extra)

errors = (
[f'{path}: missing from {source}' for path in sorted(missing)] +
[f'{path}: unexpected in {source}' for path in sorted(extra)]
)
errors = [f'{path}: missing from {source}' for path in sorted(missing)] + [f'{path}: unexpected in {source}' for path in sorted(extra)]

return errors

Expand Down
6 changes: 4 additions & 2 deletions test/sanity/code-smell/pymarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def main() -> None:

cmd = [
sys.executable,
'-m', 'pymarkdown',
'--config', pathlib.Path(__file__).parent / 'pymarkdown.config.json',
'-m',
'pymarkdown',
'--config',
pathlib.Path(__file__).parent / 'pymarkdown.config.json',
'--strict-config',
'scan',
] + paths
Expand Down
10 changes: 6 additions & 4 deletions test/sanity/code-smell/test-constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def check_ansible_test(path: str, requirements: list[tuple[int, str, re.Match]])
from ansible_test._internal.coverage_util import COVERAGE_VERSIONS
from ansible_test._internal.util import version_to_str

expected_lines = set((
expected_lines = {
f"coverage == {item.coverage_version} ; python_version >= '{version_to_str(item.min_python)}' and python_version <= '{version_to_str(item.max_python)}'"
for item in COVERAGE_VERSIONS
))
}

for idx, requirement in enumerate(requirements):
lineno, line, match = requirement
Expand All @@ -92,8 +92,10 @@ def check_ansible_test(path: str, requirements: list[tuple[int, str, re.Match]])

def parse_requirements(lines):
# see https://www.python.org/dev/peps/pep-0508/#names
pattern = re.compile(r'^(?P<name>[A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])(?P<extras> *\[[^]]*])?(?P<constraints>[^;#]*)(?P<markers>[^#]*)(?P<comment>.*)$',
re.IGNORECASE)
pattern = re.compile(
pattern=r'^(?P<name>[A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])(?P<extras> *\[[^]]*])?(?P<constraints>[^;#]*)(?P<markers>[^#]*)(?P<comment>.*)$',
flags=re.IGNORECASE,
)

matches = [(lineno, line, pattern.search(line)) for lineno, line in enumerate(lines, start=1)]
requirements = []
Expand Down
36 changes: 17 additions & 19 deletions test/sanity/code-smell/update-bundled.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,17 @@ def get_bundled_metadata(filename):
return None

if line.strip().startswith('# CANT_UPDATE'):
print(
'{0} marked as CANT_UPDATE, so skipping. Manual '
'check for CVEs required.'.format(filename))
print(f'{filename} marked as CANT_UPDATE, so skipping. Manual check for CVEs required.')
return None

if line.strip().startswith('_BUNDLED_METADATA'):
data = line[line.index('{'):].strip()
data = line[line.index('{') :].strip()
break
else:
raise ValueError('Unable to check bundled library for update. Please add'
' _BUNDLED_METADATA dictionary to the library file with'
' information on pypi name and bundled version.')
raise ValueError(
'Unable to check bundled library for update. '
'Please add _BUNDLED_METADATA dictionary to the library file with information on pypi name and bundled version.'
)
metadata = json.loads(data)
return metadata

Expand Down Expand Up @@ -138,20 +137,20 @@ def main():
if filename.startswith('test/support/'):
continue # bundled support code does not need to be updated or tracked

print('{0}: ERROR: File contains _BUNDLED_METADATA but needs to be added to'
' test/sanity/code-smell/update-bundled.py'.format(filename))
print(f'{filename}: ERROR: File contains _BUNDLED_METADATA but needs to be added to test/sanity/code-smell/update-bundled.py')

for filename in bundled_libs:
try:
metadata = get_bundled_metadata(filename)
except ValueError as e:
print('{0}: ERROR: {1}'.format(filename, e))
print(f'{filename}: ERROR: {e}')
continue
except (IOError, OSError) as e:
if e.errno == 2:
print('{0}: ERROR: {1}. Perhaps the bundled library has been removed'
' or moved and the bundled library test needs to be modified as'
' well?'.format(filename, e))
print(
f'{filename}: ERROR: {e}. '
'Perhaps the bundled library has been removed or moved and the bundled library test needs to be modified as well?'
)

if metadata is None:
continue
Expand All @@ -163,12 +162,11 @@ def main():
latest_version = get_latest_applicable_version(pypi_data, constraints)

if LooseVersion(metadata['version']) < LooseVersion(latest_version):
print('{0}: UPDATE {1} from {2} to {3} {4}'.format(
filename,
metadata['pypi_name'],
metadata['version'],
latest_version,
'https://pypi.org/pypi/{0}/json'.format(metadata['pypi_name'])))
name = metadata['pypi_name']
version = metadata['version']
url = f"https://pypi.org/pypi/{name}/json"

print(f"{filename}: UPDATE {name} from {version} to {latest_version} {url}")


if __name__ == '__main__':
Expand Down
0