diff --git a/.github/actions/allure-launch/action.yml b/.github/actions/allure-launch/action.yml new file mode 100644 index 00000000000..d683ebe848b --- /dev/null +++ b/.github/actions/allure-launch/action.yml @@ -0,0 +1,18 @@ +name: 'Allure Launch' +description: 'Launches Allure TestOps job' +inputs: + allure-token: + description: 'ALLURE_TOKEN' + required: true + cron: + description: 'Is this a cron check?' + default: 'false' +runs: + using: "composite" + steps: + - name: Launch Allure TestOps + run: bundle exec fastlane allure_launch cron:${{ inputs.cron }} + shell: bash + env: + ALLURE_TOKEN: ${{ inputs.allure-token }} + GITHUB_EVENT: ${{ toJson(github.event) }} diff --git a/.github/actions/setup-java/action.yml b/.github/actions/setup-java/action.yml new file mode 100644 index 00000000000..7874bd350da --- /dev/null +++ b/.github/actions/setup-java/action.yml @@ -0,0 +1,10 @@ +name: 'Setup Java' +description: 'Setup Java' +runs: + using: "composite" + steps: + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: adopt + java-version: 17 diff --git a/.github/actions/ruby-cache/action.yml b/.github/actions/setup-ruby/action.yml similarity index 67% rename from .github/actions/ruby-cache/action.yml rename to .github/actions/setup-ruby/action.yml index 25b8a9a761f..8a56bec008d 100644 --- a/.github/actions/ruby-cache/action.yml +++ b/.github/actions/setup-ruby/action.yml @@ -1,5 +1,5 @@ -name: 'Ruby Cache' -description: 'Cache Ruby dependencies' +name: 'Setup Ruby' +description: 'Setup Ruby and cache bundler' runs: using: "composite" steps: diff --git a/.github/workflows/apk-s3-distribute.yml b/.github/workflows/apk-s3-distribute.yml index 02c59f5ab2d..b83b43873e0 100644 --- a/.github/workflows/apk-s3-distribute.yml +++ b/.github/workflows/apk-s3-distribute.yml @@ -12,11 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Prepare environment run: | git fetch --unshallow diff --git a/.github/workflows/app-distribute.yml b/.github/workflows/app-distribute.yml index 8deadc253cc..e9b51723c8f 100644 --- a/.github/workflows/app-distribute.yml +++ b/.github/workflows/app-distribute.yml @@ -12,11 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Prepare environment run: | git fetch --unshallow @@ -44,11 +40,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Prepare environment run: | git fetch --unshallow diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 304a1d3872a..176a29478e6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -17,11 +17,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Build run: ./gradlew assembleDebug :stream-chat-android-ui-uitests:assembleDebugAndroidTest @@ -31,11 +27,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Build run: ./gradlew assembleRelease @@ -45,11 +37,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Unit tests run: ./scripts/ci-unit-tests.sh - name: Upload testDebugUnitTest results @@ -65,11 +53,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: build demo debug run: ./gradlew stream-chat-android-ui-components-sample:assembleDemoDebug - name: Upload artifact to Emerge @@ -85,11 +69,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: build debug run: ./gradlew stream-chat-android-compose-sample:assembleDebug - name: Upload artifact to Emerge diff --git a/.github/workflows/check-entities.yml b/.github/workflows/check-entities.yml index aa50c8fadc0..2c8c14738b9 100644 --- a/.github/workflows/check-entities.yml +++ b/.github/workflows/check-entities.yml @@ -11,11 +11,7 @@ jobs: uses: actions/checkout@v3.1.0 with: fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Find touched DB Entities id: touchedEntities continue-on-error: true diff --git a/.github/workflows/clean-detekt-baseline.yaml b/.github/workflows/clean-detekt-baseline.yaml index b446daab54f..620b0ba5af7 100644 --- a/.github/workflows/clean-detekt-baseline.yaml +++ b/.github/workflows/clean-detekt-baseline.yaml @@ -15,11 +15,7 @@ jobs: with: ref: develop token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }} - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: tibdex/github-app-token@v1.7.0 id: generate-token with: diff --git a/.github/workflows/e2e-build.yml b/.github/workflows/e2e-build.yml new file mode 100644 index 00000000000..f4bdc657d01 --- /dev/null +++ b/.github/workflows/e2e-build.yml @@ -0,0 +1,30 @@ +name: E2E Build + +on: + workflow_call: + inputs: + app: + required: true + type: string + +jobs: + build: + name: ${{ inputs.app }} apks + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4.2.2 + - uses: ./.github/actions/setup-java + - uses: ./.github/actions/enable-kvm + - uses: ./.github/actions/setup-ruby + - uses: ./.github/actions/gradle-cache + with: + key-prefix: gradle-test + - name: Build apks + run: bundle exec fastlane build_e2e_test + - name: Upload apks + uses: actions/upload-artifact@v4.4.3 + with: + name: apks + path: | + stream-chat-android-${{ inputs.app }}-sample/build/outputs/apk/e2e/debug/*.apk + stream-chat-android-${{ inputs.app }}-sample/build/outputs/apk/androidTest/e2e/debug/*.apk diff --git a/.github/workflows/e2e-test-cron.yml b/.github/workflows/e2e-test-cron.yml new file mode 100644 index 00000000000..76be02538e6 --- /dev/null +++ b/.github/workflows/e2e-test-cron.yml @@ -0,0 +1,86 @@ +name: E2E Tests Nightly + +on: + schedule: + # Runs "At 01:00 every night except weekends" + - cron: '0 1 * * 1-5' + + workflow_dispatch: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build-compose-apks: + name: Build + uses: ./.github/workflows/e2e-build.yml + with: + app: compose + + run-compose-tests-nightly: + name: Test compose + runs-on: ubuntu-24.04 + needs: build-compose-apks + strategy: + matrix: + include: + - android_api_level: 35 + - android_api_level: 34 + - android_api_level: 33 + - android_api_level: 32 + - android_api_level: 31 + - android_api_level: 29 + - android_api_level: 28 + fail-fast: false + env: + ANDROID_API_LEVEL: ${{ matrix.android_api_level }} + steps: + - name: Connect Bot + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} + - uses: actions/checkout@v4.2.2 + - uses: actions/download-artifact@v4.1.8 + continue-on-error: true + with: + name: apks + - uses: ./.github/actions/setup-java + - uses: ./.github/actions/enable-kvm + - uses: ./.github/actions/setup-ruby + - uses: ./.github/actions/allure-launch + with: + allure-token: ${{ secrets.ALLURE_TOKEN }} + cron: true + - name: Run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.ANDROID_API_LEVEL }} + disable-animations: true + profile: pixel + arch : x86_64 + emulator-options: ${{ vars.EMULATOR_OPTIONS }} + script: bundle exec fastlane run_e2e_test + - name: Allure TestOps Upload + run: bundle exec fastlane allure_upload + if: success() || failure() + env: + ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} + LAUNCH_ID: ${{ env.LAUNCH_ID }} + - name: Allure TestOps Launch Removal + run: bundle exec fastlane allure_launch_removal + if: cancelled() + env: + ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} + LAUNCH_ID: ${{ env.LAUNCH_ID }} + - name: Upload test results + uses: actions/upload-artifact@v4.4.3 + if: failure() + with: + name: test_report + path: | + ./**/build/reports/androidTests/* + fastlane/stream-chat-test-mock-server/logs/* diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml new file mode 100644 index 00000000000..07ff7722dc3 --- /dev/null +++ b/.github/workflows/e2e-test.yml @@ -0,0 +1,78 @@ +name: E2E Tests + +on: + pull_request: + + workflow_dispatch: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_NUM: ${{ github.event.pull_request.number }} + +jobs: + build-compose-apks: + name: Build + uses: ./.github/workflows/e2e-build.yml + with: + app: compose + + run-compose-tests: + name: Test compose + runs-on: ubuntu-24.04 + needs: build-compose-apks + strategy: + matrix: + include: + - batch: 0 + - batch: 1 + env: + ANDROID_API_LEVEL: 35 + steps: + - name: Connect Bot + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} + - uses: actions/checkout@v4.2.2 + - uses: actions/download-artifact@v4.1.8 + continue-on-error: true + with: + name: apks + - uses: ./.github/actions/setup-java + - uses: ./.github/actions/enable-kvm + - uses: ./.github/actions/setup-ruby + - uses: ./.github/actions/allure-launch + with: + allure-token: ${{ secrets.ALLURE_TOKEN }} + - name: Run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.ANDROID_API_LEVEL }} + disable-animations: true + profile: pixel + arch : x86_64 + emulator-options: ${{ vars.EMULATOR_OPTIONS }} + script: bundle exec fastlane run_e2e_test batch:${{ matrix.batch }} batch_count:${{ strategy.job-total }} + - name: Allure TestOps Upload + if: success() || failure() + run: bundle exec fastlane allure_upload + env: + ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} + LAUNCH_ID: ${{ env.LAUNCH_ID }} + - name: Allure TestOps Launch Removal + if: cancelled() + run: bundle exec fastlane allure_launch_removal + env: + ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} + LAUNCH_ID: ${{ env.LAUNCH_ID }} + - name: Upload test results + uses: actions/upload-artifact@v4.4.3 + if: failure() + with: + name: test_report + path: | + ./**/build/reports/androidTests/* + fastlane/stream-chat-test-mock-server/logs/* diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml deleted file mode 100644 index adf5098558c..00000000000 --- a/.github/workflows/e2e-tests.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: E2E Tests - -on: - pull_request: - - workflow_dispatch: - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.pull_request.number }} - -jobs: - build-apks: - name: Build - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4.2.2 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: adopt - java-version: 17 - - uses: ./.github/actions/enable-kvm - - uses: ./.github/actions/ruby-cache - - uses: ./.github/actions/gradle-cache - with: - key-prefix: gradle-test - - name: Build apks - run: bundle exec fastlane build_e2e_test - - name: Upload apks - uses: actions/upload-artifact@v4.4.0 - with: - name: apks - path: | - stream-chat-android-compose-sample/build/outputs/apk/e2e/debug/*.apk - stream-chat-android-compose-sample/build/outputs/apk/androidTest/e2e/debug/*.apk - - allure_testops_launch: - name: Launch Allure TestOps - runs-on: ubuntu-24.04 - needs: build-apks - outputs: - launch_id: ${{ steps.get_launch_id.outputs.launch_id }} - steps: - - uses: actions/checkout@v4.1.1 - - uses: ./.github/actions/ruby-cache - - name: Launch Allure TestOps - run: bundle exec fastlane allure_launch - env: - ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - GITHUB_EVENT: ${{ toJson(github.event) }} - - id: get_launch_id - run: echo "launch_id=${{env.LAUNCH_ID}}" >> $GITHUB_OUTPUT - if: env.LAUNCH_ID != '' - - run-tests: - name: Test - runs-on: ubuntu-24.04 - needs: - - build-apks - - allure_testops_launch - env: - LAUNCH_ID: ${{ needs.allure_testops_launch.outputs.launch_id }} - steps: - - name: Connect Bot - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} - - uses: actions/checkout@v4.2.2 - - uses: actions/download-artifact@v4.1.8 - continue-on-error: true - with: - name: apks - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: adopt - java-version: 17 - - uses: ./.github/actions/enable-kvm - - uses: ./.github/actions/ruby-cache - - uses: ./.github/actions/gradle-cache - with: - key-prefix: gradle-test - - name: Run tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - disable-animations: true - profile: pixel - arch : x86_64 - emulator-options: -no-snapshot-save -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -camera-back none -camera-front none - script: bundle exec fastlane run_e2e_test - - name: Allure TestOps Upload - if: env.LAUNCH_ID != '' && (success() || failure()) - run: bundle exec fastlane allure_upload launch_id:$LAUNCH_ID - env: - ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - - name: Allure TestOps Launch Removal - if: env.LAUNCH_ID != '' && cancelled() - run: bundle exec fastlane allure_launch_removal launch_id:$LAUNCH_ID - env: - ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - - name: Upload test results - uses: actions/upload-artifact@v3.1.0 - if: failure() - with: - name: test_report - path: | - ./**/build/reports/androidTests/* - fastlane/stream-chat-test-mock-server/logs/* diff --git a/.github/workflows/localazy-download.yml b/.github/workflows/localazy-download.yml index e2189b65821..cc6aa7f4c9a 100644 --- a/.github/workflows/localazy-download.yml +++ b/.github/workflows/localazy-download.yml @@ -13,11 +13,7 @@ jobs: - uses: actions/checkout@v3.1.0 with: ref: develop - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: tibdex/github-app-token@v1.7.0 id: generate-token with: diff --git a/.github/workflows/localazy-upload.yml b/.github/workflows/localazy-upload.yml index 97df812fecc..a83c6793602 100644 --- a/.github/workflows/localazy-upload.yml +++ b/.github/workflows/localazy-upload.yml @@ -15,11 +15,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v1 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: localazy/upload@v1 with: read_key: ${{ secrets.LOCALAZY_READ_KEY }} diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 391fa206ed1..580ebf4e5e4 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -19,11 +19,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-lint @@ -39,11 +35,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-APICheck @@ -56,11 +48,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-build @@ -73,11 +61,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-test @@ -95,5 +79,5 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4.2.2 - - uses: ./.github/actions/ruby-cache + - uses: ./.github/actions/setup-ruby - run: bundle exec fastlane rubocop diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml index 6e34578bbf8..31fa96f1806 100644 --- a/.github/workflows/publish-beta.yml +++ b/.github/workflows/publish-beta.yml @@ -12,11 +12,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Release build # assembleRelease for all modules, excluding non-library modules: samples, docs run: ./gradlew assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease diff --git a/.github/workflows/publish-hotfix.yml b/.github/workflows/publish-hotfix.yml index 43865ce665c..79d4c10ae84 100644 --- a/.github/workflows/publish-hotfix.yml +++ b/.github/workflows/publish-hotfix.yml @@ -12,11 +12,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Release build # assembleRelease for all modules, excluding non-library modules: samples, docs run: ./gradlew assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 3dbac60ac52..a1a79c12c8b 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -5,7 +5,7 @@ on: branches: - develop workflow_dispatch: - + jobs: publish: name: Snapshot build and publish @@ -13,11 +13,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Release build # assembleRelease for all modules, excluding non-library modules: samples, docs run: ./gradlew assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 986b51482c5..0ddd486e43d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,10 +3,11 @@ name: Publish on: workflow_run: workflows: ["ReleaseStart"] - workflow_dispatch: types: - completed + workflow_dispatch: + jobs: publish: name: Release build and publish @@ -18,11 +19,7 @@ jobs: with: ref: release persist-credentials: false - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Release build # assembleRelease for all modules, excluding non-library modules: samples, docs run: ./gradlew assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease diff --git a/.github/workflows/release-docs.yaml b/.github/workflows/release-docs.yaml index 37281384021..0baf5f7e87d 100644 --- a/.github/workflows/release-docs.yaml +++ b/.github/workflows/release-docs.yaml @@ -14,11 +14,7 @@ jobs: uses: actions/checkout@v3.1.0 with: ref: main - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Generate Dokka HTML docs run: ./gradlew dokkaHtmlMultimodule - name: Deploy to GitHub pages diff --git a/.github/workflows/release-post.yaml b/.github/workflows/release-post.yaml index 172ad42a21f..77f2094ec82 100644 --- a/.github/workflows/release-post.yaml +++ b/.github/workflows/release-post.yaml @@ -11,19 +11,15 @@ jobs: name: Sync main with release runs-on: ubuntu-22.04 if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: + steps: - name: Check out code uses: actions/checkout@v3.1.0 with: ref: main persist-credentials: false - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Sync main - run: | + run: | git fetch origin release git merge --ff-only origin/release - name: Push changes @@ -42,11 +38,7 @@ jobs: ref: main fetch-depth: 0 persist-credentials: false - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Update changelog run: ./gradlew changelog-add-model-section - name: Commit CHANGELOG.md and merge to develop diff --git a/.github/workflows/release-start.yaml b/.github/workflows/release-start.yaml index 8c363aee0d6..34f032a2c4a 100644 --- a/.github/workflows/release-start.yaml +++ b/.github/workflows/release-start.yaml @@ -3,7 +3,7 @@ name: ReleaseStart on: workflow_dispatch: inputs: - force_bump_minor_version: + force_bump_minor_version: type: boolean skip_version_bump: type: boolean @@ -19,11 +19,7 @@ jobs: with: ref: develop persist-credentials: false - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - name: Minor version bump if: "${{ github.event.inputs.force_bump_minor_version == 'true' && github.event.inputs.skip_version_bump != 'true' }}" run: ./gradlew minor-bump diff --git a/.github/workflows/snapshot-record.yaml b/.github/workflows/snapshot-record.yaml index 32053da2fd8..5d3f2aa24ea 100644 --- a/.github/workflows/snapshot-record.yaml +++ b/.github/workflows/snapshot-record.yaml @@ -11,11 +11,7 @@ jobs: uses: actions/checkout@v3.1.0 with: ref: develop - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-test @@ -26,7 +22,7 @@ jobs: disable-animations: true profile: pixel arch : x86_64 - emulator-options: -no-snapshot-save -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -camera-back none -camera-front none + emulator-options: ${{ vars.EMULATOR_OPTIONS }} script: ./gradlew stream-chat-android-ui-uitests:executeScreenshotTests -Precord -Pandroid.testInstrumentationRunnerArguments.filter=io.getstream.chat.android.uitests.util.SnapshotTestFilter - name: Upload screnshots uses: actions/upload-artifact@v3.1.0 diff --git a/.github/workflows/snapshot-tests.yaml b/.github/workflows/snapshot-tests.yaml index a5157f57a73..baf1f4bd079 100644 --- a/.github/workflows/snapshot-tests.yaml +++ b/.github/workflows/snapshot-tests.yaml @@ -15,11 +15,7 @@ jobs: uses: actions/checkout@v3.1.0 with: ref: develop - - name: Set up JDK 17 - uses: actions/setup-java@v3.6.0 - with: - distribution: adopt - java-version: 17 + - uses: ./.github/actions/setup-java - uses: ./.github/actions/gradle-cache with: key-prefix: gradle-test @@ -30,7 +26,7 @@ jobs: disable-animations: true profile: pixel arch : x86_64 - emulator-options: -no-snapshot-save -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -camera-back none -camera-front none + emulator-options: ${{ vars.EMULATOR_OPTIONS }} script: ./gradlew stream-chat-android-ui-uitests:executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.filter=io.getstream.chat.android.uitests.util.SnapshotTestFilter - name: Upload screnshot results if: always() diff --git a/.gitignore b/.gitignore index 50d420ca7f8..ad21726cf67 100644 --- a/.gitignore +++ b/.gitignore @@ -114,5 +114,7 @@ fastlane/screenshots fastlane/test_output fastlane/allurectl fastlane/recordings +fastlane/test-parser.jar +fastlane/AllTests.txt allure-results stream-chat-test-mock-server diff --git a/fastlane/Allurefile b/fastlane/Allurefile index 574e4ea1eac..a9b973e206e 100755 --- a/fastlane/Allurefile +++ b/fastlane/Allurefile @@ -9,8 +9,9 @@ allure_results_path = 'allure-results' desc 'Upload test results to Allure TestOps' lane :allure_upload do |options| remove_duplicated_allure_results + options[:launch_id] ||= ENV.fetch('LAUNCH_ID', nil) allure_args = "-e #{allure_url} --project-id #{allure_project_id} --launch-id #{options[:launch_id]}" - sh("./allurectl launch reopen #{options[:launch_id]} || true") # to prevent allure from uploading results to a closed launch + sh("./allurectl launch reopen #{options[:launch_id]} -e #{allure_url} || true") # to prevent allure from uploading results to a closed launch sh("env BRANCH_NAME='#{current_branch}' ./allurectl upload #{allure_args} #{allure_results_path} || true") UI.success("Check out test results in Allure TestOps: #{allure_url}/launch/#{options[:launch_id]} 🎉") end @@ -30,6 +31,7 @@ end desc 'Remove launch on Allure TestOps' lane :allure_launch_removal do |options| + options[:launch_id] ||= ENV.fetch('LAUNCH_ID', nil) allure_api(url: allure_api_url, path: "launch/#{options[:launch_id]}", http_method: 'DELETE') end diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 75eba3b21f8..cb24f018640 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -7,9 +7,6 @@ import 'Allurefile' github_repo = ENV['GITHUB_REPOSITORY'] || 'GetStream/stream-chat-android' test_flavor = 'stream-chat-android-compose-sample' -androidx_test_orchestrator_version = '1.5.1' -androidx_test_services_version = '1.5.0' -allure_ctl_version = '2.15.1' mock_server_driver_port = 4567 is_localhost = !is_ci @force_check = false @@ -39,7 +36,7 @@ end lane :build_and_run_e2e_test do |options| build_e2e_test - run_e2e_test + run_e2e_test(batch: options[:batch], batch_count: options[:batch_count]) end lane :build_e2e_test do @@ -48,7 +45,7 @@ lane :build_e2e_test do gradle(tasks: [":#{test_flavor}:assembleE2eDebugAndroidTest", ":#{test_flavor}:assembleE2eDebug"]) end -lane :run_e2e_test do +lane :run_e2e_test do |options| next unless is_check_required(sources: sources_matrix[:e2e], force_check: @force_check) allure_results_path = 'allure-results' @@ -59,11 +56,11 @@ lane :run_e2e_test do start_mock_server install_test_services - Dir.chdir('..') do - stream_apk_path = is_ci ? '.' : "#{test_flavor}/build/outputs/apk" - sh("adb install -r '#{stream_apk_path}/e2e/debug/stream-chat-android-compose-sample-e2e-debug.apk'") - sh("adb install -r '#{stream_apk_path}/androidTest/e2e/debug/stream-chat-android-compose-sample-e2e-debug-androidTest.apk'") - end + stream_apk_folder_path = is_ci ? '..' : "../#{test_flavor}/build/outputs/apk" + stream_app_path = "#{stream_apk_folder_path}/e2e/debug/stream-chat-android-compose-sample-e2e-debug.apk" + stream_test_path = "#{stream_apk_folder_path}/androidTest/e2e/debug/stream-chat-android-compose-sample-e2e-debug-androidTest.apk" + sh("adb install -r #{stream_app_path}") + sh("adb install -r #{stream_test_path}") app_package_name = 'io.getstream.chat.android.compose.sample.e2etest.debug' test_package_name = "#{app_package_name}.test" @@ -71,40 +68,42 @@ lane :run_e2e_test do orchestrator_package_name = 'androidx.test.orchestrator/.AndroidTestOrchestrator' androidx_test_services_path = sh('adb shell pm path androidx.test.services').strip + run_tests_in_batches = batch_tests( + batch: options[:batch], + batch_count: options[:batch_count], + test_apk_path: stream_test_path + ) + result = sh( - "adb shell 'CLASSPATH=#{androidx_test_services_path}' app_process / " \ - 'androidx.test.services.shellexecutor.ShellMain am instrument -w -e clearPackageData true ' \ - "-e targetInstrumentation #{test_package_name}/#{runner_package_name} #{orchestrator_package_name}" + "adb shell 'CLASSPATH=#{androidx_test_services_path}' " \ + 'app_process / androidx.test.services.shellexecutor.ShellMain am instrument -w -e clearPackageData true ' \ + "-e targetInstrumentation #{test_package_name}/#{runner_package_name} #{run_tests_in_batches} #{orchestrator_package_name}" ) - sh("adb exec-out sh -c 'cd #{adb_test_results_path} && tar cf - #{allure_results_path}' | tar xvf - -C .") + sh("adb exec-out sh -c 'cd #{adb_test_results_path} && tar cf - #{allure_results_path}' | tar xvf - -C .") if is_ci stop_mock_server UI.user_error!('Tests have failed!') if result.include?('Failures') end -private_lane :install_test_services do - orchestrator_apk_path = "apks/orchestrator.apk" - test_services_apk_path = "apks/test-services.apk" - allure_ctl_path = "allurectl" - allure_ctl_arch = RbConfig::CONFIG['host_os'].include?('darwin') ? 'darwin_amd64' : 'linux_amd64' - maven_repo = 'https://dl.google.com/dl/android/maven2/androidx/test' - - if [orchestrator_apk_path, test_services_apk_path, allure_ctl_path].any? { |f| !File.exist?(f) } - FileUtils.mkdir_p('apks') - sh("wget -O #{orchestrator_apk_path} '#{maven_repo}" \ - "/orchestrator/#{androidx_test_orchestrator_version}/orchestrator-#{androidx_test_orchestrator_version}.apk' 2>/dev/null") - sh("wget -O #{test_services_apk_path} '#{maven_repo}" \ - "/services/test-services/#{androidx_test_services_version}/test-services-#{androidx_test_services_version}.apk' 2>/dev/null") - sh("wget -O #{allure_ctl_path} " \ - "'https://github.com/allure-framework/allurectl/releases/download/#{allure_ctl_version}/allurectl_#{allure_ctl_arch}' 2>/dev/null") - sh('chmod +x allurectl') +private_lane :batch_tests do |options| + if options[:batch] && options[:batch_count] + install(tool: :test_parser) + sh("java -jar test-parser.jar #{options[:test_apk_path]} ./") + test_names = File.read('AllTests.txt').split + current_batch = test_names.each_slice((test_names.size.to_f / options[:batch_count].to_i).ceil).to_a[options[:batch].to_i] + "-e class #{current_batch.join(',')}" + else + '' end +end +private_lane :install_test_services do + FileUtils.mkdir_p('apks') device_api_level = sh('adb shell getprop ro.build.version.sdk').strip.to_i - force_queryable_option = device_api_level >= 30 ? '--force-queryable' : '' - sh("adb install #{force_queryable_option} -r #{orchestrator_apk_path}") - sh("adb install #{force_queryable_option} -r #{test_services_apk_path}") + install(tool: :test_orchestrator, api_level: device_api_level) + install(tool: :test_services, api_level: device_api_level) + install(tool: :allurectl, chmod: true) if is_ci end desc 'Run fastlane linting' @@ -120,3 +119,30 @@ private_lane :sources_matrix do ruby: ['fastlane', 'Gemfile', 'Gemfile.lock'] } end + +private_lane :install do |options| + case options[:tool] + when :test_orchestrator + v = '1.5.1' + output = 'apks/orchestrator.apk' + url = "https://dl.google.com/dl/android/maven2/androidx/test//orchestrator/#{v}/orchestrator-#{v}.apk" + when :test_services + v = '1.5.0' + output = 'apks/test-services.apk' + url = "https://dl.google.com/dl/android/maven2/androidx/test/services/test-services/#{v}/test-services-#{v}.apk" + when :test_parser + v = '2.2.1' + output = 'test-parser.jar' + url = "https://linkedin.jfrog.io/artifactory/open-source/com/linkedin/dextestparser/parser/#{v}/parser-#{v}-all.jar" + when :allurectl + v = '2.15.1' + output = 'allurectl' + arch = RbConfig::CONFIG['host_os'].include?('darwin') ? 'darwin_amd64' : 'linux_386' + url = "https://github.com/allure-framework/allurectl/releases/download/#{v}/allurectl_#{arch}" + else + UI.user_error!('Provide a correct tool name.') + end + sh("wget -O #{output} '#{url}' 2>/dev/null") unless File.exist?(output) + sh("adb install #{options[:api_level] >= 30 ? '--force-queryable' : ''} -r #{output}") if options[:api_level] + sh("chmod +x #{output}") if options[:chmod] +end