Skip to content

Commit

Permalink
[CI-447] Add fallback apk (#85)
Browse files Browse the repository at this point in the history
* Add fallback apk

* Update device list for testing
  • Loading branch information
tothszabi authored Jan 18, 2023
1 parent 68703ef commit cdd9f62
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris

| Key | Description | Flags | Default |
| --- | --- | --- | --- |
| `app_path` | The path to the app to test (APK or AAB). By default `android-build` and `android-build-for-ui-testing` Steps export the `BITRISE_APK_PATH` Env Var, so you won't need to change this input. Can specify an APK (`$BITRISE_APK_PATH`) or AAB (Android App Bundle) as input (`$BITRISE_AAB_PATH`). | required | `$BITRISE_APK_PATH` |
| `test_devices` | Format: One device configuration per line and the parameters are separated with `,` in the order of: `deviceID,version,language,orientation` For example: `NexusLowRes,24,en,portrait` `NexusLowRes,24,en,landscape` Available devices and its versions: ``` ┌───────────────────┬──────────┬─────────────────────────────────────┬─────────┬─────────────┬─────────────────────────┬──────┐ │ MODEL_ID │ MAKE │ MODEL_NAME │ FORM │ RESOLUTION │ OS_VERSION_IDS │ TAGS │ ├───────────────────┼──────────┼─────────────────────────────────────┼─────────┼─────────────┼─────────────────────────┼──────┤ │ Nexus10 │ Samsung │ Nexus 10 │ VIRTUAL │ 2560 x 1600 │ 19,21,22 │ │ │ Nexus4 │ LG │ Nexus 4 │ VIRTUAL │ 1280 x 768 │ 19,21,22 │ │ │ Nexus5 │ LG │ Nexus 5 │ VIRTUAL │ 1920 x 1080 │ 19,21,22,23 │ │ │ Nexus5X │ LG │ Nexus 5X │ VIRTUAL │ 1920 x 1080 │ 23,24,25,26 │ │ │ Nexus6 │ Motorola │ Nexus 6 │ VIRTUAL │ 2560 x 1440 │ 21,22,23,24,25 │ │ │ Nexus6P │ Google │ Nexus 6P │ VIRTUAL │ 2560 x 1440 │ 23,24,25,26,27 │ │ │ Nexus7 │ Asus │ Nexus 7 (2012) │ VIRTUAL │ 1280 x 800 │ 19,21,22 │ │ │ Nexus7_clone_16_9 │ Generic │ Nexus7 clone, DVD 16:9 aspect ratio │ VIRTUAL │ 1280 x 720 │ 23,24,25,26 │ beta │ │ Nexus9 │ HTC │ Nexus 9 │ VIRTUAL │ 2048 x 1536 │ 21,22,23,24,25 │ │ │ NexusLowRes │ Generic │ Low-resolution MDPI phone │ VIRTUAL │ 640 x 360 │ 23,24,25,26,27,28,29,30 │ │ │ Pixel2 │ Google │ Pixel 2 │ VIRTUAL │ 1920 x 1080 │ 26,27,28,29,30 │ │ │ Pixel3 │ Google │ Pixel 3 │ VIRTUAL │ 2160 x 1080 │ 30 │ │ └───────────────────┴──────────┴─────────────────────────────────────┴─────────┴─────────────┴─────────────────────────┴──────┘ ``` | required | `NexusLowRes,24,en,portrait` |
| `app_path` | The path to the app to test (APK or AAB). By default `android-build` and `android-build-for-ui-testing` Steps export the `BITRISE_APK_PATH` Env Var, so you won't need to change this input. Can specify an APK (`$BITRISE_APK_PATH`) or AAB (Android App Bundle) as input (`$BITRISE_AAB_PATH`). If nothing is specified then the Step will use a default empty Application APK. This will help the library instrumentation tests as it can be used as a shell where the tests will be running. | | `$BITRISE_APK_PATH` |
| `test_devices` | Format: One device configuration per line and the parameters are separated with `,` in the order of: `deviceID,version,language,orientation` For example: `NexusLowRes,24,en,portrait` `NexusLowRes,24,en,landscape` Available devices and its versions: ``` ┌─────────────────────┬──────────┬──────────────────────────────────────────┬─────────┬─────────────┬─────────────────────────┬──────────────────┐ │ MODEL_ID │ MAKE │ MODEL_NAME │ FORM │ RESOLUTION │ OS_VERSION_IDS │ TAGS │ ├─────────────────────┼──────────┼──────────────────────────────────────────┼─────────┼─────────────┼─────────────────────────┼──────────────────┤ │ AmatiTvEmulator │ Google │ Google TV Amati │ VIRTUAL │ 1080 x 1920 │ 29 │ beta=29 │ │ AndroidTablet270dpi │ Generic │ Generic 720x1600 Android tablet @ 270dpi │ VIRTUAL │ 1600 x 720 │ 30 │ │ │ GoogleTvEmulator │ Google │ Google TV │ VIRTUAL │ 720 x 1280 │ 30 │ beta=30 │ │ MediumPhone.arm │ Generic │ MediumPhone (ARM) │ VIRTUAL │ 2400 x 1080 │ 26,27,28,29,30,32,33 │ preview=33, beta │ │ MediumTablet.arm │ Generic │ MediumTablet (ARM) │ VIRTUAL │ 2560 x 1600 │ 26,27,28,29,30,32,33 │ preview=33, beta │ │ Nexus10 │ Samsung │ Nexus 10 │ VIRTUAL │ 2560 x 1600 │ 19,21,22 │ deprecated=19 │ │ Nexus4 │ LG │ Nexus 4 │ VIRTUAL │ 1280 x 768 │ 19,21,22 │ deprecated=19 │ │ Nexus5 │ LG │ Nexus 5 │ VIRTUAL │ 1920 x 1080 │ 19,21,22,23 │ deprecated=19 │ │ Nexus5X │ LG │ Nexus 5X │ VIRTUAL │ 1920 x 1080 │ 23,24,25,26 │ │ │ Nexus6 │ Motorola │ Nexus 6 │ VIRTUAL │ 2560 x 1440 │ 21,22,23,24,25 │ │ │ Nexus6P │ Google │ Nexus 6P │ VIRTUAL │ 2560 x 1440 │ 23,24,25,26,27 │ │ │ Nexus7 │ Asus │ Nexus 7 (2012) │ VIRTUAL │ 1280 x 800 │ 19,21,22 │ deprecated=19 │ │ Nexus7_clone_16_9 │ Generic │ Nexus7 clone, DVD 16:9 aspect ratio │ VIRTUAL │ 1280 x 720 │ 23,24,25,26 │ beta │ │ Nexus9 │ HTC │ Nexus 9 │ VIRTUAL │ 2048 x 1536 │ 21,22,23,24,25 │ │ │ NexusLowRes │ Generic │ Low-resolution MDPI phone │ VIRTUAL │ 640 x 360 │ 23,24,25,26,27,28,29,30 │ │ │ Pixel2 │ Google │ Pixel 2 │ VIRTUAL │ 1920 x 1080 │ 26,27,28,29,30 │ │ │ Pixel2.arm │ Google │ Pixel 2 (ARM) │ VIRTUAL │ 1920 x 1080 │ 26,27,28,29,30,32,33 │ preview=33, beta │ │ Pixel3 │ Google │ Pixel 3 │ VIRTUAL │ 2160 x 1080 │ 30 │ │ │ SmallPhone.arm │ Generic │ SmallPhone (ARM) │ VIRTUAL │ 1280 x 720 │ 26,27,28,29,30,32,33 │ preview=33, beta │ └─────────────────────┴──────────┴──────────────────────────────────────────┴─────────┴─────────────┴─────────────────────────┴──────────────────┘ ``` | required | `NexusLowRes,24,en,portrait` |
| `test_type` | The type of your test you want to run on the devices. Find more properties below in the selected test type's group. | required | `robo` |
| `test_apk_path` | The path to the APK that contains instrumentation tests. To build this, you can run the [Build for UI testing](https://bitrise.io/integrations/steps/android-build-for-ui-testing) Step (before this Step). | | `$BITRISE_TEST_APK_PATH` |
| `inst_test_runner_class` | The fully-qualified Java class name of the instrumentation test runner (leave empty to use the last name extracted from the APK manifest). | | |
Expand Down
25 changes: 21 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ package main

import (
"bufio"
_ "embed"
"fmt"
"os"
"path/filepath"
"strings"
"text/tabwriter"

"github.com/bitrise-io/go-utils/fileutil"
"github.com/bitrise-io/go-utils/log"
"github.com/bitrise-io/go-utils/pathutil"
testing "google.golang.org/api/testing/v1"
)

// This embedded basic application was created based on the https://github.com/tothszabi/BasicApp repository.
//
//go:embed resources/simple-fallback-bitrise-app.apk
var emptyAndroidApp []byte

// ConfigsModel ...
type ConfigsModel struct {
// api
Expand Down Expand Up @@ -134,10 +143,18 @@ func (configs *ConfigsModel) validate() error {
}

if strings.TrimSpace(configs.AppPath) == "" {
return fmt.Errorf("- AppPath: required variable is not present")
}
if _, err := os.Stat(configs.AppPath); err != nil {
return fmt.Errorf("- AppPath: failed to get file info, error: %s", err)
log.Warnf("Warning: Using embedded Android application as AppPath value is empty")

path, err := pathutil.NormalizedOSTempDirPath("")
if err != nil {
return fmt.Errorf("- AppPath: failed to create temporary directory for embedded application")
}
appPath := filepath.Join(path, "app.apk")
if err = fileutil.WriteBytesToFile(appPath, emptyAndroidApp); err != nil {
return fmt.Errorf("- AppPath: failed to write embedded application to the temporary directory")
}

configs.AppPath = appPath
}

if configs.TestType == testTypeInstrumentation {
Expand Down
26 changes: 9 additions & 17 deletions maintenance/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ screenDensity: 320
screenX: 1600
screenY: 2560
supportedAbis[0]: x86
supportedVersionIds[0]: 19
supportedVersionIds[1]: 21
supportedVersionIds[2]: 22
tags[0]: deprecated=19
supportedVersionIds[0]: 21
supportedVersionIds[1]: 22
---
brand: Google
codename: Nexus4
Expand All @@ -219,10 +217,8 @@ screenDensity: 320
screenX: 768
screenY: 1280
supportedAbis[0]: x86
supportedVersionIds[0]: 19
supportedVersionIds[1]: 21
supportedVersionIds[2]: 22
tags[0]: deprecated=19
supportedVersionIds[0]: 21
supportedVersionIds[1]: 22
---
brand: Google
codename: Nexus5
Expand All @@ -237,11 +233,9 @@ screenY: 1920
supportedAbis[0]: x86
supportedAbis[1]: 23:armeabi
supportedAbis[2]: 23:armeabi-v7a
supportedVersionIds[0]: 19
supportedVersionIds[1]: 21
supportedVersionIds[2]: 22
supportedVersionIds[3]: 23
tags[0]: deprecated=19
supportedVersionIds[0]: 21
supportedVersionIds[1]: 22
supportedVersionIds[2]: 23
---
brand: Google
codename: Nexus5X
Expand Down Expand Up @@ -328,10 +322,8 @@ screenDensity: 213
screenX: 800
screenY: 1280
supportedAbis[0]: x86
supportedVersionIds[0]: 19
supportedVersionIds[1]: 21
supportedVersionIds[2]: 22
tags[0]: deprecated=19
supportedVersionIds[0]: 21
supportedVersionIds[1]: 22
---
brand: Generic
codename: Nexus7_clone_16_9
Expand Down
Binary file added resources/simple-fallback-bitrise-app.apk
Binary file not shown.
3 changes: 2 additions & 1 deletion step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ inputs:
description: |
The path to the app to test (APK or AAB). By default `android-build` and `android-build-for-ui-testing` Steps export the `BITRISE_APK_PATH` Env Var, so you won't need to change this input.
Can specify an APK (`$BITRISE_APK_PATH`) or AAB (Android App Bundle) as input (`$BITRISE_AAB_PATH`).
is_required: true
If nothing is specified then the Step will use a default empty Application APK. This will help the library instrumentation tests as it can be used as a shell where the tests will be running.
- test_devices: "NexusLowRes,24,en,portrait"
opts:
title: "Test devices"
Expand Down

0 comments on commit cdd9f62

Please sign in to comment.