Skip to content

Commit

Permalink
chore: removed logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Sep 21, 2024
1 parent de80953 commit 65d5b39
Showing 1 changed file with 30 additions and 41 deletions.
71 changes: 30 additions & 41 deletions src/github/handlers/push-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ function constructErrorBody(

export async function handleActionValidationWorkflowCompleted(context: GitHubContext<"repository_dispatch">) {
const { octokit, payload } = context;
const { repository, client_payload } = payload;
const { client_payload } = payload;
let pluginOutput: PluginOutput;

try {
pluginOutput = Value.Decode(pluginOutputSchema, client_payload);
} catch (error) {
console.error("Cannot decode plugin output", error);
console.error("[handleActionValidationWorkflowCompleted]: Cannot decode plugin output", error);
throw error;
}

Expand All @@ -66,35 +66,30 @@ export async function handleActionValidationWorkflowCompleted(context: GitHubCon

console.log("Received Action output result for validation, will process.", pluginOutput.output);
const errors = pluginOutput.output.errors as ValueError[];
console.log("=== stuff", JSON.stringify(payload, null, 2), JSON.stringify(state, null, 2));
// TODO: validate with typebox
const { rawData, after, configurationRepo, path } = state.additionalProperties ?? {};
try {
const body = [];
body.push(`@${state.eventPayload.sender?.login} Configuration is ${!errors.length ? "valid" : "invalid"}.\n`);
if (errors.length) {
body.push(
...constructErrorBody(
errors.map((err) => ({ ...err, path: `${path}${err.path}` })),
rawData as string,
configurationRepo as GitHubContext<"push">["payload"]["repository"],
after as string
)
);
}
console.log("+))) creating commit comment", {
owner: repository.owner.login,
repo: repository.name,
commit_sha: state.additionalProperties?.after,
body: body.join(""),
});
if (after) {
await octokit.rest.repos.createCommitComment({
owner: configurationRepo.owner.login,
repo: configurationRepo.name,
commit_sha: after as string,
body: body.join(""),
});
const body = [];
body.push(`@${state.eventPayload.sender?.login} Configuration is invalid.\n`);
if (errors.length) {
body.push(
...constructErrorBody(
errors.map((err) => ({ ...err, path: `${path}${err.path}` })),
rawData as string,
configurationRepo as GitHubContext<"push">["payload"]["repository"],
after as string
)
);
}
if (after) {
await octokit.rest.repos.createCommitComment({
owner: configurationRepo.owner.login,
repo: configurationRepo.name,
commit_sha: after as string,
body: body.join(""),
});
}
}
} catch (e) {
console.error("handleActionValidationWorkflowCompleted", e);
Expand Down Expand Up @@ -162,23 +157,17 @@ export default async function handlePushEvent(context: GitHubContext<"push">) {
errors.push(...configurationErrors);
}
try {
const body = [];
body.push(`@${payload.sender?.login} Configuration is ${!errors.length ? "valid" : "invalid"}.\n`);
if (errors.length) {
const body = [];
body.push(`@${payload.sender?.login} Configuration is invalid.\n`);
body.push(...constructErrorBody(errors, rawData, repository, after));
await octokit.rest.repos.createCommitComment({
owner: repository.owner.login,
repo: repository.name,
commit_sha: after,
body: body.join(""),
});
}
console.log("))) creating commit comment", {
owner: repository.owner.login,
repo: repository.name,
commit_sha: after,
body: body.join(""),
});
await octokit.rest.repos.createCommitComment({
owner: repository.owner.login,
repo: repository.name,
commit_sha: after,
body: body.join(""),
});
} catch (e) {
console.error("handlePushEventError", e);
}
Expand Down

0 comments on commit 65d5b39

Please sign in to comment.