Skip to content

Commit

Permalink
Clean up activator (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofalvai authored Jul 5, 2024
1 parent bb0846b commit 016883c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
10 changes: 2 additions & 8 deletions cli/run_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (r WorkflowRunner) activateStep(
}

activator := newStepActivator()
stepYMLPth, origStepYMLPth, didStepLibUpdate, err := activator.activateStep(stepIDData, isStepLibUpdated, stepDir, configs.BitriseWorkDirPath, &stepInfoPtr, isStepLibOfflineMode)
stepYMLPth, didStepLibUpdate, err := activator.activateStep(stepIDData, isStepLibUpdated, stepDir, configs.BitriseWorkDirPath, &stepInfoPtr, isStepLibOfflineMode)
if didStepLibUpdate {
buildRunResults.StepmanUpdates[stepIDData.SteplibSource]++
}
Expand All @@ -324,13 +324,7 @@ func (r WorkflowRunner) activateStep(
specStep, err := bitrise.ReadSpecStep(stepYMLPth)
log.Debugf("Spec read from YML: %#v", specStep)
if err != nil {
ymlPth := stepYMLPth
if origStepYMLPth != "" {
// in case of local step (path:./) we use the original step definition path,
// instead of the activated step's one.
ymlPth = origStepYMLPth
}
err = fmt.Errorf("failed to parse step definition (%s): %s", ymlPth, err)
err = fmt.Errorf("parse step.yml of '%s': %s", stepIDData.IDorURI, err)
return newActivateStepResult(stepmanModels.StepModel{}, stepInfoPtr, stepIDData, stepDir, err)
}

Expand Down
15 changes: 6 additions & 9 deletions cli/step_activator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (a stepActivator) activateStep(
workDir string, // $TMPDIR/bitrise
stepInfoPtr *stepmanModels.StepInfoModel,
isSteplibOfflineMode bool,
) (stepYMLPth string, origStepYMLPth string, didStepLibUpdate bool, err error) {
) (stepYMLPth string, didStepLibUpdate bool, err error) {
stepmanLogger := log.NewLogger(log.GetGlobalLoggerOpts())

if stepIDData.SteplibSource == "path" {
Expand All @@ -36,11 +36,10 @@ func (a stepActivator) activateStep(
workDir,
)
if err != nil {
return "", "", false, fmt.Errorf("activate local step: %w", err)
return "", false, fmt.Errorf("activate local step: %w", err)
}

stepYMLPth = activatedStep.StepYMLPath
origStepYMLPth = activatedStep.OrigStepYMLPath
} else if stepIDData.SteplibSource == "git" {
log.Debugf("[BITRISE_CLI] - Remote step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)

Expand All @@ -51,11 +50,10 @@ func (a stepActivator) activateStep(
workDir,
)
if err != nil {
return "", "", false, fmt.Errorf("activate git step reference: %w", err)
return "", false, fmt.Errorf("activate git step reference: %w", err)
}

stepYMLPth = activatedStep.StepYMLPath
origStepYMLPth = activatedStep.OrigStepYMLPath
} else if stepIDData.SteplibSource != "" {
activatedStep, err := activator.ActivateSteplibRefStep(
stepmanLogger,
Expand All @@ -68,14 +66,13 @@ func (a stepActivator) activateStep(
)
didStepLibUpdate = activatedStep.DidStepLibUpdate
if err != nil {
return "", "", didStepLibUpdate, fmt.Errorf("activate steplib step: %w", err)
return "", didStepLibUpdate, fmt.Errorf("activate steplib step: %w", err)
}

stepYMLPth = activatedStep.StepYMLPath
origStepYMLPth = activatedStep.OrigStepYMLPath
} else {
return "", "", didStepLibUpdate, fmt.Errorf("invalid stepIDData: no SteplibSource or LocalPath defined (%v)", stepIDData)
return "", didStepLibUpdate, fmt.Errorf("invalid stepIDData: no SteplibSource or LocalPath defined (%v)", stepIDData)
}

return stepYMLPth, origStepYMLPth, didStepLibUpdate, nil
return stepYMLPth, didStepLibUpdate, nil
}

0 comments on commit 016883c

Please sign in to comment.