Skip to content

Commit

Permalink
Merge pull request #16 from Genymobile/dev/support_gmsaas_version
Browse files Browse the repository at this point in the history
Add new paramater gmsaas_version and force default version to 1.9.0
  • Loading branch information
thomascarpentier committed May 30, 2024
2 parents e67e21f + a9dc040 commit 8d3fd51
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ app:
envs:
# If you want to share this step into a StepLib
- BITRISE_STEP_ID: genymotion-cloud-saas-start
- BITRISE_STEP_VERSION: "0.1.5"
- BITRISE_STEP_VERSION: "0.1.6"
- BITRISE_STEP_GIT_CLONE_URL: https://github.com/genymobile/bitrise-step-genymotion-cloud-saas-start.git
- MY_STEPLIB_REPO_FORK_GIT_URL: [email protected]:Genymobile/bitrise-steplib.git
# Define these in your .bitrise.secrets.yml
Expand Down
30 changes: 22 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,34 @@ type Config struct {

GMCloudSaaSRecipeUUID string `env:"recipe_uuid,required"`
GMCloudSaaSAdbSerialPort string `env:"adb_serial_port"`
GMCloudSaaSGmsaasVersion string `env:"gmsaas_version"`
}

// install gmsaas if not installed.
func ensureGMSAASisInstalled() error {
func ensureGMSAASisInstalled(version string) error {
path, err := exec.LookPath("gmsaas")
if err != nil {
log.Infof("Installing gmsaas ...")
cmd := command.New("pip3", "install", "gmsaas")
if out, err := cmd.RunAndReturnTrimmedCombinedOutput(); err != nil {
return fmt.Errorf("%s failed, error: %s | output: %s", cmd.PrintableCommandArgs(), err, out)
log.Infof("Installing gmsaas...")

var installCmd *exec.Cmd
if version != "" {
installCmd = exec.Command("pip3", "install", "gmsaas=="+version)
} else {
installCmd = exec.Command("pip3", "install", "gmsaas")
}

if out, err := installCmd.CombinedOutput(); err != nil {
return fmt.Errorf("%s failed, error: %s | output: %s", installCmd.Args, err, out)
}
log.Infof("gmsaas has been installed.")

if version != "" {
log.Infof("gmsaas %s has been installed.", version)
} else {
log.Infof("gmsaas has been installed.")
}

} else {
log.Infof("gmsaas is already installed : %s", path)
log.Infof("gmsaas is already installed: %s", path)
}

// Set Custom user agent to improve customer support
Expand Down Expand Up @@ -172,7 +186,7 @@ func main() {
}
stepconf.Print(c)

if err := ensureGMSAASisInstalled(); err != nil {
if err := ensureGMSAASisInstalled(c.GMCloudSaaSGmsaasVersion); err != nil {
abortf("%s", err)
}
configureAndroidSDKPath()
Expand Down
9 changes: 9 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ inputs:
For example:
`4321,4322,4323`
- gmsaas_version: "1.9.0"
opts:
title: gmsaas version
summary: ""
description: |-
Install a specific version of gmsaas, per default it will install the latest gmsaas compatible : 1.9.0
outputs:
- GMCLOUD_SAAS_INSTANCE_UUID:
opts:
Expand Down

0 comments on commit 8d3fd51

Please sign in to comment.