Skip to content
 
 

Repository files navigation

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.

Installation

go get github.com/quollix/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.Cmd().Dir(backendDir).Run("go build")
    tr.Cmd().Dir(backendDir).AsDaemon("backend").Run("./backend")
    tr.WaitUntilPortIsReady("8080")

    tr.Cmd().Dir(frontendDir).Run("npm install")
    tr.Cmd().Dir(frontendDir).Env("VITE_APP_PROFILE", "TEST").AsDaemon("frontend").Run("npm run serve")
    tr.WaitForWebPageToBeReady("http://localhost:8081/")
    tr.Cmd().Dir(acceptanceTestsDir).Env("CYPRESS_PROFILE", "TEST").Run(cypressCommand)

    output := tr.Cmd().AllowFail().Run("go test ./...").Output()
    tr.Log.Info("test output:\n%s", output)
}

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 the GNU Lesser General Public License v3.0. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages