Skip to content

chore: adding test coverage #3

chore: adding test coverage

chore: adding test coverage #3

Workflow file for this run

name: Diff Coverage
on:
pull_request:
branches: "**"
workflow_dispatch:
env:
DIFF_COVERAGE_THRESHOLD: '80'
jobs:
diff-coverage:
name: Run Diff Coverage Check
runs-on: ubuntu-latest
steps:
- name: "[Checkout] Repo"
uses: actions/checkout@v4
- name: "[Setup] Project"
uses: ./.github/actions/project-setup
- name: Run Unit Tests with Coverage
working-directory: OneSignalSDK
run: |
./gradlew --no-daemon clean testDebugUnitTest jacocoTestReportAll jacocoMergedReport
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install diff-cover
run: |
python -m pip install --upgrade pip diff-cover
- name: Diff Coverage (fail under threshold)
working-directory: OneSignalSDK
run: |
REPORT=build/reports/jacoco/merged/jacocoMergedReport.xml
test -f "$REPORT" || { echo "Merged JaCoCo report not found at $REPORT" >&2; exit 1; }
python -m diff_cover.diff_cover_tool "$REPORT" \
--compare-branch=origin/main \
--fail-under=$DIFF_COVERAGE_THRESHOLD
- name: Generate HTML Diff Report
if: always()
working-directory: OneSignalSDK
run: |
REPORT=build/reports/jacoco/merged/jacocoMergedReport.xml
test -f "$REPORT" || { echo "Merged JaCoCo report not found at $REPORT" >&2; exit 1; }
python -m diff_cover.diff_cover_tool "$REPORT" \
--compare-branch=origin/main \
--html-report diff_coverage.html || true
- name: Upload JaCoCo Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-full-report
path: OneSignalSDK/build/reports/jacoco/
- name: Upload Diff Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: diff-coverage-report
path: OneSignalSDK/diff_coverage.html