119 lines
3.8 KiB
YAML
119 lines
3.8 KiB
YAML
name: Android CI / RC
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'android-app/**'
|
|
- 'api-v3/src/**'
|
|
- '.github/workflows/android.yml'
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- 'android-app/**'
|
|
- 'api-v3/src/**'
|
|
- '.github/workflows/android.yml'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: dhv2-android-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
android:
|
|
name: Android · lint, tests, debug APK, release compile
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 35
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Java 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: '17'
|
|
|
|
- name: Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: Android API 36
|
|
run: sdkmanager 'platforms;android-36' 'build-tools;36.0.0'
|
|
|
|
- name: Gradle 8.13
|
|
uses: gradle/actions/setup-gradle@v4
|
|
with:
|
|
gradle-version: '8.13'
|
|
|
|
- name: Android lint
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:lintDebug
|
|
|
|
- name: Android unit tests
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:testDebugUnitTest
|
|
|
|
- name: Require real unit-test results
|
|
run: |
|
|
set -Eeuo pipefail
|
|
result="$(find android-app/app/build/test-results/testDebugUnitTest -type f -name 'TEST-*.xml' -print -quit)"
|
|
test -n "$result"
|
|
grep -Eq '<testsuite[^>]+tests="[1-9][0-9]*"' "$result"
|
|
|
|
- name: Assemble debug APK
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:assembleDebug
|
|
|
|
- name: Compile unsigned release variant
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:assembleRelease
|
|
|
|
- name: Package RC artifact and checksum
|
|
id: package
|
|
run: |
|
|
set -Eeuo pipefail
|
|
version="$(sed -n 's/^[[:space:]]*versionName = "\([^"]*\)"/\1/p' android-app/app/build.gradle.kts | head -n1)"
|
|
code="$(sed -n 's/^[[:space:]]*versionCode = \([0-9][0-9]*\)/\1/p' android-app/app/build.gradle.kts | head -n1)"
|
|
test -n "$version"
|
|
test -n "$code"
|
|
short_sha="${GITHUB_SHA::12}"
|
|
mkdir -p android-app/dist
|
|
apk="android-app/dist/DH-Inspeccion-${version}-vc${code}-${short_sha}-debug.apk"
|
|
cp android-app/app/build/outputs/apk/debug/app-debug.apk "$apk"
|
|
sha256sum "$apk" > "${apk}.sha256"
|
|
{
|
|
echo "version=$version"
|
|
echo "versionCode=$code"
|
|
echo "commit=$GITHUB_SHA"
|
|
echo "artifact=$(basename "$apk")"
|
|
echo "applicationId=com.korexlabs.dhinspeccion.debug"
|
|
echo "apiBaseUrl=https://dhv2.korexlabs.com/api/v3/"
|
|
echo "channel=DEBUG_RC"
|
|
} > android-app/dist/release-metadata.txt
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
echo "version_code=$code" >> "$GITHUB_OUTPUT"
|
|
echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload debug RC
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: DH-Inspeccion-${{ steps.package.outputs.version }}-vc${{ steps.package.outputs.version_code }}-${{ steps.package.outputs.short_sha }}-debug
|
|
path: android-app/dist/*
|
|
if-no-files-found: error
|
|
retention-days: 30
|
|
|
|
- name: Upload Android diagnostics
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-diagnostics-${{ github.sha }}
|
|
path: |
|
|
android-app/app/build/reports/lint-results-debug.html
|
|
android-app/app/build/reports/tests/testDebugUnitTest/**
|
|
android-app/app/build/test-results/testDebugUnitTest/**
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|