-
Notifications
You must be signed in to change notification settings - Fork 376
chore: adding test coverage #2381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e500548
adding test coverage
3f76a16
jacoco and diff
a3384ec
Merge branch 'main' into testcoverage
abdulraqeeb33 30d50db
using custom diff
138ecf0
Merge remote-tracking branch 'origin/testcoverage' into testcoverage
39ad4d2
coverage with checkout
cb2e853
diff cover in one workflow
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| runs: | ||
| 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- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,33 +4,57 @@ on: | |
| pull_request: | ||
| branches: "**" | ||
|
|
||
| env: | ||
| DIFF_COVERAGE_THRESHOLD: '80' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.