Reconnect optimizations (#894) #1546
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 CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'LICENSE' | |
| - 'NOTICE' | |
| - '.gitignore' | |
| pull_request: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'LICENSE' | |
| - 'NOTICE' | |
| - '.gitignore' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./client-sdk-android | |
| steps: | |
| - name: checkout client-sdk-android | |
| uses: actions/checkout@v4.0.0 | |
| with: | |
| path: ./client-sdk-android | |
| submodules: recursive | |
| - name: set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Gradle clean | |
| run: ./gradlew clean | |
| - name: Spotless check | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| git fetch origin main --depth 1 | |
| ./gradlew spotlessCheck | |
| - name: Build and test with Gradle | |
| run: ./gradlew assembleRelease livekit-android-test:testRelease | |
| - name: Upload AAR | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: livekit-android-sdk-release.aar | |
| path: client-sdk-android/livekit-android-sdk/build/outputs/aar/livekit-android-sdk-release.aar | |
| # TODO: Figure out appropriate place to run this. Takes ~3 mins, so pretty slow. | |
| # # generates coverage-report.md and publishes as checkrun | |
| # - name: JaCoCo Code Coverage Report | |
| # id: jacoco_reporter | |
| # uses: PavanMudigonda/jacoco-reporter@v4.8 | |
| # with: | |
| # coverage_results_path: "client-sdk-android/livekit-android-sdk/build/jacoco/jacoco.xml" | |
| # coverage_report_name: Coverage | |
| # coverage_report_title: JaCoCo | |
| # github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # skip_check_run: false | |
| # minimum_coverage: 60 | |
| # fail_below_threshold: false | |
| # publish_only_summary: false | |
| # | |
| # # Publish Coverage Job Summary | |
| # - name: Add Coverage Job Summary | |
| # run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY | |
| # | |
| # # uploads the coverage-report.md artifact | |
| # - name: Upload Code Coverage Artifacts | |
| # uses: actions/upload-artifact@v2 | |
| # with: | |
| # name: code-coverage-report-markdown | |
| # path: "*/coverage-results.md" | |
| # retention-days: 7 | |
| - name: Import video test keys into gradle properties | |
| if: github.event_name == 'push' | |
| run: | | |
| sed -i -e "s,livekitUrl=,livekitUrl=$LIVEKIT_URL,g" gradle.properties | |
| sed -i -e "s,livekitApiKey=,livekitApiKey=$LIVEKIT_API_KEY,g" gradle.properties | |
| sed -i -e "s,livekitApiSecret=,livekitApiSecret=$LIVEKIT_API_SECRET,g" gradle.properties | |
| env: | |
| LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }} | |
| LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }} | |
| LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }} | |
| - name: Build video test app | |
| if: github.event_name == 'push' | |
| run: ./gradlew video-encode-decode-test:assembleDebug video-encode-decode-test:assembleDebugAndroidTest | |
| - name: Video Encode Decode App upload and Set app id in environment variable. | |
| if: github.event_name == 'push' | |
| run: | | |
| APP_UPLOAD_RESPONSE=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST https://api-cloud.browserstack.com/app-automate/upload -F "file=@video-encode-decode-test/build/outputs/apk/debug/video-encode-decode-test-debug.apk") | |
| echo "APP_UPLOAD_RESPONSE: $APP_UPLOAD_RESPONSE" | |
| APP_ID=$(echo $APP_UPLOAD_RESPONSE | jq -r ".app_url") | |
| if [ $APP_ID != null ]; then | |
| echo "Apk uploaded to BrowserStack with app id : $APP_ID"; | |
| echo "BROWSERSTACK_APP_ID=$APP_ID" >> $GITHUB_ENV; | |
| echo "Setting value of BROWSERSTACK_APP_ID in environment variables to $APP_ID"; | |
| else | |
| UPLOAD_ERROR_MESSAGE=$(echo $APP_UPLOAD_RESPONSE | jq -r ".error") | |
| echo "App upload failed, reason : ",$UPLOAD_ERROR_MESSAGE | |
| exit 1; | |
| fi | |
| env: | |
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
| - name: Video Encode Decode Test Suite upload and Set test suite id in environment variable. | |
| if: github.event_name == 'push' | |
| run: | | |
| APP_UPLOAD_RESPONSE=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite -F "file=@video-encode-decode-test/build/outputs/apk/androidTest/debug/video-encode-decode-test-debug-androidTest.apk") | |
| echo "APP_UPLOAD_RESPONSE: $APP_UPLOAD_RESPONSE" | |
| APP_ID=$(echo $APP_UPLOAD_RESPONSE | jq -r ".test_suite_url") | |
| if [ $APP_ID != null ]; then | |
| echo "Test Suite Apk uploaded to BrowserStack with id: $APP_ID"; | |
| echo "BROWSERSTACK_TEST_ID=$APP_ID" >> $GITHUB_ENV; | |
| echo "Setting value of BROWSERSTACK_TEST_ID in environment variables to $APP_ID"; | |
| else | |
| UPLOAD_ERROR_MESSAGE=$(echo $APP_UPLOAD_RESPONSE | jq -r ".error") | |
| echo "App upload failed, reason : ",$UPLOAD_ERROR_MESSAGE | |
| exit 1; | |
| fi | |
| env: | |
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
| - name: Trigger BrowserStack tests | |
| if: github.event_name == 'push' | |
| run: | | |
| TEST_RESPONSE=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" -d '{"deviceLogs": true, "app": "'"$BROWSERSTACK_APP_ID"'", "testSuite": "'"$BROWSERSTACK_TEST_ID"'", "devices": ["Samsung Galaxy Tab S7-10.0","Samsung Galaxy S22-12.0", "Samsung Galaxy S21-12.0","Samsung Galaxy S20-10.0", "Google Pixel 6-12.0", "Google Pixel 5-11.0", "Google Pixel 3-10.0", "OnePlus 7-9.0","Xiaomi Redmi Note 8-9.0", "Huawei P30-9.0"]}' -H "Content-Type: application/json") | |
| echo "TEST_RESPONSE: $TEST_RESPONSE" | |
| env: | |
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
| - name: get version name | |
| if: github.event_name == 'push' | |
| run: echo "::set-output name=version_name::$(cat gradle.properties | grep VERSION_NAME | cut -d "=" -f2)" | |
| id: version_name | |
| - name: Create gpg key and import into gradle properties | |
| if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT') | |
| run: | | |
| echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc | |
| gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc | |
| sed -i -e "s,nexusUsername=,nexusUsername=$NEXUS_USERNAME,g" gradle.properties | |
| sed -i -e "s,nexusPassword=,nexusPassword=$NEXUS_PASSWORD,g" gradle.properties | |
| sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties | |
| sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties | |
| sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties | |
| sed -i -e "s,STAGING_PROFILE_ID=,STAGING_PROFILE_ID=$PROFILE_ID,g" gradle.properties | |
| env: | |
| GPG_KEY_ARMOR: "${{ secrets.SIGNING_KEY_ARMOR }}" | |
| GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
| GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
| NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} | |
| NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} | |
| PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }} | |
| - name: Publish snapshot | |
| if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT') | |
| run: ./gradlew publishReleasePublicationToMavenRepository | |
| # Setting up diffuse artifacts | |
| - name: Setup cache for base source file for diffuse | |
| if: github.event_name == 'push' | |
| uses: actions/cache@v4 | |
| with: | |
| path: client-sdk-android/diffuse-source-file | |
| key: diffuse-${{ github.sha }} | |
| # Copy your build artifact under `diffuse-source-file` name which will be saved in cache | |
| - name: Copy diffuse source file | |
| run: cp ./livekit-android-sdk/build/outputs/aar/livekit-android-sdk-release.aar diffuse-source-file | |
| if: github.event_name == 'push' | |
| shell: bash | |
| - name: Repository Dispatch | |
| if: github.event_name == 'push' | |
| uses: peter-evans/repository-dispatch@v2 | |
| with: | |
| token: ${{ secrets.E2E_DISPATCH_TOKEN }} | |
| repository: livekit/e2e-android | |
| event-type: client-sdk-android-push | |
| client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' | |
| diffuse: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'pull_request' }} | |
| name: Diffuse checker | |
| needs: build | |
| steps: | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| # Diffuse checking for pull requests | |
| - uses: actions/cache@v4 | |
| name: Download base source AAR for diffuse | |
| with: | |
| path: client-sdk-android/diffuse-source-file | |
| key: diffuse-${{ github.event.pull_request.base.sha }} | |
| - uses: actions/download-artifact@v5 | |
| name: Download current release AAR for diffuse | |
| with: | |
| name: livekit-android-sdk-release.aar | |
| path: client-sdk-android/ | |
| - id: diffuse | |
| uses: usefulness/diffuse-action@v1 | |
| with: | |
| old-file-path: client-sdk-android/diffuse-source-file | |
| new-file-path: client-sdk-android/livekit-android-sdk-release.aar | |
| - name: Log diffuse output | |
| run: | | |
| echo "Diffuse output:" | |
| echo "${{ steps.diffuse.outputs.diff-gh-comment }}" | |
| # Consuming diffuse action output | |
| - uses: peter-evans/find-comment@v4 | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| id: find_comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-includes: Diffuse output | |
| - uses: peter-evans/create-or-update-comment@v5 | |
| if: github.event.pull_request.head.repo.full_name == github.repository && (steps.diffuse.outputs.diff-raw != null || steps.find_comment.outputs.comment-id != null) | |
| with: | |
| body: | | |
| Diffuse output: | |
| ${{ steps.diffuse.outputs.diff-gh-comment }} | |
| edit-mode: replace | |
| comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: diffuse-output | |
| path: ${{ steps.diffuse.outputs.diff-file }} |