Update codecov.yml #4
This file contains 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: Run Android Tests and Upload Coverage | |
on: | |
push: | |
branches: | |
- main # Or any branch you want to trigger the workflow for | |
jobs: | |
test: | |
name: Run Android tests and collect coverage | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Ensures the entire commit history is fetched | |
# Step 2: Set up Java (required for Android builds) | |
- name: Set up Java 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
java-package: jdk | |
architecture: x64 | |
distribution: 'temurin' | |
# Step 3: Install Android SDK | |
- name: Install Android SDK | |
run: | | |
# Install required dependencies | |
sudo apt update | |
sudo apt install -y wget unzip lib32stdc++6 lib32z1 | |
# Download and install Android SDK tools | |
wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip | |
unzip commandlinetools-linux-7583922_latest.zip -d $HOME/android-sdk | |
# Install necessary SDK components (e.g., platforms and system images) | |
export ANDROID_HOME=$HOME/android-sdk | |
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools | |
yes | sdkmanager --sdk_root=$ANDROID_HOME --licenses | |
sdkmanager --update | |
sdkmanager "platforms;android-30" "system-images;android-30;google_apis;x86_64" "build-tools;30.0.3" | |
# Step 4: Set up Android Emulator | |
- name: Set up Android Emulator | |
run: | | |
# Create and start an Android Emulator | |
echo no | avdmanager create avd --name test --package "system-images;android-30;google_apis;x86_64" --force | |
nohup emulator -avd test -no-window -no-skin -gpu off & | |
# Wait for the emulator to boot up | |
adb wait-for-device | |
# Step 5: Run unit tests with coverage using Gradle | |
- name: Run unit tests with coverage | |
run: ./gradlew testDebugUnitTest --coverage | |
# Step 6: Upload coverage report to Codecov | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage/coverage.xml # Make sure the report path is correct |