/chow

A cross-platform (toy) library for writing testable automation scripts.

Primary LanguageGoMIT LicenseMIT

chow

A framework for writing cross-platform, testable automation scripts.

CircleCI codecov Documentation

chow-logo

Overview

Chow helps you write complex cross-platform build scripts to test & deploy software.

This is a toy project in the spirit of Google Chrome Infrastucture's recipes project.

Installation

go get -u go.kendal.io/chow

Examples

Hello World

The following program calls the "echo" executable on the current PATH to print some text.

package main

import "go.kendal.io/chow"

func main() {
    chow.Main(RunSteps)
}

func RunSteps(r chow.Runner) {
    r.Run("echo hello_world", chow.Step{
        Command: []string{"echo", "Hello, World!"},
    })
}

Testing

Chow tests are written like normal go tests, and can be added alongside other unit tests. Example:

package main

import (
    "testing"
    "go.kendal.io/chow"
)

func TestMain(t *testing.T) {
    cfg := chow.TestConfig{Runnable: RunSteps}
    
    t.Run("default", func(t *testing.T) {
        cfg.Run(chow.TestCase{})
    })
}

Outputs:

[
    {
        "step_name": "echo hello_world",
        "step": {
            "command": [
                "echo",
                "Hello, World!"
            ],
            "outputs": null
        },
        "result": {
            "stdout": "",
            "stderr": "",
            "exit_code": 0
        }
    }
]

This JSON output is referred to as an expectation. Expectations are normally written to disk and checked into your source tree. When the code changes, they be should be regenerated and diffed to ensure that the set of commands exected by the script was modified as expected.

For more examples see the chow-examples project.

For an more in-depth user guide, see the Wiki