Skip to content
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

Incompatibility with yamllint (yaml rule) and antsibull-changelog #4033

Closed
alisonlhart opened this issue Feb 16, 2024 · 2 comments
Closed

Incompatibility with yamllint (yaml rule) and antsibull-changelog #4033

alisonlhart opened this issue Feb 16, 2024 · 2 comments
Labels

Comments

@alisonlhart
Copy link
Contributor

Summary

(Initially I thought this was a schema issue, but it appears to be an incompatibility with the yaml ansible-lint rule, aka yamllint, and how antsibull-changelog uses PyYAML to output changelog files.)

Antsibull-changelog currently outputs changelog.yaml files in a way that will always cause the yaml rule to error. It outputs change lists at the same indentation as the change type descriptor. For example, this is what yamllint expects for items under major_changes (or bugfixes, or minor_changes, etc):

releases:
  1.0.0:
    release_date: '2020-04-01'
    codename: White Rabbit
    changes:
      release_summary: This is the initial White Rabbit release. Enjoy!
      major_changes:
        - The authentication method handling has been rewritten.   # Two spaces indented from `major changes`

and this is how antsibull-changelog outputs:

releases:
  1.0.0:
    release_date: '2020-04-01'
    codename: White Rabbit
    changes:
      release_summary: This is the initial White Rabbit release. Enjoy!
      major_changes:
      - The authentication method handling has been rewritten.   # No indention from `major changes

This will always cause a two-space indentation yaml[indentation] ansible-lint error by default. Some ansible-lint users have custom .yamllint config files to get around this, but ideally there should be compatibility or config options to meet compatibility.

I've opened an enhancement issue on antsibull-changelog here: ansible-community/antsibull-changelog#152, but wanted to raise this here as well in case there is an alternative solution through lint.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 24.2.0 using ansible-core:2.15.4 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8

Installed via source, then upgraded.

STEPS TO REPRODUCE

Generate a changelog using antsibull-changelog that contains a change type (major_changes, minor_changes, etc), then run ansible-lint (latest).

Desired Behavior

ansible-lint should pass with the default antsibull-changelog generated changelog.yaml file.

Actual Behavior

An error similar to the below will appear:

yaml[indentation]: Wrong indentation: expected 8 but found 6
changelogs/changelog.yaml:11
@alisonlhart alisonlhart added bug new Triage required labels Feb 16, 2024
@ssbarnea
Copy link
Member

ssbarnea commented Feb 17, 2024

pyyaml can be configured to dump data in a way that is passing our validation. See https://stackoverflow.com/questions/25108581/python-yaml-dump-bad-indentation

If user creates an .yammlint config file within the repo it can change the behaviour or the linter.

@alisonlhart
Copy link
Contributor Author

@ssbarnea Hmm, as felix suggested in the antsibull-changelog issue, maybe we just recommend for folks to use prettier to reformat...

@ssbarnea ssbarnea removed the new Triage required label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants