Skip to content

Commit

Permalink
error message typo fixed
Browse files Browse the repository at this point in the history
string coloring added
  • Loading branch information
koral-- committed Sep 6, 2017
1 parent 626fc15 commit abd1992
Show file tree
Hide file tree
Showing 36 changed files with 7,438 additions and 17 deletions.
31 changes: 31 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Godeps/Readme

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package_name: github.com/DroidsOnRoids/bitrise-step-stf-connect
25 changes: 15 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"
"fmt"
"errors"
"github.com/bitrise-io/go-utils/colorstring"
)

type configsModel struct {
Expand Down Expand Up @@ -46,39 +47,43 @@ func main() {
configs := createConfigsModelFromEnvs()
configs.dump()
if err := configs.validate(); err != nil {
log.Fatalf("Could not validate config, error: %s", err)
logError("Could not validate config, error: %s", err)
}

serials, err := getSerials(configs)
if err != nil {
log.Fatalf("Could not get device serials, error: %s", err)
logError("Could not get device serials, error: %s", err)
}
homeDir, err := getHomeDir()
if err != nil {
log.Fatalf("Could not determine current user home directory, error: %s", err)
logError("Could not determine current user home directory, error: %s", err)
}

if err := setAdbKeys(configs, homeDir); err != nil {
log.Fatalf("Could not set ADB keys, error: %s", err)
logError("Could not set ADB keys, error: %s", err)
}
if err := exportArrayWithEnvman("STF_DEVICE_SERIAL_LIST", serials); err != nil {
log.Fatalf("Could export device serials with envman, error: %s", err)
logError("Could export device serials with envman, error: %s", err)
}

for _, serial := range serials {
if err := addDeviceUnderControl(configs, serial); err != nil {
log.Fatalf("Could add device under control, error: %s", err)
logError("Could add device under control, error: %s", err)
}
remoteConnectURL, err := getRemoteConnectURL(configs, serial)
if err != nil {
log.Fatalf("Could not get remote connect URL to device %s, error: %s", serial, err)
logError("Could not get remote connect URL to device %s, error: %s", serial, err)
}
if err := connectToAdb(remoteConnectURL); err != nil {
log.Fatalf("Could not connect device %s to ADB, error: %s", serial, err)
logError("Could not connect device %s to ADB, error: %s", serial, err)
}
}
}

func logError(format string, v ...interface{}){
log.Fatalf(colorstring.Red(format), v)
}

func createConfigsModelFromEnvs() configsModel {
return configsModel{
stfHostURL: os.Getenv("stf_host_url"),
Expand Down Expand Up @@ -107,7 +112,7 @@ func parseIntSafely(limit string) int {
}

func (configs configsModel) dump() {
log.Println("Config:")
log.Println(colorstring.Blue("Config:"))
log.Printf("STF host: %s", configs.stfHostURL)
log.Printf("Device filter: %s", configs.deviceFilter)
log.Printf("Device number limit: %d", configs.deviceNumberLimit)
Expand Down Expand Up @@ -159,7 +164,7 @@ func getHomeDir() (string, error) {
}

func connectToAdb(remoteConnectURL string) error {
log.Printf("Connecting ADB to %s", remoteConnectURL)
log.Printf(colorstring.Blue("Connecting ADB to %s"), remoteConnectURL)
command := exec.Command(getAdbPath(), "connect", remoteConnectURL)
output, err := command.CombinedOutput()
if err != nil {
Expand Down
19 changes: 12 additions & 7 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ description: |
To use this step, you need an access to running [Open STF](https://openstf.io/) instance with at least 1 device connected.
[Access token](https://github.com/openstf/stf/blob/master/doc/API.md#authentication) and ADB keys has to be set up using STF web UI.
Typical workflow:
1. App compilation e.g. using Gradle Runner step
2. Open STF Connect (this step)
3. Android instrumention and/or UI tests e.g. using Gradle Unit Test step
4. Open STF Disconnect step with `is_always_run: true` (to stop using remote devices)
1. App compilation e.g. using Gradle Runner step.
2. Open STF Connect (this step).
3. Android instrumention and/or UI tests e.g. using Gradle Unit Test step.
4. Open STF Disconnect step with `is_always_run: true` (to stop using remote devices).
website: https://github.com/DroidsOnRoids/bitrise-step-openstf-connect
source_code_url: https://github.com/DroidsOnRoids/bitrise-step-openstf-connect
support_url: https://github.com/DroidsOnRoids/bitrise-step-openstf-connect/issues
Expand Down Expand Up @@ -72,7 +77,7 @@ inputs:
title: Device number limit
description: |
Maximum number of devices to be used. 0 and empty mean unlimited.
If there is more available devices (after applying filter if any), only amount up to this number will be used. Devices will be chosen randomly.
If there are more available devices (after applying filter if any), only amount up to this number will be used. Devices will be chosen randomly.
is_required: false
is_expand: true

Expand All @@ -81,7 +86,7 @@ inputs:
title: Private ADB key
description: |
Private ADB key to be used when debugging on STF devices. If not empty value will be saved to `~/.android/adbkey`.
Private ADB key used during build has to be registered in STF under `Settings->Keys->ADB Keys`.
Key used during build has to be registered in STF under `Settings->Keys->ADB Keys`.
You have to either provide value here or modify `~/.android/adbkey` before this step.
Otherwise devices will be listed as unauthorized and cannot be used during build.
is_required: false
Expand All @@ -92,7 +97,7 @@ inputs:
title: Public ADB key
description: |
Public ADB key to be used when debugging on STF devices. If not empty value will be saved to `~/.android/adbkey.pub`.
Public ADB key used during build has to be registered in STF under `Settings->Keys->ADB Keys`.
Key used during build has to be registered in STF under `Settings->Keys->ADB Keys`.
You have to either provide value here or modify `~/.android/adbkey.pub` before this step.
Otherwise devices will be listed as unauthorized and cannot be used during build.
is_required: false
Expand Down
22 changes: 22 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/colorstring/colorstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/davecgh/go-spew/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit abd1992

Please sign in to comment.