-
Notifications
You must be signed in to change notification settings - Fork 15
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
Introduce task versionPolicyAssessCompatibility #184
Conversation
I tried this out (with No changes (or adding a
|
Thank you for testing, @rtyley!
Good point. I will have a look tomorrow. |
Done in 700cfa1. |
923f7cb
to
700cfa1
Compare
We can reduce switch statements, and line count a little bit too, if we use a `Map[IncompatibilityType, ...]` rather than two separate `binaryCompatibilityReport` & `sourceCompatibilityReport` fields. This is proposed change for scalacenter#184
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.
The output from this is looking good, though working out how to get a GitHub Workflow to consume the output is still a little tricky - this is the kind of output we're currently getting:
sbt:etag-caching-root> show versionPolicyAssessCompatibility
[info] core / versionPolicyAssessCompatibility
[info] Vector((com.gu.etag-caching:core:1.0.7,BinaryCompatible))
[info] aws-s3-base / versionPolicyAssessCompatibility
[info] Vector((com.gu.etag-caching:aws-s3-base:1.0.7,BinaryAndSourceCompatible))
[info] aws-s3-sdk-v2 / versionPolicyAssessCompatibility
[info] Vector((com.gu.etag-caching:aws-s3-sdk-v2:1.0.7,BinaryCompatible))
[info] versionPolicyAssessCompatibility
[info] List()
If there was some way of outputting a summary like this, it would probably be ideal for consuming from a GitHub workflow:
comparedWithVersion: 1.0.7
overallCompatibility: BinaryCompatible
It might be that we want this output into a file, rather than the console, to make it easier to consume. I realise I'm potentially asking for non-generic things here, just wanted to try and work out where we need to get to...
Apart from that, and bearing in mind that I'm not an expert in this code and won't know all the crucial nuances, I did add a query about ModuleID
, and offered a couple of small tweaks to code if you want them!
val dependencyIssues = versionPolicyFindDependencyIssues.value | ||
val mimaIssues = versionPolicyFindMimaIssues.value | ||
assert( | ||
dependencyIssues.map(_._1.revision).toSet == mimaIssues.map(_._1.revision).toSet, | ||
"Dependency issues and Mima issues must be checked against the same previous releases" | ||
) | ||
for ((previousModule, dependencyReport) <- dependencyIssues) yield { | ||
val (_, problems) = | ||
mimaIssues | ||
.find { case (id, _) => previousModule.revision == id.revision } | ||
.get // See assertion above | ||
previousModule -> (dependencyReport, problems) | ||
} |
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 having a bit of trouble understanding this code, I think because I'm not sure exactly what range of values it's operating over. dependencyIssues
& mimaIssues
are both Seq[(sbt.ModuleID, ...]
but what range of ModuleID
do we expect that to be? I assume that ModuleID
means a subproject within the sbt project we are running in, but I'm not sure of:
- will all
ModuleId
s be for the same module, but potentially for many different revisions? Would it be reasonable to assert that we're only expecting one common revision? - if
ModuleId
s can be for differing modules (egcore
&extra-thing
), then linking them together just by revision (previousModule.revision == id.revision
) wouldn't work, right?
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.
That’s a great question. The module IDs we iterate over are the previous versions of the same module that we check the compatibility against.
It is possible to check the compatibility against several previous versions, not just one, although by default only the previous release is tested. This can be customized by the users via the key versionPolicyPreviousVersions
.
We inherited this behavior because Mima itself works like that, although I am not sure it is that important that we follow the same approach in sbt-version-policy. I decided not to change that in this PR.
So, ideally we’d have a range of revisions, not a range of module IDs, but versionPolicyFindDependencyIssues
already used a range of module IDs so I followed the same structure for versionPolicyFindMimaIssues
as well (and also versionPolicyFindIssues
and versionPolicyAssessCompatibility
…).
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.
Ah, thanks for explaining that! It does make me wonder whether versionPolicyAssessCompatibility
, being a new key, needs to return Seq[(ModuleID, Compatibility)]
, or whether it could be just (ModuleID, Compatibility)
, giving info for the latest published revision. Anything that makes the output simpler to model and easier to parse is good from my perspective - would it be harmful to sbt-version-policy to make that simplification on this new key?
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 see two arguments to keep the Seq
:
- it allows the users to compute the compatibility against multiple previous versions if they want to (although I have no clue whether people really need that…), without adding much costs on our side.
- we currently implement the
skip
behavior by returning an empty collection. Alternatively, we could use anOption
. A better solution would be to “assign” the task to its definition (the part where we doversionPolicyAssessCompatibility := { … }
) only ifskip
isfalse
, but I am not sure sbt supports that.
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 think the skip
argument is more compelling for me, though it is a bit unfortunate it's necessary 😞 Never mind!
sbt-version-policy/src/main/scala/sbtversionpolicy/SbtVersionPolicySettings.scala
Outdated
Show resolved
Hide resolved
sbt-version-policy/src/main/scala/sbtversionpolicy/DependencyCheckReport.scala
Outdated
Show resolved
Hide resolved
We can reduce switch statements, and line count a little bit too, if we use a `Map[IncompatibilityType, ...]` rather than two separate `binaryCompatibilityReport` & `sourceCompatibilityReport` fields. This is proposed change for scalacenter#184
Thank you for the review!
I agree. The task In the future, we could add a task such as |
109465e
to
b3ad271
Compare
Co-authored-by: Roberto Tyley <roberto.tyley@theguardian.com>
…f skip is true This is a bit dirty because those tasks are expected to return a result. Skipping a task that returns a result means that we still have to return a result somehow (unless we fail the task). Here, we return an empty result.
b3ad271
to
5c651a5
Compare
Ah cool! Yes, |
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.
Personally, looks great to me (I'm not an sbt expert!)- especially appreciate the new documentation in the README 👍
This is another attempt to address #179 / #109. It should also help to address #121.
We introduce a bunch of new keys:
versionPolicyFindMimaIssues
, which returns all the Mima issues found on the project against its previous versions (similar to the existingversionPolicyFindDependencyIssues
)versionPolicyFindIssues
, which returns both Mima issues and dependency issuesversionPolicyAssessCompatibility
, which assess the compatibility level of the project based on the result ofversionPolicyFindIssues
.Unfortunately, I couldn’t find a way to implement these changes without breaking the binary compatibility. On the other hand, breaking the binary compatibility was a good opportunity to clean up the code base:
versionPolicyForwardCompatibilityCheck
andversionPolicyCheckDirection
)data-class
DependencyCheckReport
(so Facilitate using the plugin for custom reports #121 should be easier to achieve)I also updated the documentation.
This work is sponsored by The Guardian ❤️