add required file to collection skeleton (#77418)

* add required file to collection skeleton

This file is required to be able to upload a collection.

It is present in
https://github.com/ansible-collections/collection_template/blob/main/meta/runtime.yml
but that does not get used by default.

Without this, if you use the "ansible-galaxy collection init" command
and you try and publish that collection without adding this file, you
get the error:

"ERROR! Galaxy import process failed: 'requires_ansible' in
meta/runtime.yml is mandatory, but no meta/runtime.yml found (Code:
UNKNOWN)"

Also updates relevant test and adds a changelog fragment
pull/78593/head
Elijah DeLee 2 years ago committed by GitHub
parent 8dc097989b
commit f9a450551d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-galaxy - fix missing meta/runtime.yml in default galaxy skeleton used for ansible-galaxy collection init

@ -0,0 +1,4 @@
---
# Collections must specify a minimum required ansible version to upload
# to galaxy
# requires_ansible: '>=2.9.10'

@ -19,10 +19,11 @@
assert: assert:
that: that:
- '"Collection ansible_test.my_collection was created successfully" in init_relative.stdout' - '"Collection ansible_test.my_collection was created successfully" in init_relative.stdout'
- init_relative_actual.files | length == 3 - init_relative_actual.files | length == 4
- (init_relative_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles'] - (init_relative_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_relative_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles'] - (init_relative_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_relative_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles'] - (init_relative_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_relative_actual.files | map(attribute='path') | list)[3] | basename in ['docs', 'plugins', 'roles', 'meta']
- name: create collection with custom init path - name: create collection with custom init path
command: ansible-galaxy collection init ansible_test2.my_collection --init-path "{{ galaxy_dir }}/scratch/custom-init-dir" {{ galaxy_verbosity }} command: ansible-galaxy collection init ansible_test2.my_collection --init-path "{{ galaxy_dir }}/scratch/custom-init-dir" {{ galaxy_verbosity }}
@ -38,10 +39,11 @@
assert: assert:
that: that:
- '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout' - '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout'
- init_custom_path_actual.files | length == 3 - init_custom_path_actual.files | length == 4
- (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[3] | basename in ['docs', 'plugins', 'roles', 'meta']
- name: add a directory to the init collection path to test that --force removes it - name: add a directory to the init collection path to test that --force removes it
file: file:
@ -62,10 +64,10 @@
assert: assert:
that: that:
- '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout' - '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout'
- init_custom_path_actual.files | length == 3 - init_custom_path_actual.files | length == 4
- (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles', 'meta']
- name: create collection in cwd with custom init path - name: create collection in cwd with custom init path
command: ansible-galaxy collection init ansible_test2.my_collection --init-path ../../ --force {{ galaxy_verbosity }} command: ansible-galaxy collection init ansible_test2.my_collection --init-path ../../ --force {{ galaxy_verbosity }}
@ -83,10 +85,10 @@
assert: assert:
that: that:
- '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout' - '"Collection ansible_test2.my_collection was created successfully" in init_custom_path.stdout'
- init_custom_path_actual.files | length == 3 - init_custom_path_actual.files | length == 4
- (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[0] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[1] | basename in ['docs', 'plugins', 'roles', 'meta']
- (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles'] - (init_custom_path_actual.files | map(attribute='path') | list)[2] | basename in ['docs', 'plugins', 'roles', 'meta']
- name: create collection for ignored files and folders - name: create collection for ignored files and folders
command: ansible-galaxy collection init ansible_test.ignore command: ansible-galaxy collection init ansible_test.ignore

@ -640,7 +640,7 @@ def test_collection_build(collection_artifact):
tar_members = tar.getmembers() tar_members = tar.getmembers()
valid_files = ['MANIFEST.json', 'FILES.json', 'roles', 'docs', 'plugins', 'plugins/README.md', 'README.md', valid_files = ['MANIFEST.json', 'FILES.json', 'roles', 'docs', 'plugins', 'plugins/README.md', 'README.md',
'runme.sh'] 'runme.sh', 'meta', 'meta/runtime.yml']
assert len(tar_members) == len(valid_files) assert len(tar_members) == len(valid_files)
# Verify the uid and gid is 0 and the correct perms are set # Verify the uid and gid is 0 and the correct perms are set
@ -696,16 +696,16 @@ def test_collection_build(collection_artifact):
finally: finally:
files_file.close() files_file.close()
assert len(files['files']) == 7 assert len(files['files']) == 9
assert files['format'] == 1 assert files['format'] == 1
assert len(files.keys()) == 2 assert len(files.keys()) == 2
valid_files_entries = ['.', 'roles', 'docs', 'plugins', 'plugins/README.md', 'README.md', 'runme.sh'] valid_files_entries = ['.', 'roles', 'docs', 'plugins', 'plugins/README.md', 'README.md', 'runme.sh', 'meta', 'meta/runtime.yml']
for file_entry in files['files']: for file_entry in files['files']:
assert file_entry['name'] in valid_files_entries assert file_entry['name'] in valid_files_entries
assert file_entry['format'] == 1 assert file_entry['format'] == 1
if file_entry['name'] in ['plugins/README.md', 'runme.sh']: if file_entry['name'] in ['plugins/README.md', 'runme.sh', 'meta/runtime.yml']:
assert file_entry['ftype'] == 'file' assert file_entry['ftype'] == 'file'
assert file_entry['chksum_type'] == 'sha256' assert file_entry['chksum_type'] == 'sha256'
# Can't test the actual checksum as the html link changes based on the version or the file contents # Can't test the actual checksum as the html link changes based on the version or the file contents

Loading…
Cancel
Save