galaxy: Skip verification for unwanted files (#82162)

Fixes: #81628

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/82744/head
Abhijeet Kasurde 3 months ago committed by GitHub
parent 4edd6ba04f
commit 03246dc0ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
---
bugfixes:
- galaxy - skip verification for unwanted Python compiled bytecode files (https://github.com/ansible/ansible/issues/81628).

@ -333,11 +333,18 @@ def verify_local_collection(local_collection, remote_collection, artifacts_manag
os.path.join(b_collection_path, to_bytes(name, errors='surrogate_or_strict'))
)
b_ignore_patterns = [
b'*.pyc',
]
# Find any paths not in the FILES.json
for root, dirs, files in os.walk(b_collection_path):
for name in files:
full_path = os.path.join(root, name)
path = to_text(full_path[len(b_collection_path) + 1::], errors='surrogate_or_strict')
if any(fnmatch.fnmatch(full_path, b_pattern) for b_pattern in b_ignore_patterns):
display.v("Ignoring verification for %s" % full_path)
continue
if full_path not in collection_files:
modified_content.append(

@ -270,6 +270,16 @@
path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/test_new_dir'
state: directory
- name: create a new ignore directory
file:
path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__'
state: directory
- name: create a new ignore file
file:
path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__/test.cpython-311.pyc'
state: touch
- name: verify modified collection locally-only (should fail)
command: ansible-galaxy collection verify --offline ansible_test.verify
register: verify
@ -282,6 +292,7 @@
- "'plugins/modules/test_module.py' in verify.stdout"
- "'plugins/modules/test_new_file.py' in verify.stdout"
- "'plugins/modules/test_new_dir' in verify.stdout"
- "'plugins/modules/__pycache__/test.cpython-311.pyc' not in verify.stdout"
# TODO: add a test for offline Galaxy signature metadata

Loading…
Cancel
Save