From ec2c29a80a5016b138bb119971b23a565833b937 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 04:43:27 +0900 Subject: [PATCH 01/25] chore: changed 404 log for missing configuration file --- src/github/utils/config.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index dff0447..0911067 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -148,7 +148,12 @@ async function download({ context, repository, owner }: { context: GitHubContext }); return data as unknown as string; // this will be a string if media format is raw } catch (err) { - console.error(err); + console.log(JSON.stringify(err)); + if (err && typeof err === "object" && "code" in err) { + console.log("No configuration file was found in the repository.", { repository, owner }); + } else { + console.error(err); + } return null; } } From c92e5a0c3e8a9dc25f5ede5cf67dc2c448b7e479 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 04:46:46 +0900 Subject: [PATCH 02/25] chore: changed 404 log for missing configuration file --- src/github/utils/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 0911067..4d5210e 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -148,8 +148,8 @@ async function download({ context, repository, owner }: { context: GitHubContext }); return data as unknown as string; // this will be a string if media format is raw } catch (err) { - console.log(JSON.stringify(err)); - if (err && typeof err === "object" && "code" in err) { + // In case of a missing config, do not log is as an error + if (err && typeof err === "object" && "status" in err && err.status === 404) { console.log("No configuration file was found in the repository.", { repository, owner }); } else { console.error(err); From b96a79459eaa9337a63e53c259468c3318ef0f36 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 04:54:04 +0900 Subject: [PATCH 03/25] chore: improved logs for events --- src/github/handlers/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index 604d821..d482ab6 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -29,7 +29,7 @@ export function bindHandlers(eventHandler: GitHubEventHandler) { export async function shouldSkipPlugin(context: GitHubContext, pluginChain: PluginConfiguration["plugins"][0]) { if (pluginChain.uses[0].skipBotEvents && "sender" in context.payload && context.payload.sender?.type === "Bot") { - console.log("Skipping plugin chain because sender is a bot"); + console.log(`Skipping plugin ${JSON.stringify(pluginChain.uses[0].plugin)} in the chain because the ender is a bot`); return true; } const manifest = await getManifest(context, pluginChain.uses[0].plugin); @@ -65,7 +65,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp const pluginChains = getPluginsForEvent(config.plugins, context.key); if (pluginChains.length === 0) { - console.log(`No handler found for event ${event.name}`); + console.log(`No handler found for event ${event.name} (${context.key})`); return; } From 88ddc06122a01393a7200a8009c2e0b80f3d2da4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 04:54:23 +0900 Subject: [PATCH 04/25] chore: improved logs for events --- src/github/handlers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index d482ab6..c7cf5cd 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -65,7 +65,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp const pluginChains = getPluginsForEvent(config.plugins, context.key); if (pluginChains.length === 0) { - console.log(`No handler found for event ${event.name} (${context.key})`); + console.log(`No handler found for event ${event.name} (${context.key})`, context); return; } From 5e37cb8ff5c28c546529cc9df5da0f9f4aed5e7b Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:04:26 +0900 Subject: [PATCH 05/25] chore: improved logs for events --- src/github/handlers/index.ts | 2 +- src/github/utils/config.ts | 2 +- src/github/utils/kv-store.ts | 2 +- src/kernel.ts | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index c7cf5cd..222d73f 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -29,7 +29,7 @@ export function bindHandlers(eventHandler: GitHubEventHandler) { export async function shouldSkipPlugin(context: GitHubContext, pluginChain: PluginConfiguration["plugins"][0]) { if (pluginChain.uses[0].skipBotEvents && "sender" in context.payload && context.payload.sender?.type === "Bot") { - console.log(`Skipping plugin ${JSON.stringify(pluginChain.uses[0].plugin)} in the chain because the ender is a bot`); + console.log(`Skipping plugin ${JSON.stringify(pluginChain.uses[0].plugin)} in the chain because the sender is a bot`); return true; } const manifest = await getManifest(context, pluginChain.uses[0].plugin); diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 4d5210e..2883c1e 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -150,7 +150,7 @@ async function download({ context, repository, owner }: { context: GitHubContext } catch (err) { // In case of a missing config, do not log is as an error if (err && typeof err === "object" && "status" in err && err.status === 404) { - console.log("No configuration file was found in the repository.", { repository, owner }); + console.log(`No configuration file was found in the repository ${owner}/${repository}.`); } else { console.error(err); } diff --git a/src/github/utils/kv-store.ts b/src/github/utils/kv-store.ts index 5432d2a..bf0592a 100644 --- a/src/github/utils/kv-store.ts +++ b/src/github/utils/kv-store.ts @@ -45,7 +45,7 @@ export class EmptyStore implements KvStore { } put(id: string, state: T): Promise { - console.log(`put KV ${id} ${state}`); + console.log(`put KV ${id} ${JSON.stringify(state)}`); return Promise.resolve(); } } diff --git a/src/kernel.ts b/src/kernel.ts index cd1446d..5576778 100644 --- a/src/kernel.ts +++ b/src/kernel.ts @@ -37,6 +37,7 @@ app.post("/", async (ctx: Context) => { pluginChainState: new EmptyStore(), openAiClient, }); + console.log(`POST event instigated by ${ctx.req.url}`); bindHandlers(eventHandler); // if running in Cloudflare Worker, handle the webhook in the background and return a response immediately From b65b5b1bb9a53790931cb639337781d7346435a7 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:08:59 +0900 Subject: [PATCH 06/25] chore: improved logs for events --- src/github/utils/kv-store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/utils/kv-store.ts b/src/github/utils/kv-store.ts index bf0592a..5432d2a 100644 --- a/src/github/utils/kv-store.ts +++ b/src/github/utils/kv-store.ts @@ -45,7 +45,7 @@ export class EmptyStore implements KvStore { } put(id: string, state: T): Promise { - console.log(`put KV ${id} ${JSON.stringify(state)}`); + console.log(`put KV ${id} ${state}`); return Promise.resolve(); } } From 3af3fb94c083e977b544cd1a7c97ae4c8f1bf954 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:17:13 +0900 Subject: [PATCH 07/25] chore: improved logs for events --- src/github/utils/config.ts | 3 +++ src/kernel.ts | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 2883c1e..e1edd04 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -60,6 +60,9 @@ export async function getConfig(context: GitHubContext): Promise { pluginChainState: new EmptyStore(), openAiClient, }); - console.log(`POST event instigated by ${ctx.req.url}`); bindHandlers(eventHandler); // if running in Cloudflare Worker, handle the webhook in the background and return a response immediately From be8b8b919af54d17627a210439d295c5bcaf1067 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:23:52 +0900 Subject: [PATCH 08/25] chore: improved logs for events --- src/github/handlers/repository-dispatch.ts | 2 +- src/github/utils/config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/github/handlers/repository-dispatch.ts b/src/github/handlers/repository-dispatch.ts index ccd82af..dd4b169 100644 --- a/src/github/handlers/repository-dispatch.ts +++ b/src/github/handlers/repository-dispatch.ts @@ -17,7 +17,7 @@ export async function repositoryDispatch(context: GitHubContext<"repository_disp try { pluginOutput = Value.Decode(pluginOutputSchema, context.payload.client_payload); } catch (error) { - console.error("Cannot decode plugin output", error); + console.error(`Cannot decode plugin output from ${context.payload.repository.full_name}`, error); throw error; } console.log("Plugin output", pluginOutput); diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index e1edd04..26305b9 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -61,7 +61,7 @@ export async function getConfig(context: GitHubContext): Promise Date: Mon, 30 Dec 2024 05:27:55 +0900 Subject: [PATCH 09/25] chore: improved logs for events --- src/github/handlers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index 222d73f..46b95a4 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -65,7 +65,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp const pluginChains = getPluginsForEvent(config.plugins, context.key); if (pluginChains.length === 0) { - console.log(`No handler found for event ${event.name} (${context.key})`, context); + console.log(`No handler found for event ${event.name} (${context.key})`); return; } From dc8bdb6b8e932b229a780f2a49c5e7605812235e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:40:29 +0900 Subject: [PATCH 10/25] chore: improved logs for events --- src/github/handlers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index 46b95a4..0d00137 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -15,7 +15,7 @@ function tryCatchWrapper(fn: (event: EmitterWebhookEvent) => unknown) { try { await fn(event); } catch (error) { - console.error("Error in event handler", error); + console.error(`Error in event handler`, error, JSON.stringify(event)); } }; } From d8e1de6f976ecf7a3280bf563246bd53c2826fa6 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 05:44:17 +0900 Subject: [PATCH 11/25] chore: improved logs for events --- src/github/utils/config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 26305b9..0e85595 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -142,18 +142,19 @@ function checkExpression(value: string, allIds: Set, calledIds: Set { if (!repository || !owner) throw new Error("Repo or owner is not defined"); + const filePath = context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH; try { const { data } = await context.octokit.rest.repos.getContent({ owner, repo: repository, - path: context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH, + path: filePath, mediaType: { format: "raw" }, }); return data as unknown as string; // this will be a string if media format is raw } catch (err) { // In case of a missing config, do not log is as an error if (err && typeof err === "object" && "status" in err && err.status === 404) { - console.log(`No configuration file was found in the repository ${owner}/${repository}.`); + console.log(`No configuration file was found at ${owner}/${repository}/${filePath}.`); } else { console.error(err); } From 29d59cfb60d930d1f712617c646bc237866faa2d Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 06:12:55 +0900 Subject: [PATCH 12/25] chore: improved logs for events --- src/github/utils/config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 0e85595..7587ea4 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -150,11 +150,12 @@ async function download({ context, repository, owner }: { context: GitHubContext path: filePath, mediaType: { format: "raw" }, }); + console.log(`Configuration file found at ${owner}/${repository}/${filePath}`); return data as unknown as string; // this will be a string if media format is raw } catch (err) { // In case of a missing config, do not log is as an error if (err && typeof err === "object" && "status" in err && err.status === 404) { - console.log(`No configuration file was found at ${owner}/${repository}/${filePath}.`); + console.log(`No configuration file was found at ${owner}/${repository}/${filePath}`); } else { console.error(err); } From b5e22c3a1e26d8007ab2c870eba06d8392eae5aa Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 16:32:53 +0900 Subject: [PATCH 13/25] chore: added req log --- src/github/handlers/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index 0d00137..cc0ad40 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -69,6 +69,8 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp return; } + console.log(`Will call the following chain: ${pluginChains.map((o) => JSON.stringify(o.uses[0]?.plugin)).join(", ")}`); + for (const pluginChain of pluginChains) { if (await shouldSkipPlugin(context, pluginChain)) { continue; From 8ff05d4693fd127ce4e0d1e1e8f2efe5d86cae86 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 16:38:25 +0900 Subject: [PATCH 14/25] chore: added req log --- src/github/utils/config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 7587ea4..1e7002f 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -76,6 +76,8 @@ export async function getConfig(context: GitHubContext): Promise Date: Mon, 30 Dec 2024 16:59:52 +0900 Subject: [PATCH 15/25] chore: added req log --- src/github/utils/config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 1e7002f..0782eae 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -68,12 +68,14 @@ export async function getConfig(context: GitHubContext): Promise { if (configuration.config) { mergedConfiguration = mergeConfigurations(mergedConfiguration, configuration.config); } }); + console.log("Will check plugin chains."); checkPluginChains(mergedConfiguration); console.log(`Found ${mergedConfiguration.plugins.length} configurations for ${payload.repository.owner.login}/${payload.repository.name}`); From 7993da54a96b70545ad19080eb2b5ec666c84030 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 17:00:40 +0900 Subject: [PATCH 16/25] chore: added req log --- src/github/utils/config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 0782eae..1e36104 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -68,14 +68,16 @@ export async function getConfig(context: GitHubContext): Promise { if (configuration.config) { mergedConfiguration = mergeConfigurations(mergedConfiguration, configuration.config); } }); - console.log("Will check plugin chains."); + console.log(`Will check plugin chains for ${payload.repository.owner.login}/${payload.repository.name}.`); + checkPluginChains(mergedConfiguration); console.log(`Found ${mergedConfiguration.plugins.length} configurations for ${payload.repository.owner.login}/${payload.repository.name}`); From a3471147aaac16f890a026bf05790bc22504d24e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 17:03:49 +0900 Subject: [PATCH 17/25] chore: added req log --- src/github/utils/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 1e36104..ca770ac 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -80,7 +80,7 @@ export async function getConfig(context: GitHubContext): Promise Date: Mon, 30 Dec 2024 17:16:21 +0900 Subject: [PATCH 18/25] chore: added req log --- src/github/utils/config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index ca770ac..782cb58 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -17,6 +17,7 @@ export async function getConfigurationFromRepo(context: GitHubContext, repositor }); const { yaml, errors } = parseYaml(rawData); const targetRepoConfiguration: PluginConfiguration | null = yaml; + console.log(`Will attempt to decode configuration for ${owner}/${repository}`); if (targetRepoConfiguration) { try { const configSchemaWithDefaults = Value.Default(configSchema, targetRepoConfiguration) as Readonly; @@ -26,12 +27,14 @@ export async function getConfigurationFromRepo(context: GitHubContext, repositor console.error(error); } } - return { config: Value.Decode(configSchema, configSchemaWithDefaults), errors, rawData }; + const decodedConfig = Value.Decode(configSchema, configSchemaWithDefaults); + return { config: decodedConfig, errors, rawData }; } catch (error) { console.error(`Error decoding configuration for ${owner}/${repository}, will ignore.`, error); return { config: null, errors: [error instanceof TransformDecodeCheckError ? error.error : error] as ValueError[], rawData }; } } + console.log(`YAML could not be decoded for ${owner}/${repository}`); return { config: null, errors, rawData }; } From 22d6c7d850fb86c8288bf10aa35ee256708d0dda Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 17:45:20 +0900 Subject: [PATCH 19/25] chore: improved logs --- src/github/utils/config.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 782cb58..3c63177 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -150,7 +150,10 @@ function checkExpression(value: string, allIds: Set, calledIds: Set { - if (!repository || !owner) throw new Error("Repo or owner is not defined"); + if (!repository || !owner) { + console.error("Repo or owner is not defined, cannot download the requested file."); + return null; + } const filePath = context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH; try { const { data } = await context.octokit.rest.repos.getContent({ @@ -166,7 +169,7 @@ async function download({ context, repository, owner }: { context: GitHubContext if (err && typeof err === "object" && "status" in err && err.status === 404) { console.log(`No configuration file was found at ${owner}/${repository}/${filePath}`); } else { - console.error(err); + console.error("Failed to download the requested file.", err); } return null; } From b243aff3a756fbf692a5b37e25e49023faa51a3f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 18:04:54 +0900 Subject: [PATCH 20/25] chore: improved logs --- src/github/handlers/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index cc0ad40..e7af706 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -69,7 +69,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp return; } - console.log(`Will call the following chain: ${pluginChains.map((o) => JSON.stringify(o.uses[0]?.plugin)).join(", ")}`); + console.log(`Will call the following chain:\n${pluginChains.map((o) => JSON.stringify(o.uses[0]?.plugin)).join("\n")}`); for (const pluginChain of pluginChains) { if (await shouldSkipPlugin(context, pluginChain)) { @@ -102,6 +102,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp // We wrap the dispatch so a failing plugin doesn't break the whole execution try { + console.log(`Dispatching event for ${JSON.stringify(plugin)}`); if (!isGithubPluginObject) { await dispatchWorker(plugin, await inputs.getWorkerInputs()); } else { @@ -113,6 +114,7 @@ async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceTyp inputs: await inputs.getWorkflowInputs(), }); } + console.log(`Event dispatched for ${JSON.stringify(plugin)}`); } catch (e) { console.error(`An error occurred while processing the plugin chain, will skip plugin ${JSON.stringify(plugin)}`, e); } From 09c67947a026297248f4fbbde463f6e6d1bb4cd8 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 18:25:05 +0900 Subject: [PATCH 21/25] chore: improved logs --- src/github/utils/config.ts | 1 + src/github/utils/plugins.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 3c63177..2fa8541 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -156,6 +156,7 @@ async function download({ context, repository, owner }: { context: GitHubContext } const filePath = context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH; try { + console.log(`Attempting to fetch configuration for ${owner}/${repository}/${filePath}`); const { data } = await context.octokit.rest.repos.getContent({ owner, repo: repository, diff --git a/src/github/utils/plugins.ts b/src/github/utils/plugins.ts index 164e74c..1eb7526 100644 --- a/src/github/utils/plugins.ts +++ b/src/github/utils/plugins.ts @@ -37,7 +37,7 @@ async function fetchActionManifest(context: GitHubContext<"issue_comment.created return manifest; } } catch (e) { - console.warn(`Could not find a manifest for Action ${owner}/${repo}: ${e}`); + console.error(`Could not find a manifest for Action ${owner}/${repo}: ${e}`); } return null; } @@ -54,7 +54,7 @@ async function fetchWorkerManifest(url: string): Promise { _manifestCache[url] = manifest; return manifest; } catch (e) { - console.warn(`Could not find a manifest for Worker ${manifestUrl}: ${e}`); + console.error(`Could not find a manifest for Worker ${manifestUrl}: ${e}`); } return null; } From bc96f8891b8a18da5bc672978e1b2b17f126dffa Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 30 Dec 2024 18:41:04 +0900 Subject: [PATCH 22/25] chore: improved logs --- src/github/utils/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 2fa8541..4651ca4 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -34,7 +34,7 @@ export async function getConfigurationFromRepo(context: GitHubContext, repositor return { config: null, errors: [error instanceof TransformDecodeCheckError ? error.error : error] as ValueError[], rawData }; } } - console.log(`YAML could not be decoded for ${owner}/${repository}`); + console.error(`YAML could not be decoded for ${owner}/${repository}`); return { config: null, errors, rawData }; } From b094582283c2692ec11464ed999d8c91d8672e63 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sat, 4 Jan 2025 23:17:10 +0900 Subject: [PATCH 23/25] chore: fixed typo in comment --- src/github/utils/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/utils/config.ts b/src/github/utils/config.ts index 4651ca4..92003a7 100644 --- a/src/github/utils/config.ts +++ b/src/github/utils/config.ts @@ -166,7 +166,7 @@ async function download({ context, repository, owner }: { context: GitHubContext console.log(`Configuration file found at ${owner}/${repository}/${filePath}`); return data as unknown as string; // this will be a string if media format is raw } catch (err) { - // In case of a missing config, do not log is as an error + // In case of a missing config, do not log it as an error if (err && typeof err === "object" && "status" in err && err.status === 404) { console.log(`No configuration file was found at ${owner}/${repository}/${filePath}`); } else { From 3d7fe46223c48e8c4e84f83675b4c4884649dc0c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 5 Jan 2025 14:00:18 +0900 Subject: [PATCH 24/25] fix: events can now be ignored, skipping plugin runs --- src/github/handlers/index.ts | 6 ++++++ src/types/constants.ts | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 src/types/constants.ts diff --git a/src/github/handlers/index.ts b/src/github/handlers/index.ts index e7af706..127784c 100644 --- a/src/github/handlers/index.ts +++ b/src/github/handlers/index.ts @@ -1,4 +1,5 @@ import { EmitterWebhookEvent } from "@octokit/webhooks"; +import { FILTERED_EVENTS } from "../../types/constants"; import { GitHubContext } from "../github-context"; import { GitHubEventHandler } from "../github-event-handler"; import { getConfig } from "../utils/config"; @@ -50,6 +51,11 @@ export async function shouldSkipPlugin(context: GitHubContext, pluginChain: Plug async function handleEvent(event: EmitterWebhookEvent, eventHandler: InstanceType) { const context = eventHandler.transformEvent(event); + if (FILTERED_EVENTS.includes(event.name)) { + console.log(`Event ${event.name} is in the filtered event list, will be ignored.`); + return; + } + const config = await getConfig(context); if (!config) { diff --git a/src/types/constants.ts b/src/types/constants.ts new file mode 100644 index 0000000..92ed145 --- /dev/null +++ b/src/types/constants.ts @@ -0,0 +1,3 @@ +import { EmitterWebhookEventName } from "@octokit/webhooks"; + +export const FILTERED_EVENTS: EmitterWebhookEventName[] = ["workflow_job", "workflow_run"]; From 8ca8c90849a57b3fde6c41b3ded1deb4795fdbf2 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 5 Jan 2025 14:26:57 +0900 Subject: [PATCH 25/25] chore: added workflow event to the ignore list --- src/types/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/constants.ts b/src/types/constants.ts index 92ed145..4860231 100644 --- a/src/types/constants.ts +++ b/src/types/constants.ts @@ -1,3 +1,3 @@ import { EmitterWebhookEventName } from "@octokit/webhooks"; -export const FILTERED_EVENTS: EmitterWebhookEventName[] = ["workflow_job", "workflow_run"]; +export const FILTERED_EVENTS: EmitterWebhookEventName[] = ["workflow_job", "workflow_run", "workflow_dispatch"];