ansible-community / antsichaut

Antsichaut aims to automate the filling of a changelog.yaml used by antsibull-changelog

Home Page:https://pypi.org/project/antsichaut/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

changelog.yaml getting screwed up

gardar opened this issue · comments

Ran into a issue where changelog.yaml got screwed up somehow.

I'm not sure what exactly caused it, but it seems like it's somehow related to when the collection got moved from a single-digit minor edition to a double-digit one (from version 0.9.0 to 0.10.0).

I noticed that the last change to the changelog that happened prior to the indent getting screwed up was that version 0.10.0 got added to the changelog but it is missing the changes key.

  0.10.0:
    release_date: '2023-12-12'

Looking through the history of the file I see that for other versions the changes key is always added when a new version is added to the changelog, such as:

  0.9.1:
    changes:
      trivial:
        - 'patch: New prometheus/prometheus upstream release 2.48.1! (https://github.com/prometheus-community/ansible/pull/260)'
    release_date: '2023-12-10'

At the same time where the changelog.yaml indent got screwed up it also added a new section for version 0.10.1 which is missing the changes key.

It also looks like the sorting does not understand the semantic versioning fully as versions 0.10.0 and 0.10.1 are inserted between the last 0.1.x version and first 0.2.x version and not after version 0.9.x as you'd expect.

  0.1.5:
    changes:
      bugfixes:
      - 'fix: follow PEP 440 standard for supported ansible versions (https://github.com/prometheus-community/ansible/pull/46)'
      - 'fix: various role argument specs (https://github.com/prometheus-community/ansible/pull/50)'
      trivial:
      - 'docs: Remove references to to previous named ansible collection cloudalchemy
        (https://github.com/prometheus-community/ansible/pull/44)'
      - 'refactor: move yamllint cfg to standard path (https://github.com/prometheus-community/ansible/pull/47)'
    release_date: '2023-03-05'
  0.10.0:
    release_date: '2023-12-12'
  0.10.1:
    release_date: '2023-12-12'
  0.2.0:
    changes:
      bugfixes:
      - 'fix: Fix typo on Install selinux python packages for RedHat family (https://github.com/prometheus-community/ansible/pull/57)'
      minor_changes:
      - 'feat: add systemd exporter role (https://github.com/prometheus-community/ansible/pull/62)'
      removed_features:
      - 'removed: community.crypto is only needed when testing (https://github.com/prometheus-community/ansible/pull/56)'
      trivial:
      - 'refactor: Disable line-length check in arguments_specs (https://github.com/prometheus-community/ansible/pull/58)'
      - 'refactor: avoid using command module for systemd version fact (https://github.com/prometheus-community/ansible/pull/52)'
      - 'test: fix: 2.12+ test requirements install (https://github.com/prometheus-community/ansible/pull/61)'
    release_date: '2023-03-08'

I manually fixed the indent but since the changes key is missing for those versions antsibull-changelog fails to process the changelog.

 antsibull-changelog generate -v
  shell: /usr/bin/bash -e {0}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/cli.py", line 317, in run
    return arguments.func(arguments)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/cli.py", line 699, in command_generate
    changes = load_changes(config)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 934, in load_changes
    return ChangesData(config, path)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 504, in __init__
    self.load(data_override=data_override)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 510, in load
    super().load(data_override=data_override)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 113, in load
    self.data = sanitize_changes(load_yaml(self.path), config=self.config)
  File "/home/runner/.local/lib/python3.10/site-packages/antsibull_changelog/yaml.py", line 33, in load_yaml
    return yaml.load(stream, Loader=_SafeLoader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "yaml/_yaml.pyx", line 707, in yaml._yaml.CParser.get_single_node
  File "yaml/_yaml.pyx", line 725, in yaml._yaml.CParser._compose_document
  File "yaml/_yaml.pyx", line 776, in yaml._yaml.CParser._compose_node
  File "yaml/_yaml.pyx", line 892, in yaml._yaml.CParser._compose_mapping_node
  File "yaml/_yaml.pyx", line 905, in yaml._yaml.CParser._parse_next_event
yaml.parser.ParserError: while parsing a block mapping
  in "/home/runner/work/ansible/ansible/changelogs/changelog.yaml", line 2, column 1
did not find expected key
  in "/home/runner/work/ansible/ansible/changelogs/changelog.yaml", line 265, column 1

Here's the commit where the indent got screwed up: prometheus-community/ansible@e0697b4

Here's the commit where version 0.10.0 was added: prometheus-community/ansible@2fb25ec

The indenting issue has happened before: prometheus-community/ansible@766f0d7 but it got fixed on the next run, however the broken version sections is not something I've seen before.

Hey @gardar,

I just released antsichaut 0.3.8 on Pypi: https://github.com/ansible-community/antsichaut/releases/tag/0.3.8

I noticed that the last change to the changelog that happened prior to the indent getting screwed up was that version 0.10.0 got added to the changelog but it is missing the changes key.

If there are no changes detected, it should look like this:

releases:
  0.10.1:
    changes: {}
    release_date: '2024-01-08'

This should be fixed by 3a29d64


It also looks like the sorting does not understand the semantic versioning fully as versions 0.10.0 and 0.10.1 are inserted between the last 0.1.x version and first 0.2.x version and not after version 0.9.x as you'd expect.

This too is fixed in 0.3.8, by PR https://github.com/ansible-community/antsichaut/pull/35/files


Can you test please with the latest release?

Excellent, first impressions of v0.3.8 are good, although I haven't tried running it without any changes.

From time to time this keeps happening, haven't been able to figure out exactly why or under what condition.

Here is a commit where my changelog.yaml got screwed up: prometheus-community/ansible@a3aaf70#diff-badba4dd47cd1a24e2765eb5c5f420a529872e06a0ce09251c35ea2cb5b4ebd9

Curiously on the commit before that, the empty changes: {} section was removed, which is perhaps the root cause of the changelog.yaml getting screwed up?
prometheus-community/ansible@85d0ae8#diff-badba4dd47cd1a24e2765eb5c5f420a529872e06a0ce09251c35ea2cb5b4ebd9