mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(wire): migrate from protobuf -> wire (#4401)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
9dbc8b7fbf
commit
25657e8f8f
239 changed files with 7149 additions and 6144 deletions
42
.github/workflows/merge-queue.yml
vendored
42
.github/workflows/merge-queue.yml
vendored
|
|
@ -9,46 +9,26 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
android-check:
|
||||
if: github.repository == 'meshtastic/Meshtastic-Android'
|
||||
uses: ./.github/workflows/reusable-lint.yml
|
||||
secrets: inherit
|
||||
|
||||
build:
|
||||
needs: lint
|
||||
if: github.repository == 'meshtastic/Meshtastic-Android'
|
||||
uses: ./.github/workflows/reusable-android-build.yml
|
||||
uses: ./.github/workflows/reusable-check.yml
|
||||
with:
|
||||
upload_artifacts: false
|
||||
secrets: inherit
|
||||
|
||||
androidTest:
|
||||
needs: lint
|
||||
if: github.repository == 'meshtastic/Meshtastic-Android'
|
||||
uses: ./.github/workflows/reusable-android-test.yml
|
||||
with:
|
||||
api_levels: '[26, 35]' # Run on both API 26 and 35 for merge queue
|
||||
test_flavors: 'both' # Run both flavors for merge queue (comprehensive)
|
||||
api_levels: '[26, 35]' # Comprehensive testing for Merge Queue
|
||||
flavors: '["google", "fdroid"]'
|
||||
upload_artifacts: false
|
||||
secrets: inherit
|
||||
|
||||
check-workflow-status:
|
||||
name: Check Workflow Status # Matches another in pull-request, and is required for merge to main.
|
||||
name: Check Workflow Status
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- lint
|
||||
- build
|
||||
- androidTest
|
||||
- android-check
|
||||
if: always()
|
||||
steps:
|
||||
- name: Check Workflow Status
|
||||
run: |
|
||||
exit_on_result() {
|
||||
if [[ "$2" == "failure" || "$2" == "cancelled" ]]; then
|
||||
echo "Job '$1' failed or was cancelled."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
exit_on_result "lint" "${{ needs.lint.result }}"
|
||||
exit_on_result "build" "${{ needs.build.result }}"
|
||||
exit_on_result "androidTest" "${{ needs.androidTest.result }}"
|
||||
if [[ "${{ needs.android-check.result }}" == "failure" || "${{ needs.android-check.result }}" == "cancelled" ]]; then
|
||||
echo "::error::Android Check failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "All jobs passed successfully"
|
||||
|
|
|
|||
53
.github/workflows/pull-request.yml
vendored
53
.github/workflows/pull-request.yml
vendored
|
|
@ -32,35 +32,15 @@ jobs:
|
|||
- '**/src/**'
|
||||
- '.github/workflows/**'
|
||||
|
||||
lint:
|
||||
android-check:
|
||||
needs: check-changes
|
||||
if: needs.check-changes.outputs.code_changed == 'true'
|
||||
uses: ./.github/workflows/reusable-lint.yml
|
||||
secrets: inherit
|
||||
|
||||
build:
|
||||
needs:
|
||||
- check-changes
|
||||
- lint
|
||||
if: ${{ needs.check-changes.outputs.code_changed == 'true' && !cancelled() && !failure() }}
|
||||
uses: ./.github/workflows/reusable-android-build.yml
|
||||
uses: ./.github/workflows/reusable-check.yml
|
||||
with:
|
||||
test_flavors: 'google'
|
||||
api_levels: '[35]' # Only test latest API on PRs for speed
|
||||
flavors: '["google"]'
|
||||
secrets: inherit
|
||||
|
||||
androidTest:
|
||||
needs:
|
||||
- check-changes
|
||||
- lint
|
||||
if: ${{ needs.check-changes.outputs.code_changed == 'true' && !cancelled() && !failure() }}
|
||||
uses: ./.github/workflows/reusable-android-test.yml
|
||||
with:
|
||||
api_levels: '[35]' # Run only on API 35 for PRs
|
||||
test_flavors: 'google' # Run only Google flavor for PRs (faster)
|
||||
num_shards: 1 # Run tests in parallel across 1 emulator
|
||||
secrets: inherit
|
||||
|
||||
# This job handles the case when no code changes are detected (docs-only PRs)
|
||||
skip-notice:
|
||||
needs: check-changes
|
||||
if: needs.check-changes.outputs.code_changed != 'true'
|
||||
|
|
@ -74,34 +54,19 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- check-changes
|
||||
- lint
|
||||
- build
|
||||
- androidTest
|
||||
- android-check
|
||||
if: always()
|
||||
steps:
|
||||
- name: Check Workflow Status
|
||||
run: |
|
||||
# If no code changed, all jobs are expected to be skipped - that's success
|
||||
if [[ "${{ needs.check-changes.outputs.code_changed }}" != "true" ]]; then
|
||||
echo "No code changes - CI jobs skipped as expected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Code changed - check that all jobs succeeded
|
||||
check_result() {
|
||||
local job_name=$1
|
||||
local result=$2
|
||||
if [[ "$result" == "failure" ]]; then
|
||||
echo "::error::Job '$job_name' failed"
|
||||
exit 1
|
||||
elif [[ "$result" == "cancelled" ]]; then
|
||||
echo "::error::Job '$job_name' was cancelled"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_result "lint" "${{ needs.lint.result }}"
|
||||
check_result "build" "${{ needs.build.result }}"
|
||||
check_result "androidTest" "${{ needs.androidTest.result }}"
|
||||
if [[ "${{ needs.android-check.result }}" == "failure" || "${{ needs.android-check.result }}" == "cancelled" ]]; then
|
||||
echo "::error::Android Check failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All jobs passed successfully"
|
||||
|
|
|
|||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
|
@ -57,9 +57,13 @@ permissions:
|
|||
|
||||
jobs:
|
||||
run-lint:
|
||||
uses: ./.github/workflows/reusable-lint.yml
|
||||
uses: ./.github/workflows/reusable-check.yml
|
||||
with:
|
||||
ref: ${{ inputs.commit_sha || inputs.tag_name }}
|
||||
run_lint: true
|
||||
run_unit_tests: false
|
||||
run_instrumented_tests: false
|
||||
flavors: '["google"]'
|
||||
upload_artifacts: false
|
||||
secrets: inherit
|
||||
|
||||
prepare-build-info:
|
||||
|
|
|
|||
144
.github/workflows/reusable-android-build.yml
vendored
144
.github/workflows/reusable-android-build.yml
vendored
|
|
@ -1,144 +0,0 @@
|
|||
name: Reusable Android Build and Test
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
GRADLE_ENCRYPTION_KEY:
|
||||
required: false
|
||||
DATADOG_APPLICATION_ID:
|
||||
required: false
|
||||
DATADOG_CLIENT_TOKEN:
|
||||
required: false
|
||||
CODECOV_TOKEN:
|
||||
required: false
|
||||
GRADLE_CACHE_URL:
|
||||
required: false
|
||||
GRADLE_CACHE_USERNAME:
|
||||
required: false
|
||||
GRADLE_CACHE_PASSWORD:
|
||||
required: false
|
||||
inputs:
|
||||
upload_artifacts:
|
||||
description: 'Whether to upload build and Detekt artifacts'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
test_flavors:
|
||||
description: 'Which flavors to build and test: "google", "fdroid", or "both"'
|
||||
required: false
|
||||
type: string
|
||||
default: 'both'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
attestations: write
|
||||
timeout-minutes: 35
|
||||
env:
|
||||
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
|
||||
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
|
||||
MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
|
||||
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
|
||||
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
|
||||
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'jetbrains'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
with:
|
||||
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
||||
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: Calculate Version Code
|
||||
id: calculate_version_code
|
||||
uses: ./.github/actions/calculate-version-code
|
||||
|
||||
- name: Expose Version Code as Environment Variable
|
||||
run: echo "VERSION_CODE=${{ steps.calculate_version_code.outputs.versionCode }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Load secrets
|
||||
if: env.DATADOG_APPLICATION_ID != '' && env.DATADOG_CLIENT_TOKEN != ''
|
||||
run: |
|
||||
echo "datadogApplicationId=$DATADOG_APPLICATION_ID" >> ./secrets.properties
|
||||
echo "datadogClientToken=$DATADOG_CLIENT_TOKEN" >> ./secrets.properties
|
||||
|
||||
- name: Determine build tasks
|
||||
id: build-tasks
|
||||
run: |
|
||||
FLAVOR="${{ inputs.test_flavors }}"
|
||||
if [ "$FLAVOR" = "google" ]; then
|
||||
echo "tasks=assembleGoogleDebug testGoogleDebugUnitTest" >> $GITHUB_OUTPUT
|
||||
elif [ "$FLAVOR" = "fdroid" ]; then
|
||||
echo "tasks=assembleFdroidDebug testFdroidDebugUnitTest" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "tasks=assembleDebug testGoogleDebugUnitTest testFdroidDebugUnitTest" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build and Run Unit Tests
|
||||
run: ./gradlew ${{ steps.build-tasks.outputs.tasks }} koverXmlReport -Pci=true --continue --scan
|
||||
env:
|
||||
VERSION_CODE: ${{ env.VERSION_CODE }}
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
slug: meshtastic/Meshtastic-Android
|
||||
report_type: coverage
|
||||
directory: .
|
||||
files: "**/build/reports/kover/report.xml"
|
||||
|
||||
- name: Upload test results to Codecov
|
||||
if: ${{ !cancelled() }}
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
report_type: test_results
|
||||
directory: .
|
||||
files: "**/build/test-results/**/*.xml,**/build/outputs/androidTest-results/**/*.xml"
|
||||
|
||||
- name: Upload F-Droid debug artifact
|
||||
if: ${{ inputs.upload_artifacts && (inputs.test_flavors == 'fdroid' || inputs.test_flavors == 'both') }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: fdroidDebug
|
||||
path: app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk
|
||||
retention-days: 14
|
||||
- name: Upload Google debug artifact
|
||||
if: ${{ inputs.upload_artifacts && (inputs.test_flavors == 'google' || inputs.test_flavors == 'both') }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: googleDebug
|
||||
path: app/build/outputs/apk/google/debug/app-google-debug.apk
|
||||
retention-days: 14
|
||||
|
||||
- name: Upload reports
|
||||
if: ${{ inputs.upload_artifacts }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: upload-reports
|
||||
path: |
|
||||
build/reports
|
||||
**/build/reports
|
||||
retention-days: 14
|
||||
169
.github/workflows/reusable-android-test.yml
vendored
169
.github/workflows/reusable-android-test.yml
vendored
|
|
@ -1,169 +0,0 @@
|
|||
name: Reusable Android Instrumented Tests
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
upload_artifacts:
|
||||
description: 'Whether to upload Android test reports'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
api_levels:
|
||||
description: 'JSON array string of API levels to run tests on (e.g., `[35]` or `[26, 34, 35]`)'
|
||||
required: false
|
||||
type: string
|
||||
default: '[26, 35]'
|
||||
test_flavors:
|
||||
description: 'Which flavors to test: "google", "fdroid", or "both"'
|
||||
required: false
|
||||
type: string
|
||||
default: 'both'
|
||||
num_shards:
|
||||
description: 'Number of shards to split tests into'
|
||||
required: false
|
||||
type: number
|
||||
default: 1
|
||||
secrets:
|
||||
GRADLE_ENCRYPTION_KEY:
|
||||
required: false
|
||||
CODECOV_TOKEN:
|
||||
required: true
|
||||
GRADLE_CACHE_URL:
|
||||
required: false
|
||||
GRADLE_CACHE_USERNAME:
|
||||
required: false
|
||||
GRADLE_CACHE_PASSWORD:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
setup-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- id: set-matrix
|
||||
run: |
|
||||
API_LEVELS='${{ inputs.api_levels }}'
|
||||
FLAVORS='${{ inputs.test_flavors }}'
|
||||
NUM_SHARDS=${{ inputs.num_shards }}
|
||||
|
||||
if [ "$FLAVORS" = "both" ]; then
|
||||
FLAVORS_JSON='["google", "fdroid"]'
|
||||
else
|
||||
FLAVORS_JSON="[\"$FLAVORS\"]"
|
||||
fi
|
||||
|
||||
SHARDS_JSON=$(seq 0 $((NUM_SHARDS - 1)) | jq -R . | jq -s -c .)
|
||||
|
||||
echo "matrix={\"api_level\":$API_LEVELS,\"flavor\":$FLAVORS_JSON,\"shard\":$SHARDS_JSON}" >> $GITHUB_OUTPUT
|
||||
|
||||
androidTest:
|
||||
needs: setup-matrix
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
|
||||
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
|
||||
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'jetbrains'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Enable KVM group perms
|
||||
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: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
with:
|
||||
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
||||
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: AVD cache
|
||||
uses: actions/cache@v5
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api_level }}
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: ${{ matrix.api_level }}
|
||||
arch: x86_64
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: false
|
||||
script: echo "Generated AVD snapshot for caching."
|
||||
|
||||
- name: Determine test tasks
|
||||
id: test-tasks
|
||||
run: |
|
||||
if [ "${{ matrix.flavor }}" = "google" ]; then
|
||||
echo "tasks=connectedGoogleDebugAndroidTest" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "tasks=connectedFdroidDebugAndroidTest" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Run Sharded Android Instrumented Tests
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
env:
|
||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 60
|
||||
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.test-tasks.outputs.tasks }} koverXmlReport -Pci=true -Pandroid.testInstrumentationRunnerArguments.numShards=${{ inputs.num_shards }} -Pandroid.testInstrumentationRunnerArguments.shardIndex=${{ matrix.shard }} --continue --scan && ( killall -INT crashpad_handler || true )
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
if: ${{ !cancelled() }}
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
report_type: coverage
|
||||
slug: meshtastic/Meshtastic-Android
|
||||
files: "**/build/reports/kover/report.xml"
|
||||
|
||||
- name: Upload test results to Codecov
|
||||
if: ${{ !cancelled() }}
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
report_type: test_results
|
||||
directory: .
|
||||
files: "**/build/test-results/**/*.xml,**/build/outputs/androidTest-results/**/*.xml"
|
||||
|
||||
- name: Upload Test Results
|
||||
if: ${{ always() && inputs.upload_artifacts }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: android-test-reports-api-${{ matrix.api_level }}-${{ matrix.flavor }}-shard-${{ matrix.shard }}
|
||||
path: |
|
||||
**/build/outputs/androidTest-results/connected/**
|
||||
**/build/reports/androidTests/connected/**
|
||||
retention-days: 14
|
||||
196
.github/workflows/reusable-check.yml
vendored
Normal file
196
.github/workflows/reusable-check.yml
vendored
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
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
|
||||
flavors:
|
||||
type: string
|
||||
default: '["google"]'
|
||||
api_levels:
|
||||
type: string
|
||||
default: '[35]'
|
||||
num_shards:
|
||||
type: number
|
||||
default: 1
|
||||
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
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
api_level: ${{ fromJson(inputs.api_levels) }}
|
||||
flavor: ${{ fromJson(inputs.flavors) }}
|
||||
env:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
|
||||
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
|
||||
MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
|
||||
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
|
||||
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
|
||||
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: 'recursive'
|
||||
|
||||
- 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-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
||||
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: Calculate Version Code
|
||||
id: calculate_version_code
|
||||
uses: ./.github/actions/calculate-version-code
|
||||
|
||||
- name: Determine Tasks
|
||||
id: tasks
|
||||
run: |
|
||||
TASKS=""
|
||||
# Only run Lint and Unit Tests on the first API level and first flavor in the matrix to save time and resources
|
||||
IS_FIRST_API=$(echo '${{ inputs.api_levels }}' | jq -r '.[0] == ${{ matrix.api_level }}')
|
||||
IS_FIRST_FLAVOR=$(echo '${{ inputs.flavors }}' | jq -r '.[0] == "${{ matrix.flavor }}"')
|
||||
|
||||
if [ "${{ inputs.run_lint }}" = "true" ] && [ "$IS_FIRST_API" = "true" ] && [ "$IS_FIRST_FLAVOR" = "true" ]; then
|
||||
TASKS="$TASKS spotlessCheck detekt "
|
||||
fi
|
||||
|
||||
FLAVOR="${{ matrix.flavor }}"
|
||||
if [ "$IS_FIRST_API" = "true" ]; then
|
||||
if [ "$FLAVOR" = "google" ]; then
|
||||
TASKS="$TASKS assembleGoogleDebug "
|
||||
[ "${{ inputs.run_unit_tests }}" = "true" ] && TASKS="$TASKS testGoogleDebugUnitTest "
|
||||
elif [ "$FLAVOR" = "fdroid" ]; then
|
||||
TASKS="$TASKS assembleFdroidDebug "
|
||||
[ "${{ inputs.run_unit_tests }}" = "true" ] && TASKS="$TASKS testFdroidDebugUnitTest "
|
||||
fi
|
||||
fi
|
||||
|
||||
# Instrumented Test Tasks
|
||||
if [ "${{ inputs.run_instrumented_tests }}" = "true" ]; then
|
||||
if [ "$FLAVOR" = "google" ]; then
|
||||
TASKS="$TASKS connectedGoogleDebugAndroidTest "
|
||||
elif [ "$FLAVOR" = "fdroid" ]; then
|
||||
TASKS="$TASKS connectedFdroidDebugAndroidTest "
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run coverage report if any tests were executed
|
||||
if [[ $TASKS == *"test"* ]]; then
|
||||
TASKS="$TASKS koverXmlReport"
|
||||
fi
|
||||
|
||||
echo "tasks=$TASKS" >> $GITHUB_OUTPUT
|
||||
echo "is_first_api=$IS_FIRST_API" >> $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 Check (with Emulator)
|
||||
if: inputs.run_instrumented_tests == true
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
env:
|
||||
VERSION_CODE: ${{ steps.calculate_version_code.outputs.versionCode }}
|
||||
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 -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true --continue --scan
|
||||
|
||||
- name: Run Check (no Emulator)
|
||||
if: inputs.run_instrumented_tests == false
|
||||
env:
|
||||
VERSION_CODE: ${{ steps.calculate_version_code.outputs.versionCode }}
|
||||
run: ./gradlew ${{ steps.tasks.outputs.tasks }} -Pci=true -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true --continue --scan
|
||||
|
||||
- name: Upload coverage results to Codecov
|
||||
if: ${{ !cancelled() }}
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
slug: meshtastic/Meshtastic-Android
|
||||
files: "**/build/reports/kover/report.xml"
|
||||
|
||||
- name: Upload test results to Codecov
|
||||
if: ${{ !cancelled() }}
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
report_type: test_results
|
||||
files: "**/build/test-results/**/*.xml,**/build/outputs/androidTest-results/**/*.xml"
|
||||
|
||||
- name: Upload debug artifact
|
||||
if: ${{ steps.tasks.outputs.is_first_api == 'true' && inputs.upload_artifacts }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ matrix.flavor }}Debug
|
||||
path: app/build/outputs/apk/${{ matrix.flavor }}/debug/app-${{ matrix.flavor }}-debug.apk
|
||||
retention-days: 14
|
||||
|
||||
- name: Report App Size
|
||||
if: always() && steps.tasks.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 reports
|
||||
if: ${{ always() && inputs.upload_artifacts }}
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: reports-${{ matrix.flavor }}-api-${{ matrix.api_level }}
|
||||
path: |
|
||||
**/build/reports
|
||||
**/build/test-results
|
||||
**/build/outputs/androidTest-results
|
||||
retention-days: 7
|
||||
54
.github/workflows/reusable-lint.yml
vendored
54
.github/workflows/reusable-lint.yml
vendored
|
|
@ -1,54 +0,0 @@
|
|||
name: Reusable Lint and Format Check
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: 'The branch, tag or SHA to checkout'
|
||||
required: false
|
||||
type: string
|
||||
secrets:
|
||||
GRADLE_ENCRYPTION_KEY:
|
||||
required: false
|
||||
GRADLE_CACHE_URL:
|
||||
required: false
|
||||
GRADLE_CACHE_USERNAME:
|
||||
required: false
|
||||
GRADLE_CACHE_PASSWORD:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest # Lint is fast, doesn't need large runner
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
|
||||
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
|
||||
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.ref || '' }}
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'jetbrains'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
with:
|
||||
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
||||
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: Run Spotless and Detekt
|
||||
run: ./gradlew spotlessCheck detekt -Pci=true --scan
|
||||
Loading…
Add table
Add a link
Reference in a new issue