Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Update ci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
otavio-code authored Dec 1, 2024
1 parent 0d9a1c0 commit fd05148
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,53 +41,53 @@ jobs:
./gradlew clean test jacocoTestReport
echo "Generated JaCoCo reports:"
ls -R build/reports/jacoco || echo "No JaCoCo reports found."
- name: Extract and display coverage percentage
run: |
# Caminho fixo do relatório XML
REPORT_PATH=build/reports/jacoco/test/jacocoTestReport.xml
if [ ! -f "$REPORT_PATH" ]; then
echo "JaCoCo XML coverage report not found!"
exit 1
fi
echo "Found JaCoCo XML report at: $REPORT_PATH"
# Extração dos dados de cobertura
COVERED=$(xmllint --xpath 'string(sum(//counter[@type="LINE"]/@covered))' "$REPORT_PATH")
MISSED=$(xmllint --xpath 'string(sum(//counter[@type="LINE"]/@missed))' "$REPORT_PATH")
if [ -z "$COVERED" ] || [ -z "$MISSED" ]; then
echo "Error: Unable to extract coverage data from the XML report."
exit 1
fi
# Converte valores para inteiros para evitar problemas de cálculo
COVERED=$(printf "%.0f" "$COVERED")
MISSED=$(printf "%.0f" "$MISSED")
TOTAL=$((COVERED + MISSED))
if [ "$TOTAL" -eq 0 ]; then
echo "Error: Total lines is zero, coverage cannot be calculated."
exit 1
fi
# Cálculo do percentual de cobertura
PERCENTAGE=$(echo "scale=2; ($COVERED / $TOTAL) * 100" | bc)
echo "Lines Covered: $COVERED"
echo "Lines Missed: $MISSED"
echo "Total Lines: $TOTAL"
echo "Coverage Percentage: $PERCENTAGE%"
# Validação da cobertura mínima
MINIMUM=50.0
if (( $(echo "$PERCENTAGE < $MINIMUM" | bc -l) )); then
echo "Coverage is below the minimum required: $MINIMUM%!"
exit 1
fi
echo "Coverage validation passed with $PERCENTAGE%."
- name: Extract and display coverage percentage
run: |
# Caminho fixo do relatório XML
REPORT_PATH=build/reports/jacoco/test/jacocoTestReport.xml
if [ ! -f "$REPORT_PATH" ]; then
echo "JaCoCo XML coverage report not found!"
exit 1
fi
echo "Found JaCoCo XML report at: $REPORT_PATH"
# Extração dos dados de cobertura
COVERED=$(xmllint --xpath 'string(sum(//counter[@type="LINE"]/@covered))' "$REPORT_PATH")
MISSED=$(xmllint --xpath 'string(sum(//counter[@type="LINE"]/@missed))' "$REPORT_PATH")
if [ -z "$COVERED" ] || [ -z "$MISSED" ]; then
echo "Error: Unable to extract coverage data from the XML report."
exit 1
fi
# Converte valores para inteiros para evitar problemas de cálculo
COVERED=$(printf "%.0f" "$COVERED")
MISSED=$(printf "%.0f" "$MISSED")
TOTAL=$((COVERED + MISSED))
if [ "$TOTAL" -eq 0 ]; then
echo "Error: Total lines is zero, coverage cannot be calculated."
exit 1
fi
# Cálculo do percentual de cobertura
PERCENTAGE=$(echo "scale=2; ($COVERED / $TOTAL) * 100" | bc)
echo "Lines Covered: $COVERED"
echo "Lines Missed: $MISSED"
echo "Total Lines: $TOTAL"
echo "Coverage Percentage: $PERCENTAGE%"
# Validação da cobertura mínima
MINIMUM=50.0
if (( $(echo "$PERCENTAGE < $MINIMUM" | bc -l) )); then
echo "Coverage is below the minimum required: $MINIMUM%!"
exit 1
fi
echo "Coverage validation passed with $PERCENTAGE%."


build:
Expand Down

0 comments on commit fd05148

Please sign in to comment.