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

[Build] Add a script to execute revapi without gradle plugin #10386

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 5 additions & 33 deletions .github/workflows/api-binary-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,17 @@
# under the License.
#

name: "API Binary Compatibility Checks"
on:
push:
branches:
- 'main'
- '0.**'
tags:
- 'apache-iceberg-**'
pull_request:
paths:
- 'api/**'
- '.palantir/revapi.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
name: "API Compatibility Checks"
on: pull_request

jobs:
revapi:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# fetch-depth of zero ensures that the tags are pulled in and we're not in a detached HEAD state
# revapi depends on the tags, specifically the tag from git describe, to find the relevant override
# in the .palantir/revapi.yml file
#
# See https://github.com/actions/checkout/issues/124
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- run: |
echo "Using the old version tag, as per git describe, of $(git describe)";
- run: ./gradlew revapi --rerun-tasks
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test logs
path: |
**/build/testlogs
java-version: 8
- run: ./gradlew publishToMavenLocal
- run: ./dev/revapi
1,245 changes: 0 additions & 1,245 deletions .palantir/revapi.yml

This file was deleted.

40 changes: 9 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ buildscript {
classpath 'me.champeau.jmh:jmh-gradle-plugin:0.7.2'
classpath 'gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.6'
classpath "com.github.alisiikh:gradle-scalastyle-plugin:3.5.0"
classpath 'com.palantir.gradle.revapi:gradle-revapi:1.7.0'
classpath 'com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.2'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:3.1.0'
classpath 'org.openapitools:openapi-generator-gradle-plugin:6.6.0'
Expand Down Expand Up @@ -120,7 +119,6 @@ if (file("${rootDir}/iceberg-build.properties").exists()) {
}

def projectVersion = getProjectVersion()
final REVAPI_PROJECTS = ["iceberg-api", "iceberg-core", "iceberg-parquet", "iceberg-orc", "iceberg-common", "iceberg-data"]

allprojects {
group = "org.apache.iceberg"
Expand All @@ -139,35 +137,6 @@ subprojects {

apply plugin: 'java-library'

if (project.name in REVAPI_PROJECTS) {
apply plugin: 'com.palantir.revapi'
revapi {
oldGroup = project.group
oldName = project.name
oldVersion = "1.5.0"
}

tasks.register('showDeprecationRulesOnRevApiFailure') {
doLast {
throw new RuntimeException("==================================================================================" +
"\nAPI/ABI breaks detected.\n" +
"Adding RevAPI breaks should only be done after going through a deprecation cycle." +
"\nPlease make sure to follow the deprecation rules defined in\n" +
"https://github.com/apache/iceberg/blob/main/CONTRIBUTING.md#semantic-versioning.\n" +
"==================================================================================")
}
onlyIf {
tasks.revapi.state.failure != null
}
}

tasks.configureEach { rootTask ->
if (rootTask.name == 'revapi') {
rootTask.finalizedBy showDeprecationRulesOnRevApiFailure
}
}
}

configurations {
testImplementation.extendsFrom compileOnly

Expand Down Expand Up @@ -1070,3 +1039,12 @@ project(':iceberg-bom') {
// Needed to get the "faked" Scala artifacts into the bom
javaPlatform { allowDependencies() }
}

task revapi {
doLast {
exec {
workingDir '.'
commandLine 'dev/revapi'
}
}
}
1 change: 1 addition & 0 deletions dev/.rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build
.gradle
.idea
.rat-excludes
.revapi.template
LICENSE
NOTICE
revapi.yml
Expand Down
15 changes: 15 additions & 0 deletions dev/.revapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"extension": "revapi.differences",
"id": "1.6.0",
"configuration": {
"differences": [
{
"justification": "This is a test",
"code": "java.method.addedToInterface",
"new": "method void org.apache.iceberg.catalog.SessionCatalog::testing()"
}
]
}
}
]
17 changes: 17 additions & 0 deletions dev/.revapi.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<#ftl strip_whitespace=true>
Old API: <#list analysis.oldApi.archives as archive>${archive.name}<#sep>, </#list>
New API: <#list analysis.newApi.archives as archive>${archive.name}<#sep>, </#list>
<#if reports?has_content>
<#list reports as report>
<#list report.differences as diff>
<#list diff.classification?keys as compat>
<#if compat == "SOURCE" && diff.classification?api.get(compat) == "BREAKING">
[ERROR] ${diff.description!}
code: ${diff.code}
new: ${report.newElement!""}
old: ${report.oldElement!""}
</#if>
</#list>
</#list>
</#list>
</#if>
97 changes: 97 additions & 0 deletions dev/revapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

export REVAPI_VERSION=0.12.0
export OLD_VERSION=1.5.2
export NEW_VERSION=1.6.0-SNAPSHOT

# Go to the root directory
ROOT_DIR="$(cd "`dirname "$0"`"/..; pwd)"
cd "$ROOT_DIR"

REVAPI_WORKING_DIR="$ROOT_DIR/lib/temp/revapi"

mkdir -p $REVAPI_WORKING_DIR

export REVAPI_ZIP="$ROOT_DIR"/lib/revapi-standalone-${REVAPI_VERSION}-standalone.zip

if test -x "$JAVA_HOME/bin/java"; then
declare java_cmd="$JAVA_HOME/bin/java"
else
declare java_cmd=java
fi

REVAPI_URL=https://repo1.maven.org/maven2/org/revapi/revapi-standalone/${REVAPI_VERSION}/revapi-standalone-${REVAPI_VERSION}-standalone.zip

if [ ! -f "$REVAPI_ZIP" ]; then
printf "Downloading revapi\n"
REVAPI_ZIP_DL="${REVAPI_ZIP}.part"
if [ $(command -v curl) ]; then
curl -L --silent "${REVAPI_URL}" > "$REVAPI_ZIP_DL" && mv "$REVAPI_ZIP_DL" "$REVAPI_ZIP"
elif [ $(command -v wget) ]; then
wget --quiet ${REVAPI_URL} -O "$REVAPI_ZIP_DL" && mv "$REVAPI_ZIP_DL" "$REVAPI_ZIP"
else
printf "You do not have curl or wget installed, please install revapi manually.\n"
exit 1
fi
fi

unzip -q -o "$REVAPI_ZIP" -d "$ROOT_DIR/lib"

export REVAPI_HOME="$ROOT_DIR/lib/revapi-$REVAPI_VERSION"

REVAPI_PROJECTS="api core parquet orc common data"

REVAPI_OUT=lib/revapi.report
rm "$REVAPI_OUT"
rm -f "$REVAPI_OUT"
for REVAPI_PROJECT in $REVAPI_PROJECTS; do
echo "========================"
echo "Checking iceberg-$REVAPI_PROJECT, comparing $OLD_VERSION / $NEW_VERSION"
echo "Downloading iceberg-$REVAPI_PROJECT $OLD_VERSION"
if [ $(command -v curl) ]; then
curl -L --silent "https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-$REVAPI_PROJECT/$OLD_VERSION/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar" > "$REVAPI_WORKING_DIR/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar"
elif [ $(command -v wget) ]; then
wget --quiet "https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-$REVAPI_PROJECT/$OLD_VERSION/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar" -O "$REVAPI_REVAPI_WORKING_DIR/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar"
else
printf "You do not have curl or wget installed, please download artifact manually.\n"
exit 1
fi
if ! [ -f "$REVAPI_WORKING_DIR/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar" ]; then
echo "$REVAPI_WORKING_DIR/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar does not exist. Please check if you can download the artifact via curl or wget."
exit 1
fi
if ! [ -f "$REVAPI_PROJECT/build/libs/iceberg-$REVAPI_PROJECT-$NEW_VERSION.jar" ]; then
echo "$REVAPI_PROJECT/build/libs/iceberg-$REVAPI_PROJECT-$NEW_VERSION.jar does not exist. You have to build artifacts (with gradle publishToMavenLocal) before checking API"
exit 1
fi
$REVAPI_HOME/revapi.sh --extensions=org.revapi:revapi-java:0.28.1,org.revapi:revapi-reporter-text:0.15.0 --old "$REVAPI_WORKING_DIR/iceberg-$REVAPI_PROJECT-$OLD_VERSION.jar" --new "$REVAPI_PROJECT/build/libs/iceberg-$REVAPI_PROJECT-$NEW_VERSION.jar" -c dev/.revapi.json -Drevapi.java.missing-classes.behavior=ignore -Drevapi.reporter.text.minCriticality=error -Drevapi.reporter.text.append=true -Drevapi.reporter.text.output=$REVAPI_OUT -Drevapi.reporter.text.minSeverity=BREAKING -Drevapi.reporter.text.template=dev/.revapi.template
if [[ $(grep "ERROR" $REVAPI_OUT) ]]; then
echo "=================================================================================="
echo "API/ABI breaks detected."
echo "Details can be found in ${REVAPI_OUT}"
echo "Adding RevAPI breaks should only be done after going through a deprecation cycle."
echo "Please make sure to follow the deprecation rules defined in"
echo "https://github.com/apache/iceberg/blob/main/CONTRIBUTING.md#semantic-versioning."
echo "=================================================================================="
exit 2
fi
done

echo "revapi check passed"
Loading