Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/actions/project-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
runs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you use in this in more than 1 place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will eventually use it in the create PR flow as well as we are doing the same thing there.

using: composite
steps:
- name: Checkout (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: '10406996'
log-accepted-android-sdk-licenses: false

- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle/libs.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-
50 changes: 37 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,57 @@ on:
pull_request:
branches: "**"

env:
DIFF_COVERAGE_THRESHOLD: '80'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is % coverage


jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: "[Setup] Java"
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: "[Setup] Android"
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 10406996
log-accepted-android-sdk-licenses: false
- name: "[Test] Linting"
- name: "[Checkout] Repo"
uses: actions/checkout@v4
- name: "[Setup] Project"
uses: ./.github/actions/project-setup
- name: "[Code Formatting] Spotless"
working-directory: OneSignalSDK
run: |
./gradlew spotlessCheck --console=plain
- name: "[Test] Detekt"
- name: "[Static Code Analysis] Detekt"
working-directory: OneSignalSDK
run: |
./gradlew detekt --console=plain
- name: "[Test] SDK Unit Tests"
working-directory: OneSignalSDK
run: |
./gradlew testReleaseUnitTest --console=plain --continue
- name: "[Coverage] Generate JaCoCo merged XML"
working-directory: OneSignalSDK
run: |
./gradlew jacocoTestReportAll jacocoMergedReport --console=plain --continue
- name: "[Setup] Python"
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "[Diff Coverage] Install diff-cover"
run: |
python -m pip install --upgrade pip diff-cover
- name: "[Diff Coverage] Check and HTML report"
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
python -m diff_cover.diff_cover_tool "$REPORT" \
--compare-branch=origin/main \
--html-report diff_coverage.html || true
- name: Upload diff coverage HTML
if: always()
uses: actions/upload-artifact@v4
with:
name: diff-coverage-report
path: OneSignalSDK/diff_coverage.html
- name: Unit tests results
if: failure()
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions OneSignalSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ gradle.projectsEvaluated {
description = 'Creates/updates Detekt baselines for all modules.'
}
}

// Apply JaCoCo configuration from separate file
apply from: 'jacoco.gradle'
Loading
Loading