captainhookphp / captainhook

CaptainHook is a very flexible git hook manager for software developers that makes sharing git hooks with your team a breeze.
http://captainhook.info
MIT License
1.01k stars 87 forks source link

[Feature] Parallel execution of actions #249

Open cegento opened 6 months ago

cegento commented 6 months ago

Is it possible to add a feature to be able to have parallel executions?

One Example:

"pre-commit": {
    "enabled": true,
    "actions": [
        {
            "action": "Action1"
        },
        {
            "action": "\\Parallel\\Actions",
            "actions": [
                {
                    "action": "Action2"

                },
                {
                    "action": "Action3"
                }
            ]
        },
        {
            "action": "Action4"
        }
    ]
},

Execute Action1
                           ↓ (wait to finnish)
Execute Action2 and Action3 in parallel
                           ↓ (wait to finnish)
Execute Action4
sebastianfeldmann commented 6 months ago

Nothing is impossible :)

Since there is currently no way to parallel execution other than creating sub processes I'm not actively looking into it right now.

The idea would be to allow to change the default or configure it for every action separately.

"config": {
    "run-async": true
}
"pre-commit": {
    "enabled": true,
    "actions": [
        {
            "action": "some command"
            "options": {
                "some": value
            },
            "config": {
                "run-async": false
             }
        },

Pretty similar to how the go version of the Cap'n handles it.

As I said I'm not working on it right now. I don't think you should do things that take that long that parallel execution makes a difference anyway. But, that does not mean I would not be open to discuss the feature if somebody else want to look into it ;)