-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: worker log and revision #1
feat: worker log and revision #1
Conversation
obviously feel free to adjust whatever you think is best in terms of what we put in the header but we have all the components we need to fill it So after this is merged into the SDK and I adjust Defined at the SDK level so plugins don't need to define it. |
if (pluginOptions.postCommentOnError && loggerError) { | ||
await postComment(context, loggerError); | ||
await postComment(context, loggerError, honoEnvironment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've passed it as a param here instead of building it into context
because the SDK consumer can access anything in context
and if they installed their worker into any config other than their own they'd be able to exfiltrate the api token of the partner or us, I think, maybe not.
At least that was my intention, I hope that it holds true.
@@ -80,13 +80,16 @@ export async function createActionsPlugin<TConfig = unknown, TEnv = unknown, TSu | |||
env = process.env as TEnv; | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -80,13 +80,16 @@ export async function createActionsPlugin<TConfig = unknown, TEnv = unknown, TSu | |||
env = process.env as TEnv; | |||
} | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keyrxng thank you for that. Does it work properly within Actions as well? |
I didn't QA it for actions, I thought you would of QA'd and merged this in and adjusted things Probs just copy paste the logic into the workflow postComment I guess?
I'm not sure if you mean you'll catch anything from this PR to adjust and merge it in or something else, I'm pretty tired so if it's still to be done later I'll catch it np |
@Keyrxng the |
Yeah I saw that they were duplicated for worker/action. I assumed the reason was Why was the I even added a similar comment in ubiquity-os#191 that would allow the proxy callbacks to detect and handle worker/action specifics, but the SDK has been built to keep their intended logic separate... |
I'll just PR the kernel |
Was gonna QA actions and submit a PR but fell into a rabbit hole exploring what's possible with the I have a clear understanding of it and solutions to hand but would like your opinion It more or less boils down to this: class CustomError extends Error implements LogReturn {
logMessage: { raw: string; diff: string; level: LogLevel; type: LogLevelWithOk; };
metadata?: Metadata | undefined;
constructor(log: LogReturn) {
super(log.logMessage.raw);
Error.captureStackTrace(this, this.constructor);
this.logMessage = log.logMessage;
this.metadata = log.metadata;
}
}
export class Logger extends Logs {
constructor(logLevel: LogLevel) {
super(logLevel);
}
debug(log: string, metadata?: Metadata): LogReturn {
return new CustomError(super.debug(log, metadata));
}
...
const context: Context<TConfig, TEnv, TSupportedEvents> = {
logger: new Logger(pluginOptions.logLevel),
} Does it make sense for me to PR against the logger or against the SDK? I'm unsure because of:
|
I think we can keep is simple, the kernel has a logger and so does the SDK (which is provided to the plugin instance). What is important I think is cross operability of the SDK no matter what its context is (worker, action etc) so no code changes are needed. My aim here is to improve dev experience. |
Resolves ubiquity-os/plugin-sdk#34