Skip to content

Commit dc01da7

Browse files
committed
build: Download petclinic archive instead of full clone
To speed up CI, download a tarball of a specific commit hash instead of performing a full git clone. This is particularly useful for pinning spring-petclinic to a version compatible with Java 17. Refactor the script to handle different Java versions and use the appropriate petclinic version for each.
1 parent 91cca89 commit dc01da7

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

agent/bin/test_projects

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ mkdir -p build/fixtures
66
source "test/helper.bash"
77
export ANNOTATION_JAR="$(find_annotation_jar)"
88

9-
function is_old_java {
10-
local version="$1"
11-
[[ "$version" == 1.8* ]] || [[ "$version" == 11.* ]]
12-
}
13-
149
function install_petclinic (
1510
local repo="$1"; shift
16-
local branch=${1:-main}
11+
local ref=${1:-main}
1712
local pkg="$(basename $repo)"
1813

1914
if [[ -d "build/fixtures/${pkg}" ]]; then
@@ -24,8 +19,20 @@ function install_petclinic (
2419
cd build/fixtures
2520

2621
rm -rf "${pkg}"
27-
git clone https://github.com/"${repo}".git --depth 1 --branch "${branch}"
28-
cd "${pkg}"
22+
23+
if [[ "${#ref}" == 40 ]]; then
24+
# It's a commit hash, download archive
25+
echo "Downloading archive for ${repo} at commit ${ref}"
26+
curl -L "https://github.com/${repo}/archive/${ref}.tar.gz" | tar xz
27+
mv "${pkg}-${ref}" "${pkg}"
28+
cd "${pkg}"
29+
else
30+
# It's a branch, use git clone
31+
echo "Cloning ${repo} at branch ${ref}"
32+
git clone https://github.com/"${repo}".git --depth 1 --branch "${ref}"
33+
cd "${pkg}"
34+
fi
35+
2936

3037
cd ../../..
3138
)
@@ -54,12 +61,20 @@ function install_scala_test_app {
5461
cd ../../..
5562
}
5663

57-
if is_old_java "$JAVA_VERSION"; then
58-
install_petclinic "land-of-apps/spring-petclinic" old-java-support
59-
else
60-
install_petclinic "spring-projects/spring-petclinic"
61-
install_petclinic "spring-petclinic/spring-framework-petclinic"
62-
fi
64+
case "${JAVA_VERSION}" in
65+
1.8*|11.*)
66+
install_petclinic "land-of-apps/spring-petclinic" old-java-support
67+
;;
68+
17.*)
69+
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
70+
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
71+
install_petclinic "spring-petclinic/spring-framework-petclinic"
72+
;;
73+
*) # For Java 25+
74+
install_petclinic "spring-projects/spring-petclinic" "main"
75+
install_petclinic "spring-petclinic/spring-framework-petclinic"
76+
;;
77+
esac
6378

6479
patch -N -p1 -d build/fixtures/spring-petclinic < test/petclinic/pom.patch
6580

0 commit comments

Comments
 (0)