From bedb605cf680091dd64e7c03c0235ebe78759ba1 Mon Sep 17 00:00:00 2001 From: Aravinda Kidambi Srinivasan Date: Wed, 6 Nov 2024 11:04:49 -0800 Subject: [PATCH] Update backward compatibility check script 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. --- .../scripts/backwards_compatibility_check.sh | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/scripts/backwards_compatibility_check.sh b/.github/scripts/backwards_compatibility_check.sh index 78f95cc6..070e9c17 100755 --- a/.github/scripts/backwards_compatibility_check.sh +++ b/.github/scripts/backwards_compatibility_check.sh @@ -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