Update backward compatibility check script (#1393)

Dont fail the check for major release but print the output
for information/review purposes to know what API changes
have occurred in a major release

Manually tested the changes with some incompatible API changes
between patch release, minor release and major release.
This commit is contained in:
Aravinda Kidambi Srinivasan 2024-11-06 15:31:25 -07:00 committed by GitHub
parent fbfd74df39
commit f7e909c979
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,12 +27,21 @@ get_current_jar() {
}
is_new_minor_release() {
is_new_major_release && return 1
local latest_minor_version=$(echo "$LATEST_VERSION" | cut -d . -f 2)
local current_minor_version=$(echo "$CURRENT_VERSION" | cut -d . -f 2)
[[ "$latest_minor_version" != "$current_minor_version" ]]
return $?
}
is_new_major_release() {
local latest_major_version=$(echo "$LATEST_VERSION" | cut -d . -f 1)
local current_major_version=$(echo "$CURRENT_VERSION" | cut -d . -f 1)
[[ "$latest_major_version" != "$current_major_version" ]]
return $?
}
# Skip classes with the KinesisClientInternalApi annotation. These classes are subject to breaking backwards compatibility.
is_kinesis_client_internal_api() {
local current_class="$1"
@ -63,9 +72,9 @@ ignore_abstract_changes_in_interfaces() {
# Checks if there are any methods in the latest version that were removed in the current version.
find_removed_methods() {
echo "Checking if methods in current version (v$CURRENT_VERSION) were removed from latest version (v$LATEST_VERSION)"
if is_new_minor_release
if is_new_minor_release || is_new_major_release
then
echo "New minor release is being performed. Ignoring changes in classes marked with @KinesisClientInternalApi annotation."
echo "New minor/major release is being performed. Ignoring changes in classes marked with @KinesisClientInternalApi annotation."
fi
local latest_classes=$(
jar tf $LATEST_JAR |
@ -79,13 +88,20 @@ find_removed_methods() {
grep -v 'software\.amazon\.kinesis\.retrieval\.kpl\.Messages')
for class in $latest_classes
do
if (is_kinesis_client_internal_api "$class" && is_new_minor_release) || is_non_public_class "$class"
if (is_kinesis_client_internal_api "$class" && (is_new_minor_release || is_new_major_release)) || is_non_public_class "$class"
then
continue
fi
CURRENT_METHODS=$(javap -classpath "$CURRENT_JAR" "$class" 2>/dev/null)
if [ -z "$CURRENT_METHODS" ]
then
echo "Class $class was removed"
REMOVED_METHODS_FLAG=$TRUE
continue
fi
LATEST_METHODS=$(javap -classpath "$LATEST_JAR" "$class")
CURRENT_METHODS=$(javap -classpath "$CURRENT_JAR" "$class")
ignore_abstract_changes_in_interfaces "$class"
@ -111,7 +127,7 @@ get_backwards_compatible_result() {
if [[ $REMOVED_METHODS_FLAG == $TRUE ]]
then
echo "Current KCL version $CURRENT_VERSION is not backwards compatible with version $LATEST_VERSION. See output above for removed packages/methods."
exit 1
is_new_major_release || exit 1
else
echo "Current KCL version $CURRENT_VERSION is backwards compatible with version $LATEST_VERSION."
exit 0