-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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 watchexclude: A list of globs defining files to exclude. NOTE: Noincludedirective is needed and would be redundantdir: Path to the relative directory to match thefilesandexcludepatterns 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 stepis_daemon: whether the command should be treated as a daemon. i.e. killed and restarted in bgenabled: Whether command is enabledon_success: Command to run ifrundirective succeeds.on_error: Command to run ifrundirective has error status.ignore_status: list of status codes that don't count towardson\_errorDefaults to anything non-zero