-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
read package/workspace config from Cargo manifest #799
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor nits, looks good overall — should be able to merge on the next pass.
src/manifest.rs
Outdated
pub(crate) fn deserialize_lint_table( | ||
metadata: serde_json::Value, | ||
) -> anyhow::Result<Option<OverrideMap>> { | ||
let table: Option<LintTable> = serde_json::from_value(metadata)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to avoid the .clone()
when calling this function by making it accept &Value
and then using the trick described in this post: https://users.rust-lang.org/t/serde-from-value-moves-my-value-but-i-want-i-returned-to-me-on-err/69621
src/lib.rs
Outdated
@@ -484,6 +485,11 @@ note: skipped the following crates since they have no library target: {skipped}" | |||
); | |||
} | |||
|
|||
let workspace_overrides = | |||
manifest::deserialize_lint_table(metadata.workspace_metadata.clone()) | |||
.context("[workspace.metadata.cargo-semver-checks] table is incorrect")? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: word choice, here and below as well
.context("[workspace.metadata.cargo-semver-checks] table is incorrect")? | |
.context("[workspace.metadata.cargo-semver-checks] table is invalid")? |
src/lib.rs
Outdated
manifest::deserialize_lint_table(selected.metadata.clone()) | ||
.with_context(|| { | ||
format!( | ||
"{} [package.metadata.cargo-semver-checks] table is incorrect", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: do we by any chance know the path to the Cargo.toml
file here? If it isn't too difficult, it might be useful to not just say which crate had the invalid table but also give a path to it.
This is because in some cases, projects may contain more than one crate by the same name — for example, see #462. In such cases, knowing the Cargo.toml
path would be very helpful to the user.
If it's too hard to do now, we can just open a C-enhancement
issue for the idea and tackle it another time.
- make `manifest::deserialize_lint_table` take a `&serde_json::Value` - show manifest path on invalid `[package.metadata]` table - change "incorrect table" -> "invalid table"
Awesome! 🚀 |
Deserializes lint table from the relevant
[workspace.metadata]
and[package.metadata]
tables, if they exist.Notes:
Cargo.toml
manifest and run thecargo metadata
command - that is, we won't be able to configure lint levels when the rustdoc source isRustdoc | Revision | VersionFromRegistry
as of current without something like CLI flags:run_check_release
function. takeaway is that when we don't have the manifest to read the metadata, we just pass an emptyOverrideStack
as overrideshere's the beginnings of a test crate, although I just printed the passed overrides for now:
test output
run with `cargo r -- semver-checks --baseline-root test_crates/workspace-overrides/baseline --manifest-path test_crates/workspace-overrides/current/pkg/Cargo.toml -vvv`overrides: OverrideStack([{"function_missing": QueryOverride { required_update: Some(Minor), lint_level: Some(Warn) }, "module_missing": QueryOverride { required_update: None, lint_level: Some(Allow) }}, {"function_missing": QueryOverride { required_update: None, lint_level: Some(Deny) }, "module_missing": QueryOverride { required_update: None, lint_level: Some(Warn) }}])