Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify screenshot content #46

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
format_version: "11"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/Bitrise-Android-Sample
- TEST_APP_BRANCH: main

workflows:
test_emulator_start_23:
envs:
- EMU_VER: 23
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -15,6 +21,7 @@ workflows:
envs:
- EMU_VER: 26
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -24,6 +31,7 @@ workflows:
envs:
- EMU_VER: 28
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -33,6 +41,7 @@ workflows:
envs:
- EMU_VER: 29
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -42,18 +51,30 @@ workflows:
envs:
- EMU_VER: 30
- PROFILE: pixel_2
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
- _kill-emulator

test_emulator_start_32:
envs:
- EMU_VER: 32
- PROFILE: pixel_2
- ABI: x86_64
after_run:
- _start-emulator
- _run_ui_test_and_take_screenshot
- _kill-emulator

_start-emulator:
steps:
- path::./:
title: Step Test
inputs:
- profile: $PROFILE
- api_level: $EMU_VER
- abi: $ABI
- script:
inputs:
- content: |
Expand All @@ -69,6 +90,46 @@ workflows:
fi
- wait-for-android-emulator: { }

_run_ui_test_and_take_screenshot:
steps:
- script:
inputs:
- content: |-
#!/bin/env bash
set -ex
rm -rf ./_tmp
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
inputs:
- repository_url: $TEST_APP_URL
- clone_into_dir: ./_tmp
- branch: $TEST_APP_BRANCH
- gradle-runner:
inputs:
- gradle_file: ./_tmp/build.gradle
- gradle_task: connectedDebugAndroidTest
- gradlew_path: ./_tmp/gradlew
- app_file_include_filter: dontexport
- test_apk_file_include_filter: dontexport
- script:
inputs:
- content: |
#!/bin/bash
set -euxo pipefail

SCREENSHOT=./_tmp/app/screenshots/test_screenshot.png
cp $SCREENSHOT $BITRISE_DEPLOY_DIR/screen_$EMU_VER.png

if [[ "$OSTYPE" == "darwin"* ]]; then
brew install tesseract
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update
sudo apt-get install tesseract-ocr -y
fi

OUT=./_tmp/out
tesseract -l eng "$SCREENSHOT" "$OUT"
cat "${OUT}.txt" | grep 'Hello World!'

_take_screenshot:
steps:
- change-workdir:
Expand Down