-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
131 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ import ( | |
func TestExample_Git(t *testing.T) { | ||
p := pipeline.NewPipeline() | ||
p.WithSteps( | ||
pipeline.ToStep("clone repository", CloneGitRepository(), pipeline.Not(DirExists("my-repo"))), | ||
pipeline.NewStep("checkout branch", CheckoutBranch()), | ||
pipeline.NewStep("pull", Pull()).WithResultHandler(logSuccess), | ||
CloneGitRepository(), | ||
CheckoutBranch(), | ||
Pull().WithResultHandler(logSuccess), | ||
) | ||
result := p.Run() | ||
if !result.IsSuccessful() { | ||
|
@@ -27,29 +27,29 @@ func TestExample_Git(t *testing.T) { | |
} | ||
|
||
func logSuccess(_ context.Context, result pipeline.Result) error { | ||
log.Println("handler called") | ||
log.Println("handler called", result.Name()) | ||
return result.Err() | ||
} | ||
|
||
func CloneGitRepository() pipeline.ActionFunc { | ||
return func(_ context.Context) pipeline.Result { | ||
func CloneGitRepository() pipeline.Step { | ||
return pipeline.ToStep("clone repository", func(_ context.Context) error { | ||
err := execGitCommand("clone", "[email protected]/ccremer/go-command-pipeline") | ||
return pipeline.NewResultWithError("clone repository", err) | ||
} | ||
return err | ||
}, pipeline.Not(DirExists("my-repo"))) | ||
} | ||
|
||
func Pull() pipeline.ActionFunc { | ||
return func(_ context.Context) pipeline.Result { | ||
func Pull() pipeline.Step { | ||
return pipeline.NewStepFromFunc("pull", func(_ context.Context) error { | ||
err := execGitCommand("pull") | ||
return pipeline.NewResultWithError("pull", err) | ||
} | ||
return err | ||
}) | ||
} | ||
|
||
func CheckoutBranch() pipeline.ActionFunc { | ||
return func(_ context.Context) pipeline.Result { | ||
func CheckoutBranch() pipeline.Step { | ||
return pipeline.NewStepFromFunc("checkout branch", func(_ context.Context) error { | ||
err := execGitCommand("checkout", "master") | ||
return pipeline.NewResultWithError("checkout branch", err) | ||
} | ||
return err | ||
}) | ||
} | ||
|
||
func execGitCommand(args ...string) error { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.