Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - plugin system for alternate task executer #620

Closed
sagiegurari opened this issue Dec 31, 2021 · 0 comments
Closed

Feature - plugin system for alternate task executer #620

sagiegurari opened this issue Dec 31, 2021 · 0 comments
Assignees
Milestone

Comments

@sagiegurari
Copy link
Owner

sagiegurari commented Dec 31, 2021

Feature Description

A new plugin system in which cargo-make exposes task meta data and sub task execution capabilities (for example, only execute env setup or conditions).
Users can than setup an alternate executor implemented in duckscript using the meta data/sub execution capabilities.
This would enable to create custom solutions, beyond what cargo-make provides (for example, running a task in a container like requested in #619).

Describe The Solution You'd Like

A task would be able to define an optional plugin for alternate executer.
In which case, cargo-make calls the plugin script with task data and does not execute it on its own

[tasks.mytask]
plugin = "example-executer"
command = "cargo"
args = ["test"]

[plugins.impl.example-executer]
script = '''
# implement logic of task execution here, using task meta data.
echo Running task: ${task.name}
if cm_task_condition ${task.name}
  echo condition passed
  exec --fail-on-error ${task.command} # naturally this is ignoring lots of stuff and just a very simple example
else
  echo condition failed, skipping
end
'''

You could 'switch' implementation using aliases

[plugins.impl.old]
# code here...

[plugins.impl.new]
# code here...

[plugins.aliases]
old = "new" # calling old plugin which get redirected to new

Few capabilities exposed to duckscript plugins come to mind:

  • execute task env setup
  • execute task condition to get true/false
  • execute cargo-make functions on command args
  • execute dependencies

All task meta data would be available via 'task' namespace as duckscript variables to be used by the plugin script, for example
task.name
task.description
task.command
task.args <- list handle
task.script <- list handle
task.env.env_set <- list handle
task.env.env_unset <- list handle
and so on...

Few env vars would be set before calling the plugin (apart of the current task env vars that are already set today such as task name and so on...)
CARGO_MAKE_TASK_PLUGIN_NAME - the value defined in the task
CARGO_MAKE_TASK_PLUGIN_IMPL - the actual plugin name (after aliases)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant