-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature. Add chapter 'Lists of dictionaries' to docsite #8482
Feature. Add chapter 'Lists of dictionaries' to docsite #8482
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
For the record: There seems to be a problem with shell> git pull --rebase upstream main
From https://github.com/ansible-collections/community.general
* branch main -> FETCH_HEAD
The current branch feature-docsite-keep_keys is up to date.
shell> git push --force-with-lease
Everything up-to-date |
I think |
Thank you for the comment! |
@vbotka this now has a conflict. |
a751ff9
to
618855f
Compare
This file shouldn't be included in the PR. I rebased the PR and resolved the conflict. Sorry for the noise. I tested all helpers and docsite. This PR should be ready. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this (and similar) files? I'm not sure what ansible-test.cfg files are doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to use integration tests in the examples:
- Run the integration tests using ansible-test.cfg
- Create the examples
- Run playbook.yml and create RST using ansible.cfg
This scheme is WIP. I'll create README when completed.
- You can run integration tests in the development copy using ansible-test.cfg. For example, put the development copy into the directory
/scratch/admin/ansible.community.general
The parameter roles_path
points to the roles
roles_path = /scratch/admin/ansible.community.general/tests/integration/targets
and the parameter collections_path
points to this collection
collections_path = /scratch/collections
shell>ll /scratch/collections/ansible_collections/community/
general -> /scratch/admin/ansible.community.general/
This is an example. Fit the paths to your needs. Then, the below play
shell> cat pb-test.yml
- name: ansible.community.general/tests/integration/targets/filter_keep_keys
hosts: localhost
roles:
- filter_keep_keys
will run the integration tests
(env) > ANSIBLE_CONFIG=$PWD/ansible-test.cfg ansible-playbook pb-test.yml
PLAY [ansible.community.general/tests/integration/targets/filter_keep_keys] *****************************************
TASK [filter_keep_keys : Debug ansible_version] *********************************************************************
skipping: [localhost]
TASK [filter_keep_keys : Test keep keys equal (default)] ************************************************************
ok: [localhost]
TASK [filter_keep_keys : Test keep keys regex string] ***************************************************************
ok: [localhost]
TASK [filter_keep_keys : Test keep keys targets1] *******************************************************************
ok: [localhost] => (item=equal: ['k0_x0', 'k1_x1'])
ok: [localhost] => (item=starts_with: ['k0', 'k1'])
ok: [localhost] => (item=ends_with: ['x0', 'x1'])
ok: [localhost] => (item=regex: ['^.*[01]_x.*$'])
ok: [localhost] => (item=regex: ^.*[01]_x.*$)
TASK [filter_keep_keys : Test keep keys targets2] *******************************************************************
ok: [localhost] => (item=equal: k0_x0)
ok: [localhost] => (item=starts_with: k0)
ok: [localhost] => (item=ends_with: x0)
ok: [localhost] => (item=regex: ^.*0_x.*$)
PLAY RECAP **********************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
- Create examples when the integration tests are OK. See:
- examples.yml ........... list of examples
- *.j2 ............................. templates
- playbook.yml ............ playbook
- Create RST
(env) > ansible-playbook -e @extra-vars.yml playbook.yml
HTH. I propose to consolidate all helpers later (keep_keys, lists_mergeby, remove_keys, and replace_keys). I believe that this can be further simplified when the picture is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you don't simply run the integration tests with ansible-test integration filter_keep_keys
. That's a lot simpler than having to do all these steps and modify the contents of a file checked into this repository (to adjust the paths).
Also assuming you checked out the collection in the right directory structure that's added to ansible-core's COLLECTIONS_PATH (as described on https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_test_pr_locally.html), you can simply run ansible-playbook playbook.yml
in the directory without the special ansible.cfg
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the clarification! I'll consolidate this mess.
JFYI, links to the clones do not work. In the below example, ansible-test will fail if general is a link
shell> pwd
/scratch/collections/ansible_collections/community/general
shell> ansible-test env
FATAL: The current working directory must be within the source tree being tested.
All is right if I copy general to the path
shell> pwd
/scratch/collections/ansible_collections/community/general
shell> ansible-test env
ansible:
version: 2.16.3
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I generally clone the repo inside the ansible_collections path structure, instead of linking to the 'real' clone from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to review the PR? The docs are generated from the integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced that coupling the integration tests (which are tests run in CI) are coupled to docs generation (these are NOT run in CI!). Anytime now someone modifies the tests they break the docs build process, without anyone noticing.
IMO docs creation should be completely separate from integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced that coupling the integration tests (which are tests run in CI) are coupled to docs generation (these are NOT run in CI!).
This is not a coupling. The tests are not coupled to the docs. The docs take advantage of a friendly test structure if possible. There are only advantages:
- Single source for tests and examples.
- Already tested examples.
- Automatic generation of the documentation = lower rate of typing errors.
The variable tests in tests/integration/targets/filter_keep_keys/vars/main/tests.yml
is a list. You can select items in the template, e.g.
{% for i in tests[0:1]|subelements('group') %}
...
Anytime now someone modifies the tests they break the docs build process, without anyone noticing.
This is not the case. The helper playbooks create the rst file locally in the helper directory. You have to copy it manually to the rst directory. I have no problem if anybody updates the docs files directly in the rst directory. The helper can be synchronized anytime if needed. Use it if you want to. It's not mandatory, of course.
IMO docs creation should be completely separate from integration tests.
OK. Nothing in this PR makes the integration tests not completely separated. Still, you can use the list tests in the docs if you want to. I would go even further and propose creating also the plugin's examples similarly for the same reasons.
Ultimately, you can anytime copy the tests list to the helper if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the helpers. The feasibility is up to you.
21f0158
to
6bca180
Compare
* Update integration tests of keep_keys and remove_keys * Update docs helpers of keep_keys and remove_keys
…ns-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]>
…ns-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
For files that do not support comments, you can add a |
Thank you! I used this and simplified templates. |
Backport to stable-9: 💚 backport PR created✅ Backport PR branch: Backported as #8582 🤖 @patchback |
* Feature. Add chapter 'Lists of dictionaries' * Fix copyright and licensing. * Add maintainers for docsite chapter 'Lists of dictionaries'. * Generate docs keep_keys and remove_keys * Update integration tests of keep_keys and remove_keys * Update docs helpers of keep_keys and remove_keys * Fix copyright and licensing. * Fix remove license from templates. Cleanup. * Add docs helper replace_keys * Update integration test filter_replace_keys * Generate and update: filter_guide-abstract_informations-lists_of_dictionaries-replace_keys.rst * Formatting improved. * Fix results Jinja quotation marks. * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Fix references. * Updated helpers. * Fix licenses. Simplified templates. * Fix licenses. * Fix README. --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit caecb22)
@vbotka thanks for your contribution! |
… dictionaries' to docsite (#8582) Feature. Add chapter 'Lists of dictionaries' to docsite (#8482) * Feature. Add chapter 'Lists of dictionaries' * Fix copyright and licensing. * Add maintainers for docsite chapter 'Lists of dictionaries'. * Generate docs keep_keys and remove_keys * Update integration tests of keep_keys and remove_keys * Update docs helpers of keep_keys and remove_keys * Fix copyright and licensing. * Fix remove license from templates. Cleanup. * Add docs helper replace_keys * Update integration test filter_replace_keys * Generate and update: filter_guide-abstract_informations-lists_of_dictionaries-replace_keys.rst * Formatting improved. * Fix results Jinja quotation marks. * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Fix references. * Updated helpers. * Fix licenses. Simplified templates. * Fix licenses. * Fix README. --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit caecb22) Co-authored-by: Vladimir Botka <[email protected]>
@felixfontein thank you! |
…ections#8482) * Feature. Add chapter 'Lists of dictionaries' * Fix copyright and licensing. * Add maintainers for docsite chapter 'Lists of dictionaries'. * Generate docs keep_keys and remove_keys * Update integration tests of keep_keys and remove_keys * Update docs helpers of keep_keys and remove_keys * Fix copyright and licensing. * Fix remove license from templates. Cleanup. * Add docs helper replace_keys * Update integration test filter_replace_keys * Generate and update: filter_guide-abstract_informations-lists_of_dictionaries-replace_keys.rst * Formatting improved. * Fix results Jinja quotation marks. * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Update docs/docsite/helper/keep_keys/filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst.j2 Co-authored-by: Felix Fontein <[email protected]> * Fix references. * Updated helpers. * Fix licenses. Simplified templates. * Fix licenses. * Fix README. --------- Co-authored-by: Felix Fontein <[email protected]>
SUMMARY
Add filter_guide -> abstract_informations -> lists_of_dictionaries:
ISSUE TYPE
COMPONENT NAME
filter_guide-abstract_informations-lists_of_dictionaries.rst
filter_guide-abstract_informations-lists_of_dictionaries-remove_keys.rst
filter_guide-abstract_informations-lists_of_dictionaries-replace_keys.rst
filter_guide-abstract_informations-lists_of_dictionaries-keep_keys.rst
ADDITIONAL INFORMATION
Created helpers:
Create RST files by running the below command in the helper/*_keys directory
shell> ansible-playbook playbook.yml