Skip to content

Refactors the MetricsManager to improve reliability and monitoring control for metric delivery. #187

Refactors the MetricsManager to improve reliability and monitoring control for metric delivery.

Refactors the MetricsManager to improve reliability and monitoring control for metric delivery. #187

Workflow file for this run

name: Android CI
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
api-level: 30
build-tools: 30.0.3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle (no tests)
run: ./gradlew assemble
- name: Save Build Artifacts
uses: actions/upload-artifact@v4
with:
name: app-build
path: app/build/outputs/apk/
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
api-level: 30
build-tools: 30.0.3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Unit Tests and Capture Results
id: run_tests
run: |
# Run tests and capture exit code
./gradlew test | tee test-results.txt
TEST_EXIT_CODE=${PIPESTATUS[0]} # Capture the exit code of ./gradlew test
# Extract a clean test summary from Gradle output
echo "### 📌 Unit Test Summary" > test-summary.txt
grep -A 10 "Test Summary" test-results.txt | tail -n +2 | sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> test-summary.txt
# Print the test summary in GitHub Actions logs
cat test-summary.txt
# Fail the workflow if tests fail
if [ $TEST_EXIT_CODE -ne 0 ]; then
echo "❌ Unit tests failed. See test-results.txt for details."
exit $TEST_EXIT_CODE # Fail the workflow
fi