Skip to content

Commit

Permalink
Add maestro to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosholgado committed Aug 31, 2022
1 parent 8e552fa commit a3ddee0
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
112 changes: 112 additions & 0 deletions .github/workflows/maestro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Instrumentation tests

on:
push:
branches:
- feature/marcos/add_maestro_to_ci
schedule:
- cron: '0 4 * * *' # run at 3 AM UTC
workflow_dispatch:

jobs:
instrumentation_tests:
runs-on: macos-latest
name: Instrumentation tests
strategy:
matrix:
api-level: [31]

steps:
- name: Cancel previous
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}

- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Decode keys
uses: davidSchuppa/base64Secret-toFile-action@v1
with:
secret: ${{ secrets.FAKE_RELEASE_PROPERTIES }}
fileName: ddg_android_build.properties
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/

- name: Decode key file
uses: davidSchuppa/base64Secret-toFile-action@v1
with:
secret: ${{ secrets.FAKE_RELEASE_KEY }}
fileName: android
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install Maestro
run: |
brew tap mobile-dev-inc/tap
brew install maestro
- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}

- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-emul-${{ 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 }}
target: google_apis
ndk: 21.0.6113669
arch: x86_64
profile: pixel_5
force-avd-creation: true
emulator-options: -gpu host -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Android checks
uses: reactiveCircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
ndk: 21.0.6113669
arch: x86_64
profile: pixel_5
force-avd-creation: false
emulator-options: -no-snapshot-save -gpu host -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew installPlayRelease && cd maestro && for i in *.yaml; do maestro test "$i"; done;

- name: Bundle the Android CI checks report
if: always()
run: find . -type d -name 'reports' | zip -@ -r android-checks-report.zip

- name: Upload the Android CI checks report
if: always()
uses: actions/upload-artifact@v2
with:
name: android-checks-report
path: android-checks-report.zip
25 changes: 25 additions & 0 deletions maestro/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
appId: com.duckduckgo.mobile.android
---
- launchApp:
clearState: true
- assertVisible:
text: ".*Not to worry! Searching and browsing privately.*"
- tapOn: "let's do it!"
- tapOn: "cancel"
- assertVisible:
text: ".*I'll also upgrade the security of your connection if possible.*"
- inputText: "https://www.search-company.site/"
- tapOn:
id: ".*key_pos_ime_action.*"
- assertVisible:
text: ".*Got It.*"
- tapOn:
text: ".*Got It.*"
- assertVisible:
id: ".*ad-id-2.*"
- tapOn:
id: ".*ad-id-2.*"
- assertVisible:
text: ".*Publisher site.*"
- tapOn:
text: ".*Publisher site.*"
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

rootDir.eachFile(groovy.io.FileType.DIRECTORIES) { File parent ->

String[] ignoreFolders = ["buildSrc", "fastlane", "submodules", "node_modules", "gradle", "build"]
String[] ignoreFolders = ["buildSrc", "fastlane", "submodules", "node_modules", "gradle", "build", "maestro"]
if (!parent.name.startsWith(".") && !ignoreFolders.contains(parent.name)) {
Boolean shouldAddProject = false
parent.eachFile {
Expand Down

0 comments on commit a3ddee0

Please sign in to comment.