144 lines
5.1 KiB
YAML
144 lines
5.1 KiB
YAML
name: Android CI / RC
|
|
# F6.1 presentation barrier: lint + real tests + debug artifact + release compile.
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'release/f6-1*'
|
|
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: Validate mobile security and identity contract
|
|
run: |
|
|
set -Eeuo pipefail
|
|
grep -Fq 'applicationId = "com.korexlabs.dhinspeccion"' android-app/app/build.gradle.kts
|
|
grep -Fq 'applicationIdSuffix = ".debug"' android-app/app/build.gradle.kts
|
|
grep -Fq 'buildConfigField("String", "API_BASE_URL", "\"https://dhv2.korexlabs.com/api/v3/\"")' android-app/app/build.gradle.kts
|
|
grep -Fq 'android:allowBackup="false"' android-app/app/src/main/AndroidManifest.xml
|
|
grep -Fq 'android:usesCleartextTraffic="false"' android-app/app/src/main/AndroidManifest.xml
|
|
|
|
- name: Android lint
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:lintDebug
|
|
|
|
- name: Print complete lint failures
|
|
if: failure()
|
|
run: |
|
|
report="android-app/app/build/intermediates/lint_intermediate_text_report/debug/lintReportDebug/lint-results-debug.txt"
|
|
if [ -f "$report" ]; then
|
|
echo '========== ANDROID LINT =========='
|
|
cat "$report"
|
|
fi
|
|
|
|
- name: Android unit tests
|
|
working-directory: android-app
|
|
run: gradle --no-daemon :app:testDebugUnitTest
|
|
|
|
- name: Require real unit-test results
|
|
run: |
|
|
set -Eeuo pipefail
|
|
test_dir="android-app/app/build/test-results/testDebugUnitTest"
|
|
test -d "$test_dir"
|
|
total="$(grep -h -oE '<testsuite[^>]+tests="[0-9]+"' "$test_dir"/TEST-*.xml 2>/dev/null | sed -E 's/.*tests="([0-9]+)"/\1/' | awk '{sum += $1} END {print sum + 0}')"
|
|
test "$total" -gt 0
|
|
echo "Android unit tests discovered: $total"
|
|
|
|
- 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 "phase=F6.1"
|
|
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
|