Skip to content

Commit f256f7e

Browse files
sauragarclaude
andcommitted
[test_operator] Fix pre-commit ansible-lint compatibility with Python 3.13
Configure ansible-lint to use Python 3.12 to avoid ModuleNotFoundError with ansible.parsing.yaml.constructor. Also add full ansible package to provide required dependencies. Auto-fix formatting issues in test_operator README and sync script. Signed-off-by: Saurabh Agarwal <sauragar@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5a8d5b3 commit f256f7e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ repos:
4242
rev: v6.22.2
4343
hooks:
4444
- id: ansible-lint
45+
language_version: python3.12
4546
additional_dependencies:
47+
- ansible>=8.0.0,<9.0.0
4648
- netaddr
4749
- jmespath

roles/test_operator/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/test-operator/).
44

5-
## Generic parameters
5+
## Generic parameters
66
<!-- START GENERIC_PARAMETERS -->
77
* `cifmw_test_operator_artifacts_basedir`: (String) Directory where we will have all test-operator related files. Default value: `{{ cifmw_basedir }}/tests/test_operator` which defaults to `~/ci-framework-data/tests/test_operator`
88
* `cifmw_test_operator_namespace`: (String) Namespace inside which all the resources are created. Default value: `openstack`
@@ -315,4 +315,4 @@ cifmw_test_operator_stages:
315315
- name: tobiko
316316
type: tobiko
317317
test_vars_file: /path/to/tobiko/override/test/file
318-
```
318+
```

scripts/sync_test_operator_var_readme.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,17 @@ def sync():
219219
sections = extract_section_blocks(readme)
220220

221221
grouped_new = {g: {} for g in sections}
222-
existing_vars = {g: parse_existing_variable_blocks(sections[g]["content"]) for g in sections}
222+
existing_vars = {
223+
g: parse_existing_variable_blocks(sections[g]["content"]) for g in sections
224+
}
223225

224226
# Merge defaults with existing variables
225227
for var in defaults:
226228
value = defaults[var]
227229
group = detect_group(var)
228-
grouped_new[group][var] = build_bullet(var, value, existing_vars[group].get(var))
230+
grouped_new[group][var] = build_bullet(
231+
var, value, existing_vars[group].get(var)
232+
)
229233

230234
# Keep variables that exist only in README (but not if they just redirect to defaults)
231235
for group, existing in existing_vars.items():
@@ -249,7 +253,9 @@ def sync():
249253

250254
# Rebuild README
251255
for group in grouped_new:
252-
new_content = "\n".join(grouped_new[group][v] for v in sorted(grouped_new[group]))
256+
new_content = "\n".join(
257+
grouped_new[group][v] for v in sorted(grouped_new[group])
258+
)
253259
pattern = rf"(<!-- START {group} -->)(.*?)(<!-- END {group} -->)"
254260
readme = re.sub(pattern, rf"\1\n{new_content}\n\3", readme, flags=re.DOTALL)
255261

0 commit comments

Comments
 (0)