taskrunner

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: 0BSD Imports: 16 Imported by: 0

README

Taskrunner

Handling CI-related tasks such as building, testing, and deploying can be automated using bash scripts, but these can quickly get messy. Managing multiple processes, handling cleanup, aborting on failure, adding pretty colored output, and more can lead to complex bash code. That's why Taskrunner was created: a simple, open source library to replace bash scripts with cleaner, more maintainable code written in Go.

Note: API is not stable yet.

Installation
go get github.com/ocelot-cloud/taskrunner
Usage Example

var ( 
    backendDir = "../backend"
    frontendDir = "../frontend"
    acceptanceTestsDir = "../acceptance"
)

func TestFrontend() {
    tr := taskrunner.GetTaskRunner()
	
    tr.Log.Info("Testing Integrated Components")
    defer tr.Cleanup() // shuts down the daemon processes at the end
    tr.ExecuteInDir(backendDir, "go build")
    tr.StartDaemon(backendDir, "./backend")
    tr.WaitUntilPortIsReady("8080")

    tr.ExecuteInDir(frontendDir, "npm install")
    tr.StartDaemon(frontendDir, "npm run serve", "VITE_APP_PROFILE=TEST")
    tr.WaitForWebPageToBeReady("http://localhost:8081/")
    tr.ExecuteInDir(acceptanceTestsDir, cypressCommand, "CYPRESS_PROFILE=TEST")
}

The idea is to write simple functions like this and build a CLI tool, e.g., by using cobra, to call these functions. The final use of the CLI tool might look like this:

go build
./my-task-runner test frontend

This approach helps you create a modern and scalable CI infrastructure.

Contributing

Please read the Community articles for more information on how to contribute to the project and interact with others.

License

This project is licensed under a permissive open source license, the 0BSD License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEnvs []string

Functions

This section is empty.

Types

type Config

type Config struct {
	CleanupOnFailure            bool
	CleanupFunc                 func()
	DefaultEnvironmentVariables []string
	// contains filtered or unexported fields
}

type TaskRunner

type TaskRunner struct {
	Config *Config
	Log    logger
}

func GetTaskRunner

func GetTaskRunner() *TaskRunner

func (*TaskRunner) Cleanup

func (t *TaskRunner) Cleanup()

func (*TaskRunner) Copy

func (t *TaskRunner) Copy(srcPath, destPath string)

func (*TaskRunner) EnableAbortForKeystrokeControlPlusC

func (t *TaskRunner) EnableAbortForKeystrokeControlPlusC()

func (*TaskRunner) Execute

func (t *TaskRunner) Execute(commandStr string, envs ...string)

func (*TaskRunner) ExecuteInDir

func (t *TaskRunner) ExecuteInDir(dir string, commandStr string, envs ...string)

func (*TaskRunner) ExitWithError

func (t *TaskRunner) ExitWithError()

func (*TaskRunner) KillProcesses

func (t *TaskRunner) KillProcesses(processSubStrings []string)

func (*TaskRunner) MakeDir

func (t *TaskRunner) MakeDir(path string)

func (*TaskRunner) Move

func (t *TaskRunner) Move(srcPath, destPath string)

func (*TaskRunner) PromptForContinuation

func (t *TaskRunner) PromptForContinuation(prompt string)

func (*TaskRunner) Remove

func (t *TaskRunner) Remove(paths ...string)

func (*TaskRunner) Rename

func (t *TaskRunner) Rename(srcPath, destPath string)

func (*TaskRunner) ResetCursor

func (t *TaskRunner) ResetCursor()

func (*TaskRunner) StartDaemon

func (t *TaskRunner) StartDaemon(dir, commandStr string, envs ...string)

func (*TaskRunner) WaitForWebPageToBeReady

func (t *TaskRunner) WaitForWebPageToBeReady(targetUrl string)

func (*TaskRunner) WaitUntilPortIsReady

func (t *TaskRunner) WaitUntilPortIsReady(port string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL