Update Test cases #14
Workflow file for this run
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
| name: Android Unit Tests with JaCoCo | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout repo | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| # 2. Set up JDK | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| # 3. Cache Gradle deps | |
| - name: Cache Gradle | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle | |
| # 4. Run tests + coverage | |
| - name: Run unit tests with JaCoCo | |
| run: ./gradlew clean testDebugUnitTest jacocoTestReport | |
| # 5. Upload HTML report as artifact | |
| - name: Upload JaCoCo HTML report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: jacoco-report | |
| path: app/build/reports/jacoco/jacocoTestReport/ | |
| # ✅ Optional: Fail build if coverage < 50% | |
| - name: Enforce coverage minimum | |
| uses: devmasx/coverage-check-action@v1.2.0 | |
| with: | |
| type: jacoco | |
| result_path: app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml | |
| min_coverage: 60 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # - name: Add JaCoCo Coverage Summary | |
| # uses: jjmrocha/jacoco-summary@v1.1.1 | |
| # with: | |
| # jacoco-csv-file: app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.csv | |