|
4 | 4 | pull_request: |
5 | 5 | branches: "**" |
6 | 6 |
|
| 7 | +env: |
| 8 | + DIFF_COVERAGE_THRESHOLD: '80' |
| 9 | + |
7 | 10 | jobs: |
8 | 11 | build: |
9 | 12 | runs-on: ubuntu-24.04 |
10 | 13 | steps: |
11 | | - - uses: actions/checkout@v4 |
12 | | - - name: "[Setup] Java" |
13 | | - uses: actions/setup-java@v4 |
14 | | - with: |
15 | | - java-version: '17' |
16 | | - distribution: 'temurin' |
17 | | - - name: "[Setup] Android" |
18 | | - uses: android-actions/setup-android@v3 |
19 | | - with: |
20 | | - cmdline-tools-version: 10406996 |
21 | | - log-accepted-android-sdk-licenses: false |
22 | | - - name: "[Test] Linting" |
| 14 | + - name: "[Checkout] Repo" |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: "[Setup] Project" |
| 17 | + uses: ./.github/actions/project-setup |
| 18 | + - name: "[Code Formatting] Spotless" |
23 | 19 | working-directory: OneSignalSDK |
24 | 20 | run: | |
25 | 21 | ./gradlew spotlessCheck --console=plain |
26 | | - - name: "[Test] Detekt" |
| 22 | + - name: "[Static Code Analysis] Detekt" |
27 | 23 | working-directory: OneSignalSDK |
28 | 24 | run: | |
29 | 25 | ./gradlew detekt --console=plain |
30 | 26 | - name: "[Test] SDK Unit Tests" |
31 | 27 | working-directory: OneSignalSDK |
32 | 28 | run: | |
33 | 29 | ./gradlew testReleaseUnitTest --console=plain --continue |
| 30 | + - name: "[Coverage] Generate JaCoCo merged XML" |
| 31 | + working-directory: OneSignalSDK |
| 32 | + run: | |
| 33 | + ./gradlew jacocoTestReportAll jacocoMergedReport --console=plain --continue |
| 34 | + - name: "[Setup] Python" |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.x' |
| 38 | + - name: "[Diff Coverage] Install diff-cover" |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip diff-cover |
| 41 | + - name: "[Diff Coverage] Check and HTML report" |
| 42 | + working-directory: OneSignalSDK |
| 43 | + run: | |
| 44 | + REPORT=build/reports/jacoco/merged/jacocoMergedReport.xml |
| 45 | + test -f "$REPORT" || { echo "Merged JaCoCo report not found at $REPORT" >&2; exit 1; } |
| 46 | + python -m diff_cover.diff_cover_tool "$REPORT" \ |
| 47 | + --compare-branch=origin/main \ |
| 48 | + --fail-under=$DIFF_COVERAGE_THRESHOLD |
| 49 | + python -m diff_cover.diff_cover_tool "$REPORT" \ |
| 50 | + --compare-branch=origin/main \ |
| 51 | + --html-report diff_coverage.html || true |
| 52 | + - name: Upload diff coverage HTML |
| 53 | + if: always() |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: diff-coverage-report |
| 57 | + path: OneSignalSDK/diff_coverage.html |
34 | 58 | - name: Unit tests results |
35 | 59 | if: failure() |
36 | 60 | uses: actions/upload-artifact@v4 |
|
0 commit comments