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

Add option to fail if a crate's license cannot be reasonably discovered #213

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

mikayla-maki
Copy link
Contributor

@mikayla-maki mikayla-maki commented Jan 23, 2023

Hi y'all, thanks for creating this awesome project :)

As part of integrating this into our CI builds we wanted an option to fail CI if a crate's license could not be determined. I initially set out to implement #203 but quickly discovered that there are a lot of warnings generated for problems that get fixed in a later pass (e.g. failing to read a license identifier but successfully synthesizing one). I tried to put my check as late in the process as possible so that this flag only generates errors in truly unrecoverable situations. As such I think this PR captures the spirit of #203, if not the wording.

For testing I temporarily added this line as a dependency to cargo about:

procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }

For whatever reason, this dependency's license cannot be detected by cargo about, probably because we're depending on a module in this non-library project rather than going through crates.io. Regardless, running cargo run generate --fail_on_missing_license about.hbs should now generate an error like so:

2023-01-23 19:58:56.211281 +00:00:00 [WARN] crate 'procinfo 0.1.0' doesn't have a license field
error: unable to synthesize license expression for 'procinfo 0.1.0': no `license` specified, and no license files were found

2023-01-23 19:59:01.615755 +00:00:00 [ERROR] encountered 1 errors resolving licenses, unable to generate output

Adding the following field to about.toml should fix said error:

[procinfo.clarify]
license = "MIT"
[[procinfo.clarify.git]]
path = 'LICENSE.md'
checksum = '37db33bbbd7348969eda397b89a16f252d56c1ca7481b6ccaf56ccdcbab5dcca'

Let me know if there's anything I can fix or reformat :)

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Adds a fail_on_missing_license flag to the CLI.

Related Issues

#203

@Jake-Shadle Jake-Shadle changed the title Added command line flag for producing an error code on failure to dis… Add option to fail if a crate's license cannot be reasonably discovered Jan 27, 2023
Copy link
Member

@Jake-Shadle Jake-Shadle left a comment

Choose a reason for hiding this comment

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

Thanks!

@Jake-Shadle Jake-Shadle merged commit 0791f55 into EmbarkStudios:main Jan 27, 2023
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.

2 participants