Skip to content

Add UnifiedPush support with PushProvider abstraction #9

Add UnifiedPush support with PushProvider abstraction

Add UnifiedPush support with PushProvider abstraction #9

Workflow file for this run

name: Pull Request
on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
# This workflow should cancel previous builds since it means that a new commit has been made to the PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Register yamllint problem matcher
run: |
echo "::add-matcher::.github/workflows/matchers/yamllint.json"
- name: Validate YAML
run: yamllint --strict --format github .
lockfiles:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Update lockfiles
run: ./gradlew alldependencies --write-locks
- name: Check for missing lockfiles update
run: |
if [[ $(git status --porcelain) ]]; then
echo $(git status --porcelain)
echo -e "\n❌ Uncommitted changes detected in the repository."
echo -e "🔍 It seems that the dependency lockfiles are outdated. Please update them by running:"
echo -e " ./gradlew alldependencies --write-locks"
echo -e " Then commit the updated lockfiles to your branch."
error_message="Dependency changes detected, but lockfiles are not updated. Run \`./gradlew alldependencies --write-locks\` and commit the changes."
echo "::error file=gradle/libs.versions.toml,line=1,title=⛔ Lockfile Update Required::${error_message}"
exit 1;
else
echo -e "\n✔️ All dependency lockfiles are up to date. No uncommitted changes detected."
fi
ktlint:
needs: [yamllint]
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
# Since `build-logic` is added with `includeBuild` we have to call ktlint explicitly on `:convention`.
- name: Validate ktlint
run: ./gradlew ktlintCheck :build-logic:convention:ktlintCheck --continue
- uses: ./.github/actions/upload-sarif-results
if: always()
with:
category: "KTlint"
lint:
needs: [lockfiles, ktlint]
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Validate Lint
run: ./gradlew lint --continue
- name: Upload lint reports (HTML)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: lint-reports
path: "**/build/reports/lint-results-*.html"
- uses: ./.github/actions/upload-sarif-results
if: always()
with:
category: "Android Lint"
screenshot_test:
name: "Screenshot Tests"
needs: [lint, lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Validate Screenshot Previews
run: ./gradlew validateDebugScreenshotTest validateFullDebugScreenshotTest
- uses: ./.github/actions/upload-test-results
if: always()
with:
test-name: Screenshot test
pr_build:
needs: [lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Check for modified DB schemas on branch
run: |
if git diff --name-only --diff-filter=DMR origin/main... | grep "^common/schemas"; then
echo -e "\n❌ Existing database schema modified, please increase the database version instead"
exit 1
else
echo -e "\n✔️ No changed database schemas on branch"
fi
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Check version file creation
run: ./gradlew versionFile
- name: Build Debug APK
run: |
./gradlew :common:assemble :app:assembleDebug :wear:assembleDebug :automotive:assembleDebug -PnoStrictMode
- name: Check for missing/modified DB schemas after build
run: |
if [[ $(git status common/schemas --porcelain) ]]; then
echo $(git status common/schemas --porcelain)
echo -e "\n❌ Found uncommitted changes in database schema directory, please make sure to include all changes in your commit(s)"
exit 1;
else
echo -e "\n✔️ No changes in database schema directory after build"
fi
- name: Archive Debug Build
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: APKs
path: ./**/*.apk
pr_build_release:
needs: [lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Generate dummy keystore
run: |
keytool -genkeypair -v \
-alias androiddebugkey \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-keystore /home/runner/work/android/android/ci_dummy_keystore.keystore \
-dname "CN=Android CI dummy, O=Android, C=FR" \
-storepass android \
-keypass android
- name: Build Release
env:
KEYSTORE_PATH: /home/runner/work/android/android/ci_dummy_keystore.keystore
KEYSTORE_ALIAS: androiddebugkey
KEYSTORE_ALIAS_PASSWORD: android
KEYSTORE_PASSWORD: android
# Disable lint tasks since we have a dedicated job for this in the workflow
run: |
./gradlew :common:assemble :app:assembleRelease :wear:assembleRelease :automotive:assembleRelease
unit_tests:
name: "Unit Tests"
needs: [lint, lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- name: Run test
# Run testFullDebugUnitTest at the app level since :automotive shares the same sourceSet than app. Minimal and Full are the same in unit tests for now
run: ./gradlew testDebugUnitTest :app:testFullDebugUnitTest :lint:test
- uses: ./.github/actions/upload-test-results
if: always()
with:
test-name: Unit test
instrumentation_test:
name: "Instrumentation Tests"
needs: [lint, lockfiles, ktlint]
runs-on: ubuntu-latest
strategy:
# We want the result of each device to be reported, so we can't fail-fast
fail-fast: false
matrix:
configuration:
- api-level: 23
arch: x86_64
profile: "Nexus 5"
target: "google_apis"
gradle_target: ":app:connectedFullDebugAndroidTest :app:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest :microfrontend:connectedDebugAndroidTest"
- api-level: 36
arch: x86_64
profile: "pixel_7"
target: "google_apis"
gradle_target: ":app:connectedFullDebugAndroidTest :app:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest :microfrontend:connectedDebugAndroidTest"
- api-level: 33
arch: x86_64
profile: "automotive_1024p_landscape"
target: "android-automotive"
gradle_target: ":automotive:connectedFullDebugAndroidTest :automotive:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest :microfrontend:connectedDebugAndroidTest"
- api-level: "34"
system-image-api-level: "34-ext9"
arch: x86_64
profile: "automotive_1024p_landscape"
target: "android-automotive"
gradle_target: ":automotive:connectedFullDebugAndroidTest :automotive:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest :microfrontend:connectedDebugAndroidTest"
- api-level: 26
arch: x86
profile: "wearos_square"
target: "android-wear"
gradle_target: ":wear:connectedDebugAndroidTest :common:connectedDebugAndroidTest"
- api-level: 34
arch: x86_64
profile: "wearos_small_round"
target: "android-wear"
gradle_target: ":wear:connectedDebugAndroidTest :common:connectedDebugAndroidTest :microfrontend:connectedDebugAndroidTest"
steps:
- name: Delete unnecessary tools 🔧
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: false # Don't remove Android tools
tool-cache: true # Remove image tool cache - rm -rf "$AGENT_TOOLSDIRECTORY"
docker-images: false # Takes 16s, enable if needed in the future
large-packages: false # includes google-cloud-sdk and it's slow
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"
- 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
ls /dev/kvm
- name: Build projects and run instrumentation tests
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: ${{ matrix.configuration.api-level }}
arch: ${{ matrix.configuration.arch }}
force-avd-creation: false
disable-animations: true
disk-size: 2G # We need to ensure that there is enough space for the emulator to run. If not we get 'Failed to commit install' errors.
heap-size: 1G
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
profile: ${{ matrix.configuration.profile }}
target: ${{ matrix.configuration.target }}
system-image-api-level: ${{ matrix.configuration.system-image-api-level }}
script: ./gradlew ${{ matrix.configuration.gradle_target }}
- uses: ./.github/actions/upload-test-results
if: always()
with:
test-name: Instrumentation test (API${{ matrix.configuration.api-level }}) ${{ matrix.configuration.target }}
publish_test_results:
name: "Publish Tests Results"
needs: [instrumentation_test, unit_tests, screenshot_test]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: Publish Test Results EnricoMi
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
if: always()
with:
comment_mode: "failures"
# We want to fail the build to block the merge if any test fail it allows us simplify the setup of the protected branch.
action_fail: true
files: |
**/androidTest-results/**/TEST-*.xml
**/build/test-results/**/TEST-*.xml