Skip to content

Reworked Configuration #3

@carsonoid

Description

@carsonoid

Introduction

As discussed at the last PLUG I wanted to propose a more flexible config file structure. NOTE: I have no opinion on the exact format for the config (YAML, JSON, etc), My example below is simply in JSON for readability and syntax highlighting. It may not be a perfect format but adds a lot of functionality and flexibility while maintaining usability. Let me know what you think!

Sample Configuration

{
    "ARBITRARY_NAME_1" : {
        "files"   : ["LIST", "OF", "GLOB", "PATTERNS"],    // Required
        "exclude" : ["LIST", "OF", "GLOB", "PATTERNS"],
        "dir"     : "/path/to/working/dir",
        "steps"   : [                                      // At least one entry required. Run consecutively
                        {
                            "name"          : "STEP_NAME", // Required
                            "run"           : "COMMAND",   // Required
                            "is_daemon"     : false,
                            "enabled"       : true,
                            "on_success"    : "COMMAND",
                            "on_error"      : "COMMAND",
                            "error_status"  : [],
                            "ignore_status" : []
                        },
                        {
                            "name"          : "STEP_NAME",   // Required
                            "run"           : "COMMAND",     // Required
                            "is_daemon"     : true,
                            "enabled"       : true,
                            "on_success"    : "COMMAND",
                            "on_error"      : "COMMAND",
                            "ignore_status" : []
                        }
        ]
    }
}

Explanation

The configuration above would allow for as many filesets as you want to be defined in the config file. Each with a different set of steps to execute on file change. It also allows for a arbitrary number of steps to be defined per each fileset. So rather than hard-coding the step names we can leave that up to the config. Some filesets may have a full build->test->exec set of steps. Others may just need a build step alone. While more complicated projects can have build->test->deploy->test->exec or any imaginable set of steps when files change. Each step is only run if the run previous command succeeds or returns a code matched in the ignore_status directive.

fileset directives:

  • files : A list of globs defining files to watch
  • exclude : A list of globs defining files to exclude. NOTE: No include directive is needed and would be redundant
  • dir : Path to the relative directory to match the files and exclude patterns against. (Defaults to CWD?)
  • steps : A ordered list of steps to take when any matched files are changed.

step directives

  • name : Arbitrary step name for display purposes. NOTE: This must be a property of the step as defined in JSON as if it were the key to a dictionary item it would not maintain it's order.
  • run : Command to run for step
  • is_daemon : whether the command should be treated as a daemon. i.e. killed and restarted in bg
  • enabled : Whether command is enabled
  • on_success : Command to run if run directive succeeds.
  • on_error : Command to run if run directive has error status.
  • ignore_status : list of status codes that don't count towards on\_error Defaults to anything non-zero

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions