Shopify / function-runner-javascript

Apache License 2.0
7 stars 2 forks source link

Provide a programmable JS API around function-runner #4

Open nickwesselman opened 1 year ago

nickwesselman commented 1 year ago

In addition to facilitating execution via npx, would be great if this library allowed you to programmatically invoke the function-runner in test scripts, and even automated integration tests.

Example of such usage

A good validation case for this would be adding an integration test to samples in function-examples.

andrewhassan commented 1 year ago

@nickwesselman Are you thinking of exposing something like this:

// This is the result of function-runner
interface Result {
  name: string;
  size: number;
  memoryUsage: number;
  instructions: number;
  logs: string;
  output: OutputType;
}

export function run<InputType, OutputType>(modulePath: string, input: InputType): Result<OutputType> {
  // ...
}
nickwesselman commented 1 year ago

Yes that looks right! I fixed the link to potential usage in the issue description.

Do we need to solve or account for the 'first download' issue that I had to workaround here?

andrewhassan commented 1 year ago

I don't believe so since we'll be building this directly in @shopify/function-runner. We can modify the code so that it doesn't print that.