From cdd9f624138fcbccca5b855c5aecd151d96cca01 Mon Sep 17 00:00:00 2001 From: Szabolcs Toth <54896607+tothszabi@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:45:15 +0000 Subject: [PATCH] [CI-447] Add fallback apk (#85) * Add fallback apk * Update device list for testing --- README.md | 4 ++-- config.go | 25 +++++++++++++++++---- maintenance/maintenance_test.go | 26 ++++++++-------------- resources/simple-fallback-bitrise-app.apk | Bin 0 -> 8883 bytes step.yml | 3 ++- 5 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 resources/simple-fallback-bitrise-app.apk diff --git a/README.md b/README.md index fb7a1ac..be02c59 100644 --- a/README.md +++ b/README.md @@ -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). | | | diff --git a/config.go b/config.go index f8f7721..fa41183 100644 --- a/config.go +++ b/config.go @@ -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 @@ -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 { diff --git a/maintenance/maintenance_test.go b/maintenance/maintenance_test.go index d184bab..6820f45 100644 --- a/maintenance/maintenance_test.go +++ b/maintenance/maintenance_test.go @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/resources/simple-fallback-bitrise-app.apk b/resources/simple-fallback-bitrise-app.apk new file mode 100644 index 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S?<6QZT-T6qd{l!aq#BMa;oBuxJ*T_%nMUj ztzVAXM$+h6xrrJvsk-`D#Vf|q88Xi!flQZxOONPH*nL!>;QSw-NDv_iK>JZ=)C^PK zC2e4|{P77%+N2%3`fS2M%j8BvNm$#ky*D;(hxM7)9gKPIMQm*9>Bt^&z7wHWjm@vD z?Acr#yU)DsmQN}E_{4pmjauBNi~D}Kwt8aR5|0qLG)fV=4K$JyP-ga>>DsI7X_vq8e5!br-iFT~DtO=zQnMIF~9w#*)# zugxv#>#OH^NP(wzi{3e)IHy3LbOlmtTUBX_gXIZScKs}21gmh7QI%3}Jm*m$p>K{E zu^-lC;}ATbHg85)dQ&Jcr-FQy&hg6VeCZwi5$npk`Io6$w5T#gnI3&ZLI+ESgVt}_G|@*+Rnw2DZ(Hw|1RRun z)Si)N=52Gk$p&Ho?w&up>Ob986-Vm_0JP;)G=b;KM!9kgS8qUevd>z>?F@Spvcsz{ zU8mHJpn;C04DTt~Qh zr^;$(cL-mcj?Q8_72uwry>w$>@Uzcp{y`x5x7p^u`lo>7uQ~4H|MePD@Z#{B$Nxz1 zsPudPj{ALo3Ic#2Xs!4+Uf|;m9C!ZxYQP>edHnKR{gV54F0x-z0N{^zB=?)c?D%Mp z`#pY2r}@u-j*`DY{ow^UE`8j_{!98T=)L@>G-z=@E`Hqf_Dg(>^f&R}3~`z&xZse$ Q`z-jQ25mWEu*0YS09X~q!2kdN literal 0 HcmV?d00001 diff --git a/step.yml b/step.yml index dd8e99c..2d2e789 100755 --- a/step.yml +++ b/step.yml @@ -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"