Android - Build and test #15408
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Android - Build and test | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
generate-debug-keystore: | |
name: Generate debug keystore (migrate to secret) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate keystore | |
run: >- | |
keytool -genkey | |
-keystore debug.keystore | |
-storepass android | |
-alias androiddebugkey | |
-keypass android | |
-keyalg RSA | |
-keysize 2048 | |
-validity 10000 | |
-dname "CN=Android Debug,O=Android,C=US" | |
- name: Upload keystore | |
uses: actions/upload-artifact@v4 | |
with: | |
name: debug-keystore | |
path: debug.keystore | |
if-no-files-found: error | |
retention-days: 7 | |
generate-relay-list: | |
name: Generate relay list (migrate to secret) | |
runs-on: se-got-github-runner-006 | |
steps: | |
- name: Get date | |
id: get-date | |
shell: bash | |
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT | |
- name: Cache | |
uses: actions/cache@v4 | |
id: cache-relay-list | |
with: | |
path: android/app/build/extraAssets/relays.json | |
key: relay-list-${{ steps.get-date.outputs.date }} | |
- name: Checkout repository | |
if: steps.cache-relay-list.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
- name: Generate | |
if: steps.cache-relay-list.outputs.cache-hit != 'true' | |
env: | |
CARGO_TARGET_VOLUME_NAME: cargo-target-${{ runner.name }} | |
CARGO_REGISTRY_VOLUME_NAME: cargo-cache-${{ runner.name }} | |
GRADLE_CACHE_VOLUME_NAME: gradle-cache-${{ runner.name }} | |
run: | | |
mkdir -p android/app/build/extraAssets | |
./building/container-run.sh android cargo run --bin relay_list > android/app/build/extraAssets/relays.json | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: relay-list | |
path: android/app/build/extraAssets/relays.json | |
if-no-files-found: error | |
retention-days: 7 | |
build-app: | |
name: Build app | |
runs-on: se-got-github-runner-006 | |
needs: [generate-debug-keystore, generate-relay-list] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Checkout wireguard-go-rs recursively | |
run: | | |
git config --global --add safe.directory '*' | |
git submodule update --init --recursive --depth=1 wireguard-go-rs | |
- uses: actions/download-artifact@v4 | |
with: | |
name: debug-keystore | |
path: .android | |
- uses: actions/download-artifact@v4 | |
with: | |
name: relay-list | |
path: android/app/build/extraAssets | |
# - name: Wait for other jobs (native) | |
# uses: kachick/wait-other-jobs@v3.4.1 | |
# with: | |
# skip-same-workflow: 'false' | |
# early-exit: 'false' | |
# wait-list: | | |
# [ | |
# { | |
# "workflowFile": "android-app.yml", | |
# "jobName": "build-native" | |
# } | |
# ] | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# pattern: native-libs-* | |
# path: android/app/build/extraJni | |
# merge-multiple: true | |
- name: Build native | |
env: | |
CARGO_TARGET_VOLUME_NAME: cargo-target-${{ runner.name }} | |
CARGO_REGISTRY_VOLUME_NAME: cargo-cache-${{ runner.name }} | |
GRADLE_CACHE_VOLUME_NAME: gradle-cache-${{ runner.name }} | |
run: ./building/container-run.sh android ./build-apk.sh --dev-build --skip-apk | |
- name: Build debug app | |
env: | |
CARGO_TARGET_VOLUME_NAME: cargo-target-${{ runner.name }} | |
CARGO_REGISTRY_VOLUME_NAME: cargo-cache-${{ runner.name }} | |
GRADLE_CACHE_VOLUME_NAME: gradle-cache-${{ runner.name }} | |
run: ./building/container-run.sh android android/gradlew -p android assembleOssProdDebug | |
- name: Upload apks | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apks | |
path: android/app/build/outputs/apk | |
if-no-files-found: error | |
retention-days: 7 | |
build-test-apps: | |
name: Build test apps | |
runs-on: se-got-github-runner-006 | |
needs: generate-debug-keystore | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: debug-keystore | |
path: .android | |
- name: Build test apps | |
env: | |
CARGO_TARGET_VOLUME_NAME: cargo-target-${{ runner.name }} | |
CARGO_REGISTRY_VOLUME_NAME: cargo-cache-${{ runner.name }} | |
GRADLE_CACHE_VOLUME_NAME: gradle-cache-${{ runner.name }} | |
run: ./building/container-run.sh android android/gradlew -p android assembleOssProdAndroidTest | |
run-lint-and-tests: | |
name: Run lint and test tasks | |
needs: generate-debug-keystore | |
runs-on: se-got-github-runner-006 | |
strategy: | |
fail-fast: false | |
max-parallel: 1 | |
matrix: | |
include: | |
- gradle-task: testDebugUnitTest -x :test:arch:testDebugUnitTest :app:testOssProdDebugUnitTest :service:testOssProdDebugUnitTest :lib:billing:testDebugUnitTest :lib:daemon-grpc:testDebugUnitTest :lib:shared:testDebugUnitTest | |
- gradle-task: :test:arch:test --rerun-tasks | |
- gradle-task: detekt | |
- gradle-task: lint | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: debug-keystore | |
path: .android | |
- name: Run gradle test task | |
env: | |
CARGO_TARGET_VOLUME_NAME: cargo-target-${{ runner.name }} | |
CARGO_REGISTRY_VOLUME_NAME: cargo-cache-${{ runner.name }} | |
GRADLE_CACHE_VOLUME_NAME: gradle-cache-${{ runner.name }} | |
run: ./building/container-run.sh android android/gradlew -p android ${{ matrix.gradle-task }} |