Files
super-app/.github/workflows/metrics_logger.yml
2023-12-31 14:21:31 +05:30

79 lines
3.4 KiB
YAML

name: Metrics Logger
on:
schedule:
- cron: '30 1 * * *'
env:
NON_PROD_RELEASE_STORE_PASSWORD: android
NON_PROD_RELEASE_KEY_ALIAS: navi
NON_PROD_RELEASE_KEY_PASSWORD: android
jobs:
log_build_metrics:
strategy:
fail-fast: false
max-parallel: 1
matrix:
build_type:
- freshDebug
- cachedRelease
runs-on: [ macOS ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Log Build Metadata
run: |
echo "Commit SHA: ${{ github.sha }}"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Disable local and remote cache
if: matrix.build_type == 'freshDebug'
run: |
sed -i '' 's/enabled = true/enabled = false/g' settings.gradle
- name: Print settings.gradle
run: cat settings.gradle
- name: Copy release key
if: matrix.build_type == 'cachedRelease'
run: cp keystore/navi-non-prod-release-key.jks app/navi-release-key.jks
- name: Build APK
id: build_apk
run: |
t1=$(( $(date +%s) * 1000 ))
if [[ "${{ matrix.build_type }}" == "cachedRelease" ]]; then
./gradlew packageQaReleaseUniversalApk --stacktrace -PRELEASE_STORE_PASSWORD=$NON_PROD_RELEASE_STORE_PASSWORD -PRELEASE_KEY_ALIAS=$NON_PROD_RELEASE_KEY_ALIAS -PRELEASE_KEY_PASSWORD=$NON_PROD_RELEASE_KEY_PASSWORD
else
./gradlew packageQaDebugUniversalApk --stacktrace
fi
t2=$(( $(date +%s) * 1000 - t1 ))
echo "BUILD_TIME=$t2" >> "$GITHUB_OUTPUT"
- name: Calculate Apk Size
id: apk_size
run: |
if [[ "${{ matrix.build_type }}" == "cachedRelease" ]]; then
apk_size=$(stat -f%z app/build/outputs/apk_from_bundle/qaRelease/app-qa-release-universal.apk)
else
apk_size=$(stat -f%z app/build/outputs/apk_from_bundle/qaDebug/app-qa-debug-universal.apk)
fi
echo "APK_SIZE=$apk_size" >> "$GITHUB_OUTPUT"
- name: Log metrics
run: |
if [[ "${{ matrix.build_type }}" == "cachedDebug" ]]; then
build_time_key="cached_debug_build_time"
apk_size_key="debug_apk_size"
elif [[ "${{ matrix.build_type }}" == "cachedRelease" ]]; then
build_time_key="cached_release_build_time"
apk_size_key="release_apk_size"
else
build_time_key="fresh_debug_build_time"
apk_size_key="debug_apk_size"
fi
echo "Input value: ${{ matrix.build_type }}"
timestamp=$(($(date +%s) * 1000)) && echo "{\"events\":[{\"attributes\":{\"$build_time_key\":\"${{ steps.build_apk.outputs.BUILD_TIME }}\",\"$apk_size_key\":\"${{ steps.apk_size.outputs.APK_SIZE }}\"},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}"
timestamp=$(($(date +%s) * 1000)) && curl -X POST -H "Content-Type: application/json" -d "{\"events\":[{\"attributes\":{\"$build_time_key\":\"${{ steps.build_apk.outputs.BUILD_TIME }}\",\"$apk_size_key\":\"${{ steps.apk_size.outputs.APK_SIZE }}\"},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}" https://janus.prod.navi-tech.in/events/json
- name: Run UI tests
if: matrix.build_type == 'freshDebug'
run: ./gradlew :app:connectedUitestDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=com.navi.ap --stacktrace