Skip to content

Commit 702f841

Browse files
committed
configured script and ci job to collect and merge ut and it results
1 parent 7489379 commit 702f841

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ Collect container logs:
466466
paths:
467467
- "$K8S_NAMESPACE.log"
468468
- "$K8S_NAMESPACE-billing.json"
469+
- "*.exec"
469470

470471
#
471472
# dispose kubernetes resources
@@ -835,11 +836,11 @@ get_jacoco_cli:
835836

836837
# Job to generate JaCoCo report using script
837838
generate_jacoco_report:
838-
stage: build
839+
stage: testenv_post
839840
image: eclipse-temurin:17-jre
840841
needs:
841842
- job: run_ut_with_coverage
842-
artifacts: true
843+
- job: Collect container logs
843844
- job: get_jacoco_cli
844845
cache:
845846
key: "jacoco-cli-${JACOCO_VERSION}"
@@ -850,4 +851,8 @@ generate_jacoco_report:
850851
artifacts:
851852
paths:
852853
- target/coverage-reports/site/
854+
reports:
855+
coverage_report:
856+
coverage_format: jacoco
857+
path: target/coverage-reports/jacoco-total.xml
853858
expire_in: 1 week

generate-jacoco-report.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ fi
1616

1717
# Ensure the report directory exists
1818
mkdir -p "$REPORT_DIR"
19+
EXEC_FILES=$(find "$PROJECT_ROOT" -name "*.exec" -type f)
1920

20-
# Issue 1: Simplified find command (avoiding array initialization)
21-
EXEC_FILES=$(find "$PROJECT_ROOT" -name "jacoco-ut.exec" -type f)
22-
23-
# Issue 2: Simplified check for empty results using -z
2421
if [ -z "$EXEC_FILES" ]; then
25-
echo "Error: No jacoco-ut.exec files found in $PROJECT_ROOT"
22+
echo "Error: No .exec files found in $PROJECT_ROOT"
2623
exit 1
2724
fi
2825

@@ -43,21 +40,20 @@ echo "Generating coverage report..."
4340
CLASSFILES_ARGS=()
4441
SOURCEFILES_ARGS=()
4542

46-
# Issue 5: Iterating over the string list instead of an array
47-
for exec_file in ${EXEC_FILES}; do
48-
# Extract module path (e.g., core, dlm, rquota) from the exec file path
49-
module_path=$(dirname "$(dirname "$(dirname "$exec_file")")")
50-
51-
# Add classfiles and sourcefiles arguments
52-
CLASSFILES_ARGS+=("--classfiles" "$module_path/target/classes")
53-
SOURCEFILES_ARGS+=("--sourcefiles" "$module_path/src/main/java")
43+
for module in $(find modules -maxdepth 1 -mindepth 1 -type d); do
44+
if [ -d "$module/target/classes" ]; then
45+
CLASSFILES_ARGS+=("--classfiles" "$module/target/classes")
46+
SOURCEFILES_ARGS+=("--sourcefiles" "$module/src/main/java")
47+
fi
5448
done
5549

5650
# Generate the report with dynamic arguments
5751
java -jar "$JACOCO_CLI_JAR" report "$MERGED_EXEC" \
5852
"${CLASSFILES_ARGS[@]}" \
5953
"${SOURCEFILES_ARGS[@]}" \
60-
--html "$REPORT_DIR"
54+
--html "$REPORT_DIR" \
55+
--xml "$PROJECT_ROOT/target/coverage-reports/jacoco-total.xml" \
56+
--csv "$PROJECT_ROOT/target/coverage-reports/jacoco-total.csv"
6157

6258
if [ $? -ne 0 ]; then
6359
echo "Error: Failed to generate coverage report"

0 commit comments

Comments
 (0)