Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move local step activator from CLI to stepman #958

Merged
merged 8 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions cli/step_activator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/bitrise-io/bitrise/tools"
"github.com/bitrise-io/go-utils/command"
"github.com/bitrise-io/go-utils/command/git"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-io/go-utils/pointers"
"github.com/bitrise-io/stepman/activator"
stepmanModels "github.com/bitrise-io/stepman/models"
"github.com/bitrise-io/stepman/stepid"
)
Expand All @@ -28,45 +28,30 @@ func newStepActivator() stepActivator {
func (a stepActivator) activateStep(
stepIDData stepid.CanonicalID,
buildRunResults *models.BuildRunResultsModel,
stepDir string,
workDir string,
stepDir string, // $TMPDIR/bitrise/step_src
workDir string, // $TMPDIR/bitrise
workflowStep *stepmanModels.StepModel,
stepInfoPtr *stepmanModels.StepInfoModel,
isSteplibOfflineMode bool,
) (stepYMLPth string, origStepYMLPth string, err error) {
stepYMLPth = filepath.Join(workDir, "current_step.yml")
stepmanLogger := log.NewLogger(log.GetGlobalLoggerOpts())

if stepIDData.SteplibSource == "path" {
log.Debugf("[BITRISE_CLI] - Local step found: (path:%s)", stepIDData.IDorURI)
stepAbsLocalPth, err := pathutil.AbsPath(stepIDData.IDorURI)
if err != nil {
return "", "", err
}

exist, err := pathutil.IsDirExists(stepAbsLocalPth)
if err != nil {
return "", "", fmt.Errorf("failed to activate local step: failed to check if a directory exists at %s: %w", stepAbsLocalPth, err)
} else if !exist {
return "", "", fmt.Errorf("failed to activate local step: the provided directory doesn't exist: %s", stepAbsLocalPth)
}

log.Debug("stepAbsLocalPth:", stepAbsLocalPth, "|stepDir:", stepDir)

origStepYMLPth = filepath.Join(stepAbsLocalPth, "step.yml")
exist, err = pathutil.IsPathExists(origStepYMLPth)
activatedStep, err := activator.ActivatePathRefStep(
stepmanLogger,
stepIDData,
stepDir,
workDir,
)
if err != nil {
return "", "", fmt.Errorf("failed to activate local step: failed to check if step.yml exists at %s: %w", origStepYMLPth, err)
} else if !exist {
return "", "", fmt.Errorf("failed to activate local step: step.yml doesn't exist at %s", origStepYMLPth)
}

if err := command.CopyFile(origStepYMLPth, stepYMLPth); err != nil {
return "", "", err
return "", "", fmt.Errorf("activate local step: %w", err)
}

if err := command.CopyDir(stepAbsLocalPth, stepDir, true); err != nil {
return "", "", 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)
repo, err := git.New(stepDir)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bitrise-io/go-utils v1.0.11
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.21
github.com/bitrise-io/goinp v0.0.0-20240103152431-054ed78518ef
github.com/bitrise-io/stepman v0.0.0-20240530152555-8c02c2799166
github.com/bitrise-io/stepman v0.0.0-20240625190612-34c5f93d1604
github.com/gofrs/uuid v4.3.1+incompatible
github.com/hashicorp/go-version v1.4.0
github.com/ryanuber/go-glob v1.0.0
Expand Down
12 changes: 2 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.21 h1:iwNnwOGg8VP8eqhse68Fxt5ZnfE
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.21/go.mod h1:Laih4ji980SQkRgdnMCH0g4u2GZI/5nnbqmYT9UfKFQ=
github.com/bitrise-io/goinp v0.0.0-20240103152431-054ed78518ef h1:R5FOa8RHjqZwMN9g1FQ8W7nXxQAG7iwq1Cw+mUk5S9A=
github.com/bitrise-io/goinp v0.0.0-20240103152431-054ed78518ef/go.mod h1:27ldH2bkCdYN5CEJ6x92EK+gkd5EcDBkA7dMrSKQFYU=
github.com/bitrise-io/stepman v0.0.0-20240514090619-db15d602b74b h1:wra4n0rZ4l4PhuFXRB5fz6FmQqD842B8ElsNSuw8xLg=
github.com/bitrise-io/stepman v0.0.0-20240514090619-db15d602b74b/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/bitrise-io/stepman v0.0.0-20240517133523-36bc3fae02b4 h1:l3JbKBYcMXoExH57iK7mNwfgBxuqAPjcuv9RurVZvy0=
github.com/bitrise-io/stepman v0.0.0-20240517133523-36bc3fae02b4/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/bitrise-io/stepman v0.0.0-20240517141153-85fd809d8e91 h1:xLOoxQ9lIA293bvGUCOe4ifBjPscfBqoaj24x/+hbkk=
github.com/bitrise-io/stepman v0.0.0-20240517141153-85fd809d8e91/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/bitrise-io/stepman v0.0.0-20240517143505-dd9c9e302775 h1:bPbCyYxSDspZ/NG6PuPwTanNQDvhwC2xQmr/kpM3+SY=
github.com/bitrise-io/stepman v0.0.0-20240517143505-dd9c9e302775/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/bitrise-io/stepman v0.0.0-20240530152555-8c02c2799166 h1:bqcwVelwkx/UKSfoNfiAz5gygH1ZEmmz5CIgupXQFtE=
github.com/bitrise-io/stepman v0.0.0-20240530152555-8c02c2799166/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/bitrise-io/stepman v0.0.0-20240625190612-34c5f93d1604 h1:ssvlwaczX2ANHGvMziuVN4v3UnbOTjg+PobD79lzMPA=
github.com/bitrise-io/stepman v0.0.0-20240625190612-34c5f93d1604/go.mod h1:netRLDQD95IzWZbzmn7CBolzNqH1tErRKS31BrZKt9s=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

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

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ github.com/bitrise-io/go-utils/v2/retryhttp
# github.com/bitrise-io/goinp v0.0.0-20240103152431-054ed78518ef
## explicit; go 1.18
github.com/bitrise-io/goinp/goinp
# github.com/bitrise-io/stepman v0.0.0-20240530152555-8c02c2799166
# github.com/bitrise-io/stepman v0.0.0-20240625190612-34c5f93d1604
## explicit; go 1.18
github.com/bitrise-io/stepman/activator
github.com/bitrise-io/stepman/cli
github.com/bitrise-io/stepman/models
github.com/bitrise-io/stepman/preload
Expand Down