Skip to content

Commit 4e2eca2

Browse files
committed
code coverage: jacoco script divided into: get & generate
Motivation: To also include pynfs tests to the code coverage we needed to separate the generate-jacoco-report.sh script functionality into two separate ones. To be able to set JaCoCo CLI first and then run pynfs tests. Modifications: Added get-jacoco.sh, which checks existing cache for JaCoCo CLI and downloads it if not found. Deleted cache and download management of JaCoCo CLI from generate-jacoco-report.sh. Added a new job "Get JaCoCo CLI" to build.yml to run our new script get-jacoco.sh. Moved "Generate JaCoCo Report" and "Upload JaCoCo Report" jobs after pynfs tests in build.yml Results: Pynfs test results are also included in the merged code coverage report. Testing: Validated reports locally and in CI. Acked-by: Target: master Require-book: no Require-notes: no Committed:
1 parent 1042c50 commit 4e2eca2

File tree

3 files changed

+46
-33
lines changed

3 files changed

+46
-33
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ jobs:
3030
- name: Build with Maven
3131
run: mvn --batch-mode --update-snapshots package
3232

33-
- name: Generate JaCoCo Report
33+
- name: Get JaCoCo CLI
3434
run: |
35-
chmod +x ./generate-jacoco-report.sh
36-
./generate-jacoco-report.sh
37-
38-
- name: Upload JaCoCo Report
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: JaCoCo Coverage Report
42-
path: target/coverage-reports/site
35+
chmod +x ./get-jacoco.sh
36+
./get-jacoco.sh
4337
4438
- name: JUnit test report
4539
uses: mikepenz/action-junit-report@v5
@@ -58,3 +52,14 @@ jobs:
5852
with:
5953
check_name: pynfs protocol compatibility test
6054
report_paths: "report/*.xml"
55+
56+
- name: Generate JaCoCo Report
57+
run: |
58+
chmod +x ./generate-jacoco-report.sh
59+
./generate-jacoco-report.sh
60+
61+
- name: Upload JaCoCo Report
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: JaCoCo Coverage Report
65+
path: target/coverage-reports/site

generate-jacoco-report.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@ REPORT_DIR="$PROJECT_ROOT/target/coverage-reports/site"
1111
# Ensure the report directory exists
1212
mkdir -p "$REPORT_DIR"
1313

14-
# Debug: Print paths
15-
echo "DEBUG: JACOCO_CLI_JAR: $JACOCO_CLI_JAR"
16-
echo "DEBUG: Checking if $JACOCO_CLI_JAR exists..."
17-
18-
# Check if JaCoCo CLI JAR exists in the cache directory
19-
if [ ! -f "$JACOCO_CLI_JAR" ]; then
20-
echo "JaCoCo CLI JAR not found in cache directory. Downloading..."
21-
mkdir -p "$JACOCO_DIR"
22-
wget -q "https://github.com/jacoco/jacoco/releases/download/v$JACOCO_VERSION/jacoco-$JACOCO_VERSION.zip" -O "/tmp/jacoco-$JACOCO_VERSION.zip"
23-
unzip -q "/tmp/jacoco-$JACOCO_VERSION.zip" -d "$JACOCO_DIR"
24-
rm -f "/tmp/jacoco-$JACOCO_VERSION.zip"
25-
echo "DEBUG: Downloaded JaCoCo CLI to $JACOCO_DIR"
26-
ls -la "$JACOCO_DIR"
27-
else
28-
echo "DEBUG: JaCoCo CLI JAR found at $JACOCO_CLI_JAR"
29-
fi
30-
31-
# Check if JaCoCo CLI JAR exists after download
32-
if [ ! -f "$JACOCO_CLI_JAR" ]; then
33-
echo "Error: JaCoCo CLI JAR not found at $JACOCO_CLI_JAR"
34-
exit 1
35-
fi
36-
3714
# Find all jacoco-ut.exec files dynamically
3815
EXEC_FILES=($(find "$PROJECT_ROOT" -name "jacoco-ut.exec" -type f))
3916

@@ -71,7 +48,6 @@ for exec_file in "${EXEC_FILES[@]}"; do
7148
# Extract module path (e.g., core, dlm, rquota) from the exec file path
7249
module_path=$(dirname "$(dirname "$(dirname "$exec_file")")")
7350
module_name=$(basename "$module_path")
74-
7551
# Add classfiles and sourcefiles arguments
7652
CLASSFILES_ARGS+=("--classfiles" "$module_path/target/classes")
7753
SOURCEFILES_ARGS+=("--sourcefiles" "$module_path/src/main/java")

get-jacoco.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Define paths
4+
PROJECT_ROOT="${PROJECT_ROOT:-$(pwd)}"
5+
JACOCO_VERSION="0.8.14"
6+
JACOCO_DIR="${PROJECT_ROOT}/jacoco-$JACOCO_VERSION"
7+
JACOCO_CLI_JAR="$JACOCO_DIR/lib/jacococli.jar"
8+
9+
# Debug: Print paths
10+
echo "DEBUG: JACOCO_CLI_JAR: $JACOCO_CLI_JAR"
11+
echo "DEBUG: Checking if $JACOCO_CLI_JAR exists..."
12+
13+
# Check if JaCoCo CLI JAR exists in the cache directory
14+
if [ ! -f "$JACOCO_CLI_JAR" ]; then
15+
echo "JaCoCo CLI JAR not found in cache directory. Downloading..."
16+
mkdir -p "$JACOCO_DIR"
17+
wget -q "https://github.com/jacoco/jacoco/releases/download/v$JACOCO_VERSION/jacoco-$JACOCO_VERSION.zip" -O "/tmp/jacoco-$JACOCO_VERSION.zip"
18+
unzip -q "/tmp/jacoco-$JACOCO_VERSION.zip" -d "$JACOCO_DIR"
19+
rm -f "/tmp/jacoco-$JACOCO_VERSION.zip"
20+
echo "DEBUG: Downloaded JaCoCo CLI to $JACOCO_DIR"
21+
ls -la "$JACOCO_DIR"
22+
else
23+
echo "DEBUG: JaCoCo CLI JAR found at $JACOCO_CLI_JAR"
24+
fi
25+
26+
# Check if JaCoCo CLI JAR exists after download
27+
if [ ! -f "$JACOCO_CLI_JAR" ]; then
28+
echo "Error: JaCoCo CLI JAR not found at $JACOCO_CLI_JAR"
29+
exit 1
30+
fi
31+
32+
export JACOCO_CLI_JAR

0 commit comments

Comments
 (0)