Skip to content

Commit

Permalink
Check if step uses locked version and update Steplib if so. (#704)
Browse files Browse the repository at this point in the history
* Check if step uses locked version and update Steplib if so.

* Clean up version parsing.

* dep update

* Fixing stepman test case, failed due to testing a stepman version installed, not the current one.
  • Loading branch information
lpusok authored Feb 25, 2020
1 parent f9f500f commit c65c9e8
Show file tree
Hide file tree
Showing 55 changed files with 1,094 additions and 187 deletions.
20 changes: 10 additions & 10 deletions Gopkg.lock

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

17 changes: 14 additions & 3 deletions cli/run_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,25 @@ func activateStepLibStep(stepIDData models.StepIDData, destination, stepYMLCopyP
log.Debugf("[BITRISE_CLI] - Steplib (%s) step (id:%s) (version:%s) found, activating step", stepIDData.SteplibSource, stepIDData.IDorURI, stepIDData.Version)
if err := stepman.SetupLibrary(stepIDData.SteplibSource); err != nil {
return stepmanModels.StepInfoModel{}, false, err
}

versionConstraint, err := stepmanModels.ParseRequiredVersion(stepIDData.Version)
if err != nil {
return stepmanModels.StepInfoModel{}, false,
fmt.Errorf("activating step (%s) from source (%s) failed, invalid version specified: %s", stepIDData.IDorURI, stepIDData.SteplibSource, err)
}
if versionConstraint.VersionLockType == stepmanModels.InvalidVersionConstraint {
return stepmanModels.StepInfoModel{}, false,
fmt.Errorf("activating step (%s) from source (%s) failed, version constraint is invalid", stepIDData.IDorURI, stepIDData.SteplibSource)
}

isLatestVersionOfStep := (stepIDData.Version == "")
if isLatestVersionOfStep && !isStepLibUpdated {
isStepLibUpdateNeeded := (versionConstraint.VersionLockType == stepmanModels.Latest) ||
(versionConstraint.VersionLockType == stepmanModels.MinorLocked) ||
(versionConstraint.VersionLockType == stepmanModels.MajorLocked)
if !isStepLibUpdated && isStepLibUpdateNeeded {
log.Infof("Step uses latest version -- Updating StepLib ...")
if _, err := stepman.UpdateLibrary(stepIDData.SteplibSource); err != nil {
log.Warnf("Step uses latest version, but failed to update StepLib, err: %s", err)
log.Warnf("Step version constraint is latest or version locked, but failed to update StepLib, err: %s", err)
} else {
didStepLibUpdate = true
}
Expand Down
4 changes: 2 additions & 2 deletions tools/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func TestStepmanJSONStepLibStepInfo(t *testing.T) {
require.NotEqual(t, "", outStr)

// Invalid params -- Err should empty, output filled
outStr, err = StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "2")
require.NotEqual(t, nil, err)
outStr, err = StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "2.x")
require.Error(t, err)
require.Equal(t, "", outStr)
}

Expand Down

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

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

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

Loading

0 comments on commit c65c9e8

Please sign in to comment.