-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
API / binary compatibility checking tool via revapi gradle plugin #4638
API / binary compatibility checking tool via revapi gradle plugin #4638
Conversation
Another tool to consider is open-telemetry/opentelemetry-java#2692 open-telemetry/opentelemetry-java#3183 The rev-api plugin used in this PR is very actively maintained and relatively simple, but anybody who is interested might use that for comparison. |
The available tasks: $ ./gradlew tasks --all | grep rev
iceberg-api:revapi
iceberg-api:revapiAcceptAllBreaks
iceberg-api:revapiAcceptBreak
iceberg-api:revapiAnalyze
iceberg-api:revapiVersionOverride |
Sample output from running `./gradlew check.
|
I really like this approach due to the simplicity and how well it integrates into the current build process. +1 (will wait on other feedback) |
.palantir/revapi.yml
Outdated
@@ -0,0 +1,2 @@ | |||
versionOverrides: | |||
org.apache.iceberg:iceberg-api:release-base-0.13.0: "0.13.1" |
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.
What is this doing?
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 plug-in works by comparing the previous version with the current code, by fetching the previous version from maven.
The previous version is inferred based on the most recent tag, which for the master branch is release-base-0.xx
normally.
However, that’s not an artifact available on maven.
So this sets the “old version” to compare for breaking changes to apache-iceberg-0.13.1
from maven.
See here: https://github.com/palantir/gradle-revapi#version-overrides
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.
Also the Configuration
section has a succinct description of how it works: https://github.com/palantir/gradle-revapi#configuration
“””
gradle-revapi should work out of the box for most uses cases once applied.
By default it compares against the previous version of the jar from the project it is applied in by finding the last tag using git describe.
However, if you need to need to override the artifact to compare against, you can do so.
“””
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.
Here's the documentation on the actual underlying revapi tool: https://revapi.org/revapi-site/main/index.html
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.
Is it possible to move this to a different directory? I isn't very obvious what to fix if this is in .palantir
.
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.
Looking through their source code, the .palantir
directory is hardcoded: https://github.com/kbendick/gradle-revapi/blob/09039d215efbd41e25b6743409a12ceb22ca5d75/src/main/java/com/palantir/gradle/revapi/RevapiPlugin.java#L176-L178
We could either add a comment somewhere in the Gradle build file or possibly try to open a PR upstream.
That said, nobody should have to update the config file manually. It's all done via gradlew
commands which autogenerates the file and updates it.
7789671
to
5a452c2
Compare
Another thought: This runs as part of However, we might want to add this as its CI step eventually. The logic being that this check is relatively inexpensive, and so it could be placed first alongside the PR labeler. Then, if API compatibility fails, we could not run all of the expensive tests. I wouldn’t add it as a standalone check just yet because it will get run as part of |
@@ -0,0 +1,2 @@ | |||
versionOverrides: |
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.
For the upstream version, I agree it should be 0.13.0
, which is the tag you're using. But should this mark it as 0.13.1? What happens if we make the branch 0.13.0 instead?
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.
This is marking it as 0.13.0 because of the output of git describe
. I believe if we pushed a tag for release-base-0.13.1
, it would use that instead.
However, it seems we can use an override in the build.gradle
file instead: https://github.com/palantir/gradle-revapi#configuration
Let me try 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.
Setting it to 0.13.0 then compares the output of current master (or the generated code from this branch) to the 0.13.0
artifact.
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 set it by running ./gradlew iceberg-api:revapiVersionOverride --replacement-version 0.13.0
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.
If we tagged a release-base-0.13.1
, we'd also be able to compare that from within the same file.
I left the full output comparison in a gist. https://gist.github.com/kbendick/b9543ac8498bb06815a8c4e993f5c969
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 we want to compare against the last minor release right now. Later, we'll want to compare to the last major release.
5a452c2
to
22254d3
Compare
build.gradle
Outdated
revapi { | ||
oldGroup = 'org.apache.iceberg' | ||
oldName = 'iceberg-api' | ||
oldVersion = '0.13.0' | ||
} |
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.
Using this seems to be not the best idea, as it would need to be updated manually across versions.
Using the gradle tasks doesn't update this, but we might consider using this for when we cut a release tag (not the release base off of master but the actual tag).
Here's a gist comparing the output of 0.13.0 API module to the current 0.14.0-SNAPSHOT: https://gist.github.com/kbendick/b9543ac8498bb06815a8c4e993f5c969 This was generated by running |
…pare against for changes
d9e75a0
to
13f3c41
Compare
Thanks, @kbendick! This is great to have. I merged this. Do we expect builds to start failing now if there are binary breaking changes? |
Yes. In fact, builds might start failing now (the changes to gradle check were prossibly not run in this PR’s status checks). If you run I’ll hop on my computer and open a PR or if you make one then I’ll review it. Then from there it will be required. @rdblue |
But TLDR - We don’t have to add anything new to CI, this runs during gradle check. |
Can't run build on branch master 9ab94f8 ubuntu 20.04 LTS .
What did I miss? @kbendick |
I do think it caused by palantir/gradle-revapi#550 |
Oh I’m sorry I missed this. If you’re on master, can you fetch all tags from the upstream repository? Commenting on closed PRs is likely to not get seen. Probably better to open an issue. But @chenjunjiedada had this issue recently and they were missing the most recent release-base branch. |
Here’s an image of the tags needed. It’s just a EDIT: Couldn’t upload a picture, but… If you do |
Oh sorry. I see you do have a release-base. I think maybe your gradle / maven dependency revolution (possibly in a fork) isn’t able to fetch the dependencies from the old version. Maybe a Firewall issue or maven / gradle configuration difference? Like I said, open an issue as a closed old PR is not the best place to discuss this. But try running the build with |
Sorry. |
Purpose
As part of our journey to the 1.0 release, we'd like to have stability / binary compatibility guarantees for the
api
package.Added
Adds a gradle plugin, that's currently still actively maintained, for the
Revapi
tool, for checking API and ABI compatibility and ensuring that any breaks are caught duringgradlew check
(orgradlew revapi
).It also allows for allowing overrides and setting binary compatibility checks against different versions / tags.
Info can be found here: https://github.com/palantir/gradle-revapi
Using
A generated override file is added that allows us to accept breaking changes and optionally denote why they're allowed.
This plugin requires that we point to some sort of base (to check binary / API compatibility from). I pointed it to 0.13.1 for this PR.
With this patch, if
./gradlew check
is run, it fails because it can't determine the correct upstream version to compare against.So I ran the following to generate the config file in
./palantir/revapi.yml
.Please feel free to take a look.
Why this plugin
check
phase so that little to none of our CI needs to change.Anybody who is interested, please take a look, play around and see how you like it.
cc @rdblue @danielcweeks @nastra @jackye1995 @snazy