-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
This file will allow you to specify licenses that are allowed and denied as well as dependencies that will be allowed regardless of their license.
Pull Request Test Coverage Report for Build 50
💛 - Coveralls |
|
||
@config_filename ".licensir.exs" | ||
|
||
defstruct allowlist: [], denylist: [], allow_deps: [] |
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.
change to :allow
, :deny
?
Parse a project's .licensir.exs file to determine what licenses are acceptable to the user, not acceptable, and projects that are allowed | ||
""" | ||
|
||
@config_filename ".licensir.exs" |
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.
original issue mentioned .licenses.exs
but I used .licensir.exs
instead. LMK which you prefer
@@ -21,6 +21,7 @@ defmodule Licensir.License do | |||
license: nil, | |||
certainty: 0.0, | |||
mix: nil, | |||
status: :unknown, |
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.
I'm open to a better name here. This is also what would be in the csv and stdout output.
defp exit_status(licenses) do | ||
if Enum.any?(licenses, &(&1.status == :not_allowed)) do | ||
exit({:shutdown, 1}) | ||
end |
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.
I didn't see a good way to test this since it would also shutdown the test, but running it manually proved it worked.
@@ -0,0 +1,5 @@ | |||
%{ | |||
allowlist: ["MIT", "Apache 2.0"], | |||
denylist: ["GPLv2", "Licensir Mock License"], |
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.
I opted for the human name since that's the output folks would see in their stdout/csv.
Thanks! I'm on it now! |
After using GitHub's licensed library, I think I'd like to modify this to treat unknown licenses as a failure as well. Currently, it only exits with status 1 if there is a 'not_allowed' license, which isn't very practical for workflows because those libraries should not be used if not allowed, but moreso if a new library comes in that doesn't have a known license it needs to fail CI and be reviewed. |
Any particular reason why make it additional file instead of configuration option in |
@hauleth Mostly at your suggestion in the original issue; also there is precedence with other libraries like credo and dialyxir. I haven't looked yet, but would licensir have access to |
Yeah, but now I think that
I do not know, but I think that nothing should change there, as it is still ran within context of the project. |
@dbernheisel it doesn't look like this was ever merged. Was there any specific reason? This would be a super handy feature! |
The
.licensir.exs
file will allow you to specify licenses that are allowed and denied, as well as dependencies that are allowed regardless of their license. If a denied license is found, the mix task will return with an exit status of 1, otherwise it will exit normally with a status of 0.We're totally open to feedback; we did the minimum to make it work and wanted to get feedback before going much further.
Currently, the way it works for end-users would be for them to include a
.licensir.exs
file at the root of their projectThis updates the CSV and stdout output to include a new
status
column that indicates whether the license is allowed, not allowed, or unknown. For example:I tested this on a normal mix project, and it worked as expected.
For an umbrella app, it would require the
.licensir.exs
file for each application included in the umbrella.Resolves #6