Merge pull request #363 from opendocument-app/conanInstallParallel #5027
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: OpenDocument-Reader-Android | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/android_main.yml' | |
branches: | |
- main | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/android_main.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
ndk_version: 26.3.11579264 | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: install ninja | |
run: sudo apt-get install -y ninja-build | |
- name: setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: setup python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: install python dependencies | |
run: pip install conan | |
- name: install ndk | |
run: echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ndk_version }}" | |
- name: conan remote | |
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan | |
- name: conan profile | |
run: conan profile detect | |
- name: gradle | |
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace | |
- name: conan login | |
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }} | |
- name: upload binaries to conan repo | |
run: conan upload "*" --check --confirm --remote odr | |
- name: upload apks | |
uses: actions/upload-artifact@v4 | |
with: | |
name: APKs | |
path: app/build/outputs/apk/**/*.apk | |
if-no-files-found: error | |
- name: upload lint results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: lint-report | |
path: app/build/reports/lint-results-*.html | |
if-no-files-found: error | |
test: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { arch: x86_64, api-level: 23 } | |
- { arch: x86_64, api-level: 29 } | |
- { arch: x86_64, api-level: 30 } | |
- { arch: x86_64, api-level: 32 } | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: install ninja | |
run: sudo apt-get install -y ninja-build | |
- name: java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
bundler-cache: true | |
- name: install fastlane | |
run: bundle install | |
- name: setup python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: install python dependencies | |
run: pip install conan | |
- name: install ndk | |
run: echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ndk_version }}" | |
- name: conan remote | |
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan | |
- name: conan profile | |
run: conan profile detect | |
- name: Android Virtual Device (AVD) cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}-r4 | |
- 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: 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: ${{ matrix.arch }} | |
target: google_apis | |
script: echo "Generated AVD snapshot for caching." | |
- name: Run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ matrix.arch }} | |
target: google_apis | |
script: | | |
mkdir -p testResults/screenshots | |
adb logcat > testResults/logcat.txt & | |
adb shell screencap /data/local/tmp/beforeTests.png | |
adb pull /data/local/tmp/beforeTests.png testResults/screenshots/ | |
bundle exec fastlane tests || touch sorry_but_tests_are_failing | |
adb pull /sdcard/Pictures/screenshots testResults/ || true | |
adb shell screencap /data/local/tmp/afterTests.png | |
adb pull /data/local/tmp/afterTests.png testResults/screenshots/ | |
mv app/build/reports/androidTests/connected testResults/ | |
mv app/build/outputs/androidTest-results testResults/ | |
test ! -f sorry_but_tests_are_failing | |
- name: conan login | |
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }} | |
- name: upload binaries to conan repo | |
run: conan upload "*" --check --confirm --remote odr | |
- name: upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: testResults-${{ matrix.api-level }}-${{ matrix.arch }} | |
path: testResults | |
if-no-files-found: error |