Skip to content

Update sonarqube.yml #11

Update sonarqube.yml

Update sonarqube.yml #11

Workflow file for this run

name: Run Tests and Upload Coverage to Codecov
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: Run tests and collect coverage
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Set up Java 17 (required for Android and Java-based testing)
- name: Set up Java 17
uses: actions/setup-java@v2
with:
java-version: '17'
java-package: jdk
architecture: x64
distribution: 'temurin'
- name: Decode google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
echo "$GOOGLE_SERVICES_JSON" > app/google-services.json
# Step 3: Install dependencies
- name: Install dependencies
run: |
chmod +x ./gradlew # Make gradlew executable
./gradlew build # Install dependencies (you can adjust this if needed)
# Step 4: Run tests and generate coverage report
- name: Run tests with coverage
run: |
chmod +x ./gradlew # Ensure gradlew is executable
./gradlew testDebugUnitTest jacocoTestReport # Run tests and generate coverage report
# Step 5: Upload coverage report to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }} # Ensure the token is added to your repo secrets
files: build/jacoco/testDebugUnitTest.exec # Path to the JaCoCo coverage file
flags: unittests # Optional, can be used to label the coverage