Skip to content

Commit c7ec811

Browse files
authored
Merge pull request #246 from contentstack/development
DX| 05-01-2026 | Release
2 parents 73ae158 + 591c04a commit c7ec811

File tree

69 files changed

+32768
-3106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+32768
-3106
lines changed

.github/workflows/unit-testing.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Java SDK - Coverage Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- development
7+
- staging
8+
- master
9+
10+
jobs:
11+
coverage:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: 🧾 Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: ☕ Set up JDK 8 (Temurin)
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 8
23+
cache: maven
24+
25+
- name: 🧩 Ensure tests are enabled in pom.xml
26+
run: |
27+
echo "🔧 Ensuring tests are enabled in pom.xml..."
28+
sed -i 's/<skipTests>true<\/skipTests>/<skipTests>false<\/skipTests>/g' pom.xml || true
29+
30+
- name: 🧪 Run tests and generate JaCoCo report
31+
run: mvn clean test -Dtest='Test*' jacoco:report -Dgpg.skip=true
32+
33+
- name: 📊 Extract coverage from JaCoCo HTML report
34+
id: extract_coverage
35+
run: |
36+
echo "📊 Extracting coverage summary from JaCoCo HTML report..."
37+
38+
REPORT="target/site/jacoco/index.html"
39+
40+
if [ ! -f "$REPORT" ]; then
41+
echo "❌ JaCoCo HTML report not found!"
42+
exit 1
43+
fi
44+
45+
# Extract the <tfoot> Total row and clean it up
46+
TOTAL_ROW=$(grep -A2 "<td>Total</td>" "$REPORT" | tr -d '\n')
47+
48+
# Extract numeric percentages in order (Instruction first, Branch second)
49+
PERCENTAGES=($(echo "$TOTAL_ROW" | grep -oE '[0-9]+%' | sed 's/%//g'))
50+
51+
INSTRUCTION=${PERCENTAGES[0]:-0}
52+
BRANCH=${PERCENTAGES[1]:-0}
53+
54+
echo "📘 Instruction Coverage: ${INSTRUCTION}%"
55+
echo "🌿 Branch Coverage: ${BRANCH}%"
56+
57+
echo "instruction=${INSTRUCTION}" >> $GITHUB_OUTPUT
58+
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
59+
60+
- name: 🚦 Enforce coverage threshold
61+
run: |
62+
MIN_INSTRUCTION=90
63+
MIN_BRANCH=80
64+
65+
INSTRUCTION=${{ steps.extract_coverage.outputs.instruction }}
66+
BRANCH=${{ steps.extract_coverage.outputs.branch }}
67+
68+
echo "🧾 Required minimums:"
69+
echo " • Instruction: ${MIN_INSTRUCTION}%"
70+
echo " • Branch: ${MIN_BRANCH}%"
71+
echo ""
72+
echo "📈 Actual coverage:"
73+
echo " • Instruction: ${INSTRUCTION}%"
74+
echo " • Branch: ${BRANCH}%"
75+
76+
if [ "$INSTRUCTION" -lt "$MIN_INSTRUCTION" ]; then
77+
echo "❌ Instruction coverage (${INSTRUCTION}%) is below the threshold (${MIN_INSTRUCTION}%)"
78+
exit 1
79+
fi
80+
81+
if [ "$BRANCH" -lt "$MIN_BRANCH" ]; then
82+
echo "❌ Branch coverage (${BRANCH}%) is below the threshold (${MIN_BRANCH}%)"
83+
exit 1
84+
fi
85+
86+
echo "✅ Coverage thresholds met!"
87+
88+
- name: 💬 Post coverage summary as PR comment
89+
uses: marocchino/sticky-pull-request-comment@v2
90+
with:
91+
header: 🧪 JaCoCo Coverage Report
92+
message: |
93+
**Coverage Summary**
94+
- 📘 Instruction Coverage: `${{ steps.extract_coverage.outputs.instruction }}%`
95+
- 🌿 Branch Coverage: `${{ steps.extract_coverage.outputs.branch }}%`
96+
97+
- name: 📦 Upload JaCoCo HTML report as artifact
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: jacoco-report
101+
path: target/site/jacoco/
102+
if-no-files-found: warn

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,5 @@ src/main/resources/
272272
/src/main/java/com/contentstack/sdk/models/
273273
/.vscode/
274274
/.vscode/
275+
/docs/
276+
INTEGRATION-TESTS-GUIDE.md

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## v2.3.2
4+
5+
### Jan 05, 2026
6+
- Snyk Fixes
7+
38
## v2.3.1
49

510
### Date: 03-Nov-2025

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2012 - 2025 Contentstack
3+
Copyright (c) 2012 - 2026 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

pom.xml

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>java</artifactId>
8-
<version>2.3.1</version>
8+
<version>2.3.2</version>
99
<packaging>jar</packaging>
1010
<name>contentstack-java</name>
1111
<description>Java SDK for Contentstack Content Delivery API</description>
@@ -20,8 +20,8 @@
2020
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
2121
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
2222
<dotenv-source.version>3.0.0</dotenv-source.version>
23-
<rxjava-source.version>3.1.10</rxjava-source.version>
24-
<retrofit-source.version>2.11.0</retrofit-source.version>
23+
<rxjava-source.version>3.1.11</rxjava-source.version>
24+
<retrofit-source.version>3.0.0</retrofit-source.version>
2525
<loggin.version>5.1.0</loggin.version>
2626
<jococo-plugin.version>0.8.5</jococo-plugin.version>
2727
<lombok-source.version>1.18.36</lombok-source.version>
@@ -172,12 +172,19 @@
172172
<artifactId>json-simple</artifactId>
173173
<version>${json-simple-version}</version>
174174
<scope>compile</scope>
175+
<!-- Exclude junit - it was incorrectly included as compile dep in json-simple -->
176+
<exclusions>
177+
<exclusion>
178+
<groupId>junit</groupId>
179+
<artifactId>junit</artifactId>
180+
</exclusion>
181+
</exclusions>
175182
</dependency>
176183

177184
<dependency>
178185
<groupId>com.fasterxml.jackson.core</groupId>
179186
<artifactId>jackson-databind</artifactId>
180-
<version>2.18.2</version>
187+
<version>2.19.2</version>
181188
</dependency>
182189
<dependency>
183190
<groupId>com.slack.api</groupId>
@@ -187,7 +194,7 @@
187194
<dependency>
188195
<groupId>org.jetbrains</groupId>
189196
<artifactId>annotations</artifactId>
190-
<version>24.0.1</version>
197+
<version>26.0.2</version>
191198
</dependency>
192199
<dependency>
193200
<groupId>com.squareup.okhttp3</groupId>
@@ -215,6 +222,34 @@
215222
<artifactId>kotlin-stdlib</artifactId>
216223
<version>2.1.0</version>
217224
</dependency>
225+
<!-- Fix CVE-2025-48924: Uncontrolled Recursion in commons-lang3 -->
226+
<dependency>
227+
<groupId>org.apache.commons</groupId>
228+
<artifactId>commons-lang3</artifactId>
229+
<version>3.18.0</version>
230+
</dependency>
231+
<!-- Fix Spring vulnerabilities from contentstack-utils transitive deps -->
232+
<dependency>
233+
<groupId>org.springframework</groupId>
234+
<artifactId>spring-core</artifactId>
235+
<version>6.2.11</version>
236+
</dependency>
237+
<dependency>
238+
<groupId>org.springframework</groupId>
239+
<artifactId>spring-beans</artifactId>
240+
<version>6.2.11</version>
241+
</dependency>
242+
<dependency>
243+
<groupId>org.springframework</groupId>
244+
<artifactId>spring-web</artifactId>
245+
<version>6.2.11</version>
246+
</dependency>
247+
<!-- Fix CVE-2020-15250: junit pulled by json-simple -->
248+
<dependency>
249+
<groupId>junit</groupId>
250+
<artifactId>junit</artifactId>
251+
<version>4.13.2</version>
252+
</dependency>
218253
</dependencies>
219254
</dependencyManagement>
220255
<build>
@@ -271,14 +306,44 @@
271306
</executions>
272307
</plugin>
273308

309+
<!-- Surefire Plugin for API Tests -->
274310
<plugin>
275311
<groupId>org.apache.maven.plugins</groupId>
276312
<artifactId>maven-surefire-plugin</artifactId>
277313
<version>2.22.2</version>
278314
<configuration>
315+
<!-- Tests are skipped by default; use -Dtest to specify which tests to run -->
316+
<!-- Example: -Dtest='*IT' for integration tests, -Dtest='Test*' for unit tests -->
279317
<skipTests>true</skipTests>
318+
<!-- OPTIMIZED: Parallel execution with controlled concurrency -->
319+
<parallel>classes</parallel>
320+
<threadCount>4</threadCount>
321+
<perCoreThreadCount>false</perCoreThreadCount>
322+
<useUnlimitedThreads>false</useUnlimitedThreads>
323+
<!-- Reuse forks for better performance -->
324+
<reuseForks>true</reuseForks>
325+
<forkCount>2</forkCount>
326+
<!-- Increase timeout for slow tests -->
327+
<forkedProcessTimeoutInSeconds>500</forkedProcessTimeoutInSeconds>
328+
<!-- Better memory management -->
329+
<!-- @{argLine} allows JaCoCo to inject its agent -->
330+
<argLine>@{argLine} -Xmx2048m -XX:MaxMetaspaceSize=512m</argLine>
280331
</configuration>
281332
</plugin>
333+
334+
<plugin>
335+
<groupId>org.apache.maven.plugins</groupId>
336+
<artifactId>maven-surefire-report-plugin</artifactId>
337+
<version>2.22.2</version>
338+
<executions>
339+
<execution>
340+
<phase>test</phase>
341+
<goals>
342+
<goal>report-only</goal>
343+
</goals>
344+
</execution>
345+
</executions>
346+
</plugin>
282347

283348
<plugin>
284349
<groupId>org.apache.maven.plugins</groupId>
@@ -377,7 +442,7 @@
377442
</goals>
378443
<configuration>
379444
<dataFile>target/jacoco.exec</dataFile>
380-
<outputDirectory>target/jacoco-ut</outputDirectory>
445+
<!-- outputDirectory removed - uses default: target/site/jacoco/ -->
381446
</configuration>
382447
</execution>
383448
</executions>

send-report.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ echo "📄 Generating Surefire HTML report..."
4242
mvn surefire-report:report-only
4343

4444
echo "📤 Sending test report to Slack..."
45-
mvn compile exec:java -Dexec.mainClass="com.contentstack.sdk.SanityReport"
45+
mvn test-compile exec:java -Dexec.mainClass="com.contentstack.sdk.SanityReport" -Dexec.classpathScope=test
4646

4747
# Restore pom.xml and clean up
4848
restore_pom

0 commit comments

Comments
 (0)