mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-27 10:11:48 -04:00
260 lines
11 KiB
YAML
260 lines
11 KiB
YAML
name: Reusable Android Check
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
run_lint:
|
|
type: boolean
|
|
default: true
|
|
run_unit_tests:
|
|
type: boolean
|
|
default: true
|
|
run_instrumented_tests:
|
|
type: boolean
|
|
default: true
|
|
api_levels:
|
|
type: string
|
|
default: '[35]'
|
|
upload_artifacts:
|
|
type: boolean
|
|
default: true
|
|
secrets:
|
|
GRADLE_ENCRYPTION_KEY:
|
|
required: false
|
|
CODECOV_TOKEN:
|
|
required: false
|
|
DATADOG_APPLICATION_ID:
|
|
required: false
|
|
DATADOG_CLIENT_TOKEN:
|
|
required: false
|
|
GOOGLE_MAPS_API_KEY:
|
|
required: false
|
|
GRADLE_CACHE_URL:
|
|
required: false
|
|
GRADLE_CACHE_USERNAME:
|
|
required: false
|
|
GRADLE_CACHE_PASSWORD:
|
|
required: false
|
|
|
|
env:
|
|
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
|
|
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
|
|
MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
|
|
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
|
|
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
|
|
|
|
jobs:
|
|
host-check:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: 'recursive'
|
|
|
|
- name: Validate Gradle Wrapper
|
|
uses: gradle/actions/wrapper-validation@v5
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'jetbrains'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.event_name != 'merge_group' && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') }}
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
cache-cleanup: on-success
|
|
build-scan-publish: true
|
|
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
|
|
build-scan-terms-of-use-agree: 'yes'
|
|
add-job-summary: always
|
|
|
|
- name: Code Style & Static Analysis
|
|
if: inputs.run_lint == true
|
|
run: ./gradlew spotlessCheck detekt -Pci=true --scan
|
|
|
|
- name: Android Lint
|
|
if: inputs.run_lint == true
|
|
run: ./gradlew app:lintFdroidDebug app:lintGoogleDebug core:barcode:lintFdroidDebug core:barcode:lintGoogleDebug core:api:lintDebug mesh_service_example:lintDebug -Pci=true --continue --scan
|
|
|
|
- name: Shared Unit Tests & Coverage
|
|
if: inputs.run_unit_tests == true
|
|
run: ./gradlew test koverXmlReport app:koverXmlReportFdroidDebug app:koverXmlReportGoogleDebug core:api:koverXmlReportDebug core:barcode:koverXmlReportFdroidDebug core:barcode:koverXmlReportGoogleDebug mesh_service_example:koverXmlReportDebug desktop:koverXmlReport -Pci=true --continue --scan
|
|
|
|
- name: KMP Smoke Compile
|
|
run: ./gradlew :core:proto:compileKotlinJvm :core:common:compileKotlinJvm :core:model:compileKotlinJvm :core:repository:compileKotlinJvm :core:di:compileKotlinJvm :core:navigation:compileKotlinJvm :core:resources:compileKotlinJvm :core:datastore:compileKotlinJvm :core:database:compileKotlinJvm :core:domain:compileKotlinJvm :core:prefs:compileKotlinJvm :core:network:compileKotlinJvm :core:data:compileKotlinJvm :core:ble:compileKotlinJvm :core:nfc:compileKotlinJvm :core:service:compileKotlinJvm :core:testing:compileKotlinJvm :core:ui:compileKotlinJvm :feature:intro:compileKotlinJvm :feature:messaging:compileKotlinJvm :feature:connections:compileKotlinJvm :feature:map:compileKotlinJvm :feature:node:compileKotlinJvm :feature:settings:compileKotlinJvm :feature:firmware:compileKotlinJvm :core:proto:compileKotlinIosSimulatorArm64 :core:common:compileKotlinIosSimulatorArm64 :core:model:compileKotlinIosSimulatorArm64 :core:repository:compileKotlinIosSimulatorArm64 :core:di:compileKotlinIosSimulatorArm64 :core:navigation:compileKotlinIosSimulatorArm64 :core:resources:compileKotlinIosSimulatorArm64 :core:datastore:compileKotlinIosSimulatorArm64 :core:database:compileKotlinIosSimulatorArm64 :core:domain:compileKotlinIosSimulatorArm64 :core:prefs:compileKotlinIosSimulatorArm64 :core:network:compileKotlinIosSimulatorArm64 :core:data:compileKotlinIosSimulatorArm64 :core:ble:compileKotlinIosSimulatorArm64 :core:nfc:compileKotlinIosSimulatorArm64 :core:service:compileKotlinIosSimulatorArm64 :core:testing:compileKotlinIosSimulatorArm64 :core:ui:compileKotlinIosSimulatorArm64 :feature:intro:compileKotlinIosSimulatorArm64 :feature:messaging:compileKotlinIosSimulatorArm64 :feature:connections:compileKotlinIosSimulatorArm64 :feature:map:compileKotlinIosSimulatorArm64 :feature:node:compileKotlinIosSimulatorArm64 :feature:settings:compileKotlinIosSimulatorArm64 :feature:firmware:compileKotlinIosSimulatorArm64 -Pci=true --continue --scan
|
|
|
|
- name: Upload coverage results to Codecov
|
|
if: ${{ !cancelled() && inputs.run_unit_tests }}
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
slug: meshtastic/Meshtastic-Android
|
|
flags: host-unit
|
|
fail_ci_if_error: false
|
|
files: "**/build/reports/kover/report*.xml"
|
|
|
|
- name: Upload unit test results to Codecov
|
|
if: ${{ !cancelled() && inputs.run_unit_tests }}
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
slug: meshtastic/Meshtastic-Android
|
|
flags: host-unit
|
|
fail_ci_if_error: false
|
|
report_type: test_results
|
|
files: "**/build/test-results/**/*.xml"
|
|
|
|
- name: Upload host reports
|
|
if: ${{ always() && inputs.upload_artifacts }}
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: reports-host
|
|
path: |
|
|
**/build/reports
|
|
**/build/test-results
|
|
retention-days: 7
|
|
|
|
android-check:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
timeout-minutes: 60
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
api_level: ${{ fromJson(inputs.api_levels) }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: 'recursive'
|
|
|
|
- name: Validate Gradle Wrapper
|
|
uses: gradle/actions/wrapper-validation@v5
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'jetbrains'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.event_name != 'merge_group' && !startsWith(github.ref, 'refs/heads/gh-readonly-queue/') }}
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
cache-cleanup: on-success
|
|
build-scan-publish: true
|
|
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
|
|
build-scan-terms-of-use-agree: 'yes'
|
|
add-job-summary: always
|
|
|
|
- name: Determine matrix metadata
|
|
id: matrix_meta
|
|
shell: bash
|
|
run: |
|
|
first_api=$(python3 - <<'PY'
|
|
import json
|
|
print(json.loads('${{ inputs.api_levels }}')[0])
|
|
PY
|
|
)
|
|
|
|
if [[ "${{ matrix.api_level }}" == "$first_api" ]]; then
|
|
echo "is_first_api=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "is_first_api=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Determine Android tasks
|
|
id: tasks
|
|
shell: bash
|
|
run: |
|
|
tasks=(
|
|
"app:assembleFdroidDebug"
|
|
"app:assembleGoogleDebug"
|
|
"mesh_service_example:assembleDebug"
|
|
)
|
|
|
|
if [[ "${{ inputs.run_instrumented_tests }}" == "true" ]]; then
|
|
tasks+=(
|
|
"app:connectedFdroidDebugAndroidTest"
|
|
"app:connectedGoogleDebugAndroidTest"
|
|
"core:barcode:connectedFdroidDebugAndroidTest"
|
|
"core:barcode:connectedGoogleDebugAndroidTest"
|
|
)
|
|
fi
|
|
|
|
printf 'tasks=%s\n' "${tasks[*]}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Enable KVM group perms
|
|
if: inputs.run_instrumented_tests == true
|
|
run: |
|
|
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
|
sudo udevadm control --reload-rules
|
|
sudo udevadm trigger --name-match=kvm
|
|
|
|
- name: Run Android Build & Instrumented Tests
|
|
if: inputs.run_instrumented_tests == true
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: ${{ matrix.api_level }}
|
|
arch: x86_64
|
|
force-avd-creation: false
|
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
disable-animations: true
|
|
script: ./gradlew ${{ steps.tasks.outputs.tasks }} -Pci=true --parallel --configuration-cache --continue --scan
|
|
|
|
- name: Run Android Build
|
|
if: inputs.run_instrumented_tests == false
|
|
run: ./gradlew ${{ steps.tasks.outputs.tasks }} -Pci=true --parallel --configuration-cache --continue --scan
|
|
|
|
- name: Upload instrumented test results to Codecov
|
|
if: ${{ !cancelled() && inputs.run_instrumented_tests && steps.matrix_meta.outputs.is_first_api == 'true' }}
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
slug: meshtastic/Meshtastic-Android
|
|
flags: android-instrumented
|
|
fail_ci_if_error: false
|
|
report_type: test_results
|
|
files: "**/build/outputs/androidTest-results/**/*.xml"
|
|
|
|
- name: Upload debug artifact
|
|
if: ${{ steps.matrix_meta.outputs.is_first_api == 'true' && inputs.upload_artifacts }}
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: app-debug-apks
|
|
path: app/build/outputs/apk/*/debug/*.apk
|
|
retention-days: 14
|
|
|
|
- name: Report App Size
|
|
if: ${{ always() && steps.matrix_meta.outputs.is_first_api == 'true' }}
|
|
run: |
|
|
echo "### 📦 App Size Report" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Artifact | Size |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
|
|
find app/build/outputs/apk -name "*.apk" -exec du -h {} + | awk '{print "| " $2 " | " $1 " |"}' >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Upload Android reports
|
|
if: ${{ always() && inputs.upload_artifacts }}
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: reports-android-api-${{ matrix.api_level }}
|
|
path: |
|
|
**/build/outputs/androidTest-results
|
|
retention-days: 7
|
|
if-no-files-found: ignore
|