Skip to content

Commit d5b2be5

Browse files
committed
chore: Add comments for the script
1 parent 012be19 commit d5b2be5

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

.github/scripts/test_dependency_compatibility.sh

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ function print_help() {
2929
echo "Use -l {deps_list} for a comma-separated list of dependencies to test (Format: dep1=1.0,dep2=2.0)"
3030
}
3131

32+
# Function to parse a dependency string and append it to the Maven command
33+
function add_dependency_to_maven_command() {
34+
local dep_pair=$1
35+
if [[ ! "${dep_pair}" =~ .*=.* ]]; then
36+
echo "Malformed dependency string: ${dep_pair}. Expected format: dependency=version"
37+
exit 1
38+
fi
39+
local dependency=$(echo "${dep_pair}" | cut -d'=' -f1 | tr -d '[:space:]')
40+
local version=$(echo "${dep_pair}" | cut -d'=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
41+
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
42+
}
43+
3244
# Default to the upper bounds file in the root of the repo
3345
file='dependencies.txt'
3446
dependency_list=''
@@ -65,15 +77,7 @@ if [ -z "${dependency_list}" ]; then
6577
if [[ "${line}" =~ ^[[:space:]]*# ]] || [[ -z "${line}" ]]; then
6678
continue
6779
fi
68-
69-
# Extract the dependency name and version
70-
# We use 'cut' to split the line by '=' and trim whitespace
71-
# The sed command is used to remove potential trailing whitespace from the version number
72-
dependency=$(echo "${line}" | cut -d'=' -f1 | tr -d '[:space:]')
73-
version=$(echo "${line}" | cut -d'=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
74-
75-
# Append the formatted property to the Maven command
76-
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
80+
add_dependency_to_maven_command "${line}"
7781
done < "${UPPER_BOUND_DEPENDENCY_FILE}"
7882
else # This else block means that a list of dependencies was inputted
7983
# Set the Internal Field Separator (IFS) to a comma.
@@ -87,15 +91,7 @@ else # This else block means that a list of dependencies was inputted
8791
if [ -z "${DEP_PAIR}" ]; then
8892
continue
8993
fi
90-
91-
# Extract the dependency name and version
92-
# We use 'cut' to split the line by '=' and trim whitespace
93-
# The sed command is used to remove potential trailing whitespace from the version number
94-
dependency=$(echo "${DEP_PAIR}" | cut -d'=' -f1 | tr -d '[:space:]')
95-
version=$(echo "${DEP_PAIR}" | cut -d'=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
96-
97-
# Append the formatted property to the PROPERTIES string.
98-
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
94+
add_dependency_to_maven_command "${DEP_PAIR}"
9995
done
10096
fi
10197

dependencies.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# This file contains a list of dependencies and their versions to be tested for compatibility.
2+
# The format is key=value, where the key is the dependency name and the value is the version.
3+
# "1P" refers to First-Party dependencies (owned by Google).
4+
# "3P" refers to Third-Party dependencies.
5+
16
# 1P Parent-Pom
27
javax.annotation-api=1.3.2
38
grpc=1.74.0

0 commit comments

Comments
 (0)