FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
contentstack-java/.github/workflows/unit-testing.yml at v2.5.0 · contentstack/contentstack-java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
contentstack
/
contentstack-java
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
4
Code
Issues
0
Pull requests
6
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
contentstack-java
/
.github
/
workflows
/
unit-testing.yml
Copy path
View runs
More file actions
More file actions
Latest commit
History
History
History
102 lines (80 loc) · 3.26 KB
Breadcrumbs
contentstack-java
/
.github
/
workflows
/
unit-testing.yml
Copy path
File metadata and controls
102 lines (80 loc) · 3.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name
:
Java SDK - Coverage Check
on
:
pull_request
:
branches
:
-
development
-
staging
-
master
jobs
:
coverage
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
🧾 Checkout repository
uses
:
actions/checkout@v4
-
name
:
☕ Set up JDK 8 (Temurin)
uses
:
actions/setup-java@v4
with
:
distribution
:
temurin
java-version
:
8
cache
:
maven
-
name
:
🧩 Ensure tests are enabled in pom.xml
run
:
|
echo "🔧 Ensuring tests are enabled in pom.xml..."
sed -i 's/<skipTests>true<\/skipTests>/<skipTests>false<\/skipTests>/g' pom.xml ||
true
-
name
:
🧪 Run tests and generate JaCoCo report
run
:
mvn clean test -Dtest='Test*' jacoco:report -Dgpg.skip=true
-
name
:
📊 Extract coverage from JaCoCo HTML report
id
:
extract_coverage
run
:
|
echo "📊 Extracting coverage summary from JaCoCo HTML report..."
REPORT="target/site/jacoco/index.html"
if [ ! -f "$REPORT" ]; then
echo "❌ JaCoCo HTML report not found!"
exit 1
fi
# Extract the <tfoot> Total row and clean it up
TOTAL_ROW=$(grep -A2 "<td>Total</td>" "$REPORT" | tr -d '\n')
# Extract numeric percentages in order (Instruction first, Branch second)
PERCENTAGES=($(echo "$TOTAL_ROW" | grep -oE '[0-9]+%' | sed 's/%//g'))
INSTRUCTION=${PERCENTAGES[0]:-0}
BRANCH=${PERCENTAGES[1]:-0}
echo "📘 Instruction Coverage: ${INSTRUCTION}%"
echo "🌿 Branch Coverage: ${BRANCH}%"
echo "instruction=${INSTRUCTION}" >> $GITHUB_OUTPUT
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
-
name
:
🚦 Enforce coverage threshold
run
:
|
MIN_INSTRUCTION=90
MIN_BRANCH=80
INSTRUCTION=${{ steps.extract_coverage.outputs.instruction }}
BRANCH=${{ steps.extract_coverage.outputs.branch }}
echo "🧾 Required minimums:"
echo " • Instruction: ${MIN_INSTRUCTION}%"
echo " • Branch: ${MIN_BRANCH}%"
echo ""
echo "📈 Actual coverage:"
echo " • Instruction: ${INSTRUCTION}%"
echo " • Branch: ${BRANCH}%"
if [ "$INSTRUCTION" -lt "$MIN_INSTRUCTION" ]; then
echo "❌ Instruction coverage (${INSTRUCTION}%) is below the threshold (${MIN_INSTRUCTION}%)"
exit 1
fi
if [ "$BRANCH" -lt "$MIN_BRANCH" ]; then
echo "❌ Branch coverage (${BRANCH}%) is below the threshold (${MIN_BRANCH}%)"
exit 1
fi
echo "✅ Coverage thresholds met!"
-
name
:
💬 Post coverage summary as PR comment
uses
:
marocchino/sticky-pull-request-comment@v2
with
:
header
:
🧪 JaCoCo Coverage Report
message
:
|
**Coverage Summary**
- 📘 Instruction Coverage: `${{ steps.extract_coverage.outputs.instruction }}%`
- 🌿 Branch Coverage: `${{ steps.extract_coverage.outputs.branch }}%`
-
name
:
📦 Upload JaCoCo HTML report as artifact
uses
:
actions/upload-artifact@v4
with
:
name
:
jacoco-report
path
:
target/site/jacoco/
if-no-files-found
:
warn
Back
|
FazBrowse Home
|
New Git URL