-
Notifications
You must be signed in to change notification settings - Fork 144
[test_operator] Automatic sync of README.md #3589
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
kstrenkova
left a comment
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 PR! I have tested it locally and found a small issue with updating the defaults. It is explained in the comments, the fix should be rather simple. Other than that I saw the README sync was working nicely, so I think you're close to the finish 🎉 I like that the parameters will be in alphabetical order now :D Maybe there could be a mention of the script somewhere in the README so that people know they can use the sync when creating new variables or updating the old ones.
|
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/4de28a813ea54e73883c28ab7ff35c81 ✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 18m 29s |
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 is left are just a few transformations from defaults to to Default value: where it is possible. Other than that lgtm.
kstrenkova
left a comment
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 am adding 2 comments about the same issue atop of my previous comments.
|
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/fe0fdd8386324989bd8ea335a95f52d6 ❌ openstack-k8s-operators-content-provider FAILURE in 4m 53s |
|
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/5eac463796534f4b89b1f990b236fe22 ✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 29m 11s |
f256f7e to
c6e4dd2
Compare
082fce7 to
f2cf98b
Compare
- Add automatic sync script (sync_test_operator_var_readme.py) to keep README.md in sync with defaults/main.yml - Reorganize parameter documentation in alphabetical order - Replace inline default value definitions with references to defaults/main.yml to reduce duplication and improve maintainability - Add auto-sync note at the top of README.md - Fix pre-commit ansible-lint compatibility Signed-off-by: Saurabh Agarwal <sauragar@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
kstrenkova
left a comment
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 am leaving a few very small comments. I think the PR is almost done, so it would be a good idea to ask someone else for a review to get more perspective. I am also not sure about editing the pre-commit and setup_molecule files, we need someone from ci-framework for that :D
|
|
||
| # 1️⃣ Redirect if value is complex | ||
| if should_redirect(value): | ||
| print("should_redirect =", should_redirect(value)) |
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.
When you run the script there are a lot of these prints, which say nothing to the user. I think it could be removed.
| # Convert Python bool to lowercase for consistency | ||
| if isinstance(value, bool): | ||
| value_str = str(value).lower() | ||
| elif value is None: |
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 think the if or elif is needed. It should reflect the real values that are in the defaults/main.yaml file. I am not sure why the value can be None when in the defaults/main.yaml there are no None, so you can correct me.
|
|
||
| def normalize_default_text(block, value): | ||
| # Normalize "Defaults to `x`" → "Default value: `x`" | ||
| block = re.sub( |
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 think this substitution is needed. If someone wanted to, they could also do Default: and this code wouldn't help to keep consistency. So I don't think it's necessary to normalize it, as you can never catch all cases.
michburk
left a comment
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.
A handful of comments and suggestions.
Overall, I understand the motivation to keep the readme up to date by using a script. We've done a pretty poor job of enforcing that the docs be updated with every change to the defaults, but I don't love the idea of designing and maintaining a script specifically for just one role's readme. I'd be curious to see what other cifmw folks have to say.
| README_PATH = Path("roles/test_operator/README.md") | ||
| DEFAULTS_PATH = Path("roles/test_operator/defaults/main.yml") | ||
| DEFAULTS_REL = DEFAULTS_PATH.relative_to("roles/test_operator") | ||
| DEFAULTS_LINK = f"[{DEFAULTS_REL.name}]({DEFAULTS_REL})" |
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.
[blocking] When rendered to html, the links to defaults/main.yml don't lead anywhere. main.yml is presented as a link and you can click on it, but it doesn't do anything. In general, since these docs are also meant to be accessed from the web browser, a suggestion to check main.yml isn't very helpful.
|
|
||
| # CASE 1: Variable already exists in README | ||
| if existing_block: | ||
| # 🔹 Normalize Defaults wording FIRST |
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.
[blocking] No emojis please
(same comment applies to lines 156, 171, and 181)
| # Rebuild README | ||
| for group in grouped_new: | ||
| new_content = "\n".join( | ||
| grouped_new[group][v] for v in sorted(grouped_new[group]) |
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.
[non-blocking] I noticed that the vars are now listed in alphabetical order. I assume there was not much thought put into how the vars were ordered before so this is probably fine, but if there was some meaningful ordering to the vars before, or if you want to order the vars in some meaningful way in the future, it might be worth preserving the order instead of alphabetizing.
Willing to hear others' thoughts on this, feel free to disregard if nobody has any strong feelings :)
| hooks: | ||
| - id: ansible-lint | ||
| additional_dependencies: | ||
| - ansible>=8.0.0,<9.0.0 |
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.
[blocking] +1 to @kstrenkova 's suggestion to not edit .pre-commit-config.yaml and scripts/setup_molecule in this pr. If you'd like to suggest those changes, feel free to open a separate pr. I'd prefer to keep this pr focused strictly on your script and the test_operator readme.
| * `cifmw_test_operator_logs_image`: (String) Image that should be used to collect logs from the pods spawned by the test-operator. Default value: `quay.io/quay/busybox` | ||
| ## Generic parameters | ||
| <!-- START GENERIC_PARAMETERS --> | ||
| * `cifmw_test_operator_artifacts_basedir`: (String) Directory where we will have all test-operator related files. Default value: `{{ cifmw_basedir }}/tests/test_operator` which Default value: `~/ci-framework-data/tests/test_operator` |
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.
Wording here is weird: "Default value: ... which Default value: ..."
| * `cifmw_test_operator_horizontest_registry`: (String) The registry where to pull horizontest container. Default value: `{{ cifmw_test_operator_default_registry }}` | ||
| * `cifmw_test_operator_horizontest_namespace`: (String) Registry's namespace where to pull horizontest container. Default value: `{{ cifmw_test_operator_default_namespace }}` | ||
| * `cifmw_test_operator_horizontest_container`: (String) Name of the horizontest container. Default value: `openstack-horizontest` | ||
| * `cifmw_test_operator_horizontest_image`: (String) Horizontest image to be used. Default value: `{{ cifmw_test_operator_horizontest_registry }}/{{ cifmw_test_operator_horizontest_namespace }}/{{ cifmw_test_operator_horizontest_container }}` |
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.
[Maybe blocking?] I see that several vars in the updated version of the readme get their default values changed from some specific value (like {{ cifmw_test_operator_horizontest_registry }}/{{ cifmw_test_operator_horizontest_namespace }}/{{ cifmw_test_operator_horizontest_container }} in this example) to see defaults in main.yml. Would it be possible to preserve more of these values rather than replacing with see defaults?
This commit will ensure to have the proper auto-sync of README.md with the defaults/main.yml file and also added the post-commit file so whenever someone commits in the defaults/main.yml file the script can be auto-run
Ticket: OSPRH-19423
This PR #3327 is closed since I am not able to reopen the PR
Signing off: Saurabh Agarwal sauragar@redhat.com