Add execute #30
This file contains hidden or 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 Main CI | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| - 'release/*' | |
| - 'hotfix/*' | |
| - 'test/*' | |
| concurrency: | |
| group: build-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check_spotless: | |
| name: Check spotless | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: 17 | |
| - name: Set up NDK | |
| uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 | |
| with: | |
| ndk-version: r28c | |
| link-to-sdk: true | |
| local-cache: true | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Check formatting using spotless | |
| run: ./gradlew spotlessCheck | |
| build: | |
| name: Build debug, Jacoco test and publish to codacy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: 17 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| file_operations/target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Setup Rust for Android | |
| run: | | |
| cd file_operations | |
| chmod +x setup_rust_android.sh | |
| ./setup_rust_android.sh | |
| - name: Verify Rust setup | |
| run: | | |
| cd file_operations | |
| echo "π Verifying Rust Android targets..." | |
| rustup target list --installed | grep android || echo "No Android targets found" | |
| echo "π Verifying cargo configuration..." | |
| if [ -f .cargo/config.toml ]; then | |
| echo "β .cargo/config.toml exists" | |
| else | |
| echo "β .cargo/config.toml missing" | |
| exit 1 | |
| fi | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Build with Gradle | |
| run: ./gradlew assembledebug | |
| - name: Run test cases | |
| run: ./gradlew jacocoTestPlayDebugUnitTestReport | |
| - name: Publish test cases | |
| run: | | |
| export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_TOKEN }} | |
| bash <(curl -Ls https://coverage.codacy.com/get.sh) | |
| - name: Publish on Telegram | |
| run: | | |
| COMMIT_COUNT=$(git rev-list --count ${GITHUB_REF}) | |
| VERSION_NAME=$(echo ${GITHUB_REF##*/} | sed 's/release\///' | sed 's/hotfix\///') | |
| cp app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk app/build/outputs/apk/fdroid/debug/amaze-fdroid-$(echo $VERSION_NAME)-$(echo $COMMIT_COUNT).apk | |
| cp app/build/outputs/apk/play/debug/app-play-debug.apk app/build/outputs/apk/play/debug/amaze-play-$(echo $VERSION_NAME)-$(echo $COMMIT_COUNT).apk | |
| echo $(curl -v -F "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" -F document=@app/build/outputs/apk/fdroid/debug/amaze-fdroid-$(echo $VERSION_NAME)-$(echo $COMMIT_COUNT).apk https://api.telegram.org/${{ secrets.AMAZE_BOT_ID }}:${{ secrets.TELEGRAM_INTEGRATION_KEY }}/sendDocument) | |
| echo $(curl -v -F "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" -F document=@app/build/outputs/apk/play/debug/amaze-play-$(echo $VERSION_NAME)-$(echo $COMMIT_COUNT).apk https://api.telegram.org/${{ secrets.AMAZE_BOT_ID }}:${{ secrets.TELEGRAM_INTEGRATION_KEY }}/sendDocument) | |
| test_emulator: | |
| timeout-minutes: 30 # Emulator can get stuck | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| api-level: [ 21, 28 ] | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| - name: Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: 17 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| file_operations/target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Setup Rust for Android | |
| run: | | |
| cd file_operations | |
| chmod +x setup_rust_android.sh | |
| ./setup_rust_android.sh | |
| - name: Verify Rust setup | |
| run: | | |
| cd file_operations | |
| echo "π Verifying Rust Android targets..." | |
| rustup target list --installed | grep android || echo "No Android targets found" | |
| echo "π Verifying cargo configuration..." | |
| if [ -f .cargo/config.toml ]; then | |
| echo "β .cargo/config.toml exists" | |
| else | |
| echo "β .cargo/config.toml missing" | |
| exit 1 | |
| fi | |
| - name: Enable KVM | |
| 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: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| ~/.android/debug.keystore | |
| 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 }} | |
| force-avd-creation: false | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: false | |
| sdcard-path-or-size: 100M | |
| arch: x86_64 | |
| ram-size: 2048M | |
| channel: canary | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: run tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| force-avd-creation: false | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: true | |
| sdcard-path-or-size: 100M | |
| arch: x86_64 | |
| ram-size: 2048M | |
| channel: canary | |
| script: | | |
| adb logcat -c | |
| adb logcat *:E & | |
| ./gradlew :app:connectedCheck | |