Skip to content

Conversation

@jsoriano
Copy link
Member

Add a new subcommand with utilities for the changelog.

It includes an add command that can be used to add changelog entries,
this can be useful in automation.

For example the following command creates a new patch version including a change with a description, link and type:

elastic-package changelog add --next patch --description "Add documentation for multi-fields" --type enhancement --link https://github.com/elastic/integrations/pull/2916

If no --next or --version flags are passed, change is included in current version.

@jsoriano jsoriano added the Team:Ecosystem Label for the Packages Ecosystem team label Mar 30, 2022
@jsoriano jsoriano requested a review from a team March 30, 2022 17:28
@jsoriano jsoriano self-assigned this Mar 30, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 30, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-03-31T12:58:35.628+0000

  • Duration: 25 min 22 sec

Test stats 🧪

Test Results
Failed 0
Passed 627
Skipped 0
Total 627

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

// PatchYAML looks for the proper place to add the new revision in the changelog,
// trying to conserve original format and comments.
func PatchYAML(d []byte, patch Revision) ([]byte, error) {
var nodes []yaml.Node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you did it this way (generic YAML parsing), but maybe it's fair to depend on schema and unmarshal the changelog to the proper structure? I don't mind if we lose some comments in the meantime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to change the files the minimum possible and maintain the current format, at the end these files are still maintained by humans.

I gave a try to yaml patch libraries for this, and they work well for simple changes as setting the version in the manifest, or appending elements, but I didn't manage to add the changelog entry on top. I can give this approach another try so we don't have to maintain this parsing code, but we can still keep the format and comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that it's a matter of personal preference, YAML patching vs strict model. I don't have any strong points for switching to mapping except for simpler implementation and less node-level processing.

BTW as an alternative approach, you can consider mapstr. It's up to you to decide which option seems less error-prone :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this code is a bit too much for what it does, but I didn't find another reliable way to do it with the requisite (maybe self-imposed :) ) of maintaining the format as much as possible.

In any case I have tried to maintain the interfaces of the two exposed methods clean, and tests cover them, we can change their implementation if we get another idea.

return nil, errors.Wrap(err, "unexpected manifest content")
}

setYamlMapValue(node.Content[0], "version", version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as for the changelog. In this case, we already have the logic to read the package manifest.

@mtojek mtojek self-requested a review March 31, 2022 15:36
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment about an alternative approach, but please don't consider it as blocker for this PR.

@mtojek mtojek requested a review from marc-gr March 31, 2022 15:37
@mtojek
Copy link
Contributor

mtojek commented Mar 31, 2022

FYI @marc-gr as your team may benefit from this pull request :)

@jsoriano jsoriano merged commit e210494 into elastic:main Mar 31, 2022
@jsoriano jsoriano deleted the changelog-subcommand branch March 31, 2022 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Ecosystem Label for the Packages Ecosystem team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants