Skip to content

Commit f0df793

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. After extracting the tarball, a new git repository is initialized to simulate a checkout (which the tests expect). Refactor the script to handle different Java versions and use the appropriate petclinic version for each. This commit also updates the appmap-labels.yml file to correctly identify the logging classes used in newer versions of the project.
1 parent 83d3958 commit f0df793

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

agent/bin/test_projects

Lines changed: 37 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,28 @@ 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+
# The archive doesn't include git history, but the tests rely on it for
30+
# metadata. We create a fresh git repo to satisfy the tests.
31+
git init
32+
git config user.email "test@example.com"
33+
git config user.name "Test User"
34+
git remote add origin "https://github.com/${repo}.git"
35+
git add .
36+
git commit -m "Initial commit"
37+
else
38+
# It's a branch, use git clone
39+
echo "Cloning ${repo} at branch ${ref}"
40+
git clone https://github.com/"${repo}".git --depth 1 --branch "${ref}"
41+
cd "${pkg}"
42+
fi
43+
2944

3045
cd ../../..
3146
)
@@ -54,12 +69,20 @@ function install_scala_test_app {
5469
cd ../../..
5570
}
5671

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
72+
case "${JAVA_VERSION}" in
73+
1.8*|11.*)
74+
install_petclinic "land-of-apps/spring-petclinic" old-java-support
75+
;;
76+
17.*)
77+
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
78+
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
79+
install_petclinic "spring-petclinic/spring-framework-petclinic"
80+
;;
81+
*) # For Java 25+
82+
install_petclinic "spring-projects/spring-petclinic" "main"
83+
install_petclinic "spring-petclinic/spring-framework-petclinic"
84+
;;
85+
esac
6386

6487
patch -N -p1 -d build/fixtures/spring-petclinic < test/petclinic/pom.patch
6588

agent/test/petclinic/appmap-labels.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ packages:
88
name: (info|debug)
99
labels: [log]
1010

11+
- path: org.apache.commons.logging.impl
12+
methods:
13+
- class: Slf4jLogFactory\$Slf4jLocationAwareLog
14+
name: (info|debug)
15+
labels: [log]

0 commit comments

Comments
 (0)