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

Add process based plugins to Smithy build #1672

Merged
merged 3 commits into from
Mar 16, 2023
Merged

Add process based plugins to Smithy build #1672

merged 3 commits into from
Mar 16, 2023

Conversation

mtdowling
Copy link
Member

@mtdowling mtdowling commented Mar 11, 2023

This commit adds the ability to integrate smithy build with process based plugins so that the Smithy CLI will be able to call other CLI tools through a process based plugin model.

To do this, I've introduced the run plugin which takes a command array containing the program to run and arguments to provide. The plugin will open a process and send the serialized Smithy model to the standard input of the process. The process can then perform its logic and write files in the working directory its called with.

A couple things are still missing here that we should figure out later:

  1. The only way to see the output of a plugin is using --debug in the CLI. Should there be an output to somehow always show it? That will require some kind of hackery in the CLI I think.
  2. There is no way currently to indicate the process is "serial" like how other Smithy Build plugins can. Serial indicates that a plugin requires some kind of global locking (like file locks) and can't be run in parallel with other plugins.

In addition to adding the run plugin, you can also apply the same plugin multiple times in a single projectiony by giving it a custom artifact name using the "plugin-name::artifact-name" syntax.

Example:

{
    "version": "1.0",
    "projections": {
        "source": {
            "plugins": {
                "run::hello": {
                    "command": ["hello.sh", "--arg", "arg-value"]
                }
            }
        }
    }
}

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from a team as a code owner March 11, 2023 01:12
@mtdowling mtdowling force-pushed the run-plugin branch 6 times, most recently from c598d38 to 8508f4a Compare March 12, 2023 04:44
This commit adds the ability to integrate smithy build with
process based plugins so that the Smithy CLI will be able to
call other CLI tools through a process based plugin model.

To do this, I've introduced the `run` plugin which takes a
`command` array containing the program to run and arguments
to provide. The plugin will open a process and send the
serialized Smithy model to the standard input of the process.
The process can then perform its logic and write files in the
working directory its called with.

A couple things are still missing here that we should figure
out later:

1. The only way to see the output of a plugin is using --debug
   in the CLI. Should there be an output to somehow always
   show it? That will require some kind of hackery in the CLI
   I think.
2. There is no way currently to indicate the process is "serial"
   like how other Smithy Build plugins can. Serial indicates that
   a plugin requires some kind of global locking (like file locks)
   and can't be run in parallel with other plugins.

In addition to adding the run plugin, you can also apply the same
plugin multiple times in a single projectiony by giving it a custom
artifact name using the "artifact-name via plugin-name" syntax.
Copy link
Contributor

@sugmanue sugmanue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor notes.

Copy link
Contributor

@sugmanue sugmanue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noted some duplication, not sure if those are per-design, i.e., part of the tests. I added a comments anyway.

@mtdowling mtdowling merged commit b2b952a into main Mar 16, 2023
@mtdowling mtdowling deleted the run-plugin branch March 21, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants