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

feat(config): allow configuration from package/workspace metadata #1082

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

orhun
Copy link
Sponsor Contributor

@orhun orhun commented Nov 22, 2023

closes #1022

This PR makes it possible to configure release-plz from Cargo.toml as follows:

[workspace.metadata.release-plz.workspace]
allow_dirty = false
changelog_config = "cliff.toml"
changelog_update = true
dependencies_update = true
git_release_enable = false
git_tag_enable = true
pr_labels = ["release"]
publish_allow_dirty = false
semver_check = false

Or:

[package.metadata.release-plz.workspace]
allow_dirty = false
changelog_config = "cliff.toml"
# ...

TODOs

  • Add integration tests

@orhun
Copy link
Sponsor Contributor Author

orhun commented Dec 2, 2023

Hey @MarcoIeni, can you take a quick glance on this and let me know if you like the implementation? 🐻

@orhun orhun marked this pull request as ready for review December 2, 2023 18:21
@MarcoIeni
Copy link
Owner

Sure. It's a busy period. I'll do it as soon as I can :)

@orhun
Copy link
Sponsor Contributor Author

orhun commented Dec 31, 2023

I guess the only thing left is to write some integration tests \o/

pub fn config(&self, cargo_metadata: &Metadata) -> anyhow::Result<Config> {
super::parse_config(
self.config.as_deref(),
self.optional_project_manifest(),
Copy link
Owner

Choose a reason for hiding this comment

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

project_manifest is already inside self.config. You don't need this parameter.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

self.config is a PathBuf. Not sure if I understood.

Copy link
Owner

Choose a reason for hiding this comment

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

oops sorry. Than you can find the project manifest in cargo_metadata.workspace_root.join("Cargo.toml")

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

Not sure if we can do this. What happens if the user provided a custom path via --project-manifest?

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, I missed this comment.
It's already taken into account here

@MarcoIeni
Copy link
Owner

Integration tests would be great 🥳

@MarcoIeni
Copy link
Owner

MarcoIeni commented Jan 1, 2024

I don't know why cargo-assist is failing. Please ignore it 😅
Let's see if more people report the same issue.

EDIT: fixed it. GitHub actions can be annoying sometimes.

@orhun
Copy link
Sponsor Contributor Author

orhun commented Jan 3, 2024

Any idea how to add integration tests for this? Do you have some examples?

@MarcoIeni
Copy link
Owner

MarcoIeni commented Jan 3, 2024

release-plz integration tests are here.

Complex idea

The first test that comes to mind is specifying a different changelog_config in the Cargo.toml and testing that the changelog is generated according to the custom changelog.

You can use this test as a starting point.
Either you create a new command for the update (context.run_update() here) or you call gitea api to assert the content of the changelog.

Easier alternative

  1. You copy paste this test
  2. You disable the changelog with the changelog_update field in Cargo.toml
  3. You assert that no PR is created

@orhun
Copy link
Sponsor Contributor Author

orhun commented Jan 7, 2024

I tried to add integration tests in the last commit but I'm not sure if I'm on the right path. Please check it out and let me know!

])?;
if let Some(project_manifest) = project_manifest
.or(Some(Path::new(CARGO_TOML)))
.filter(|v| v.exists())
Copy link
Owner

@MarcoIeni MarcoIeni Jan 13, 2024

Choose a reason for hiding this comment

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

if the project manifest exists, you ignore completely the file_contents, returning the default configuration on line 100, right? 🤔

Imagine somebody that doesn't specify the config in the Cargo.toml metadata. Their release-plz.toml file is ignored. I tested this by running your branch on release-plz itself.

// check both workspace and package metadata
for metadata in [
Some(metadata.clone().workspace_metadata),
metadata.packages.first().map(|v| v.metadata.clone()),
Copy link
Owner

Choose a reason for hiding this comment

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

why do you only consider the first package?
Also, metadata.packages also contains your dependencies. We should only consider workspace members.
You can find workspace members with this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support package configuration in the package's directory
2 participants