From ed08a42b9aa74f9d393efa146562b6fa640ded9d Mon Sep 17 00:00:00 2001 From: Vincent Viloria Date: Fri, 19 Apr 2024 12:24:19 -0700 Subject: [PATCH] add function to check if minor release is being performed --- .../scripts/backwards_compatibility_check.sh | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/scripts/backwards_compatibility_check.sh b/.github/scripts/backwards_compatibility_check.sh index dac14e57..e8470ab5 100755 --- a/.github/scripts/backwards_compatibility_check.sh +++ b/.github/scripts/backwards_compatibility_check.sh @@ -15,7 +15,7 @@ get_latest_jar() { # clear the directory so that the latest release will be the only version in the Maven directory after running mvn dependency:get rm -rf "$KCL_MAVEN_DIR" mvn -B dependency:get -Dartifact=software.amazon.kinesis:amazon-kinesis-client:LATEST - LATEST_VERSION=$(ls "$KCL_MAVEN_DIR" | grep '[0-9].[0-9].[0-9]') + LATEST_VERSION=$(ls "$KCL_MAVEN_DIR" | grep -E '[0-9]+.[0-9]+.[0-9]+') LATEST_JAR=$KCL_MAVEN_DIR/$LATEST_VERSION/amazon-kinesis-client-$LATEST_VERSION.jar } @@ -26,6 +26,13 @@ get_current_jar() { CURRENT_JAR=$KCL_MAVEN_DIR/$CURRENT_VERSION/amazon-kinesis-client-$CURRENT_VERSION.jar } +is_new_minor_release() { + 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 $? +} + # Skip classes with the KinesisClientInternalApi annotation. These classes are subject to breaking backwards compatibility. is_kinesis_client_internal_api() { local current_class="$1" @@ -56,11 +63,14 @@ 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 + then + echo "New minor release is being performed. Ignoring changes in classes marked with @KinesisClientInternalApi annotation." + fi local latest_classes=$(jar tf $LATEST_JAR | grep .class | tr / . | sed 's/\.class$//') for class in $latest_classes do - - if is_kinesis_client_internal_api "$class" || is_non_public_class "$class" + if (is_kinesis_client_internal_api "$class" && is_new_minor_release) || is_non_public_class "$class" then continue fi @@ -75,6 +85,10 @@ find_removed_methods() { if [[ "$removed_methods" != "" ]] then REMOVED_METHODS_FLAG=$TRUE + if is_kinesis_client_internal_api "$class" + then + echo "Found removed methods in class with @KinesisClientInternalApi annotation. To resolve these issues, upgrade the current minor version or address these changes." + fi echo "$class does not have method(s):" echo "$removed_methods" fi @@ -84,10 +98,10 @@ find_removed_methods() { get_backwards_compatible_result() { if [[ $REMOVED_METHODS_FLAG == $TRUE ]] then - echo "Current KCL version is not backwards compatible with version $LATEST_VERSION. See output above for removed packages/methods." + echo "Current KCL version $CURRENT_VERSION is not backwards compatible with version $LATEST_VERSION. See output above for removed packages/methods." exit 1 else - echo "Current KCL version is backwards compatible with version $LATEST_VERSION." + echo "Current KCL version $CURRENT_VERSION is backwards compatible with version $LATEST_VERSION." exit 0 fi }