Skip to content

Commit

Permalink
Gather rawRelease for future replays. Improve prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-osch committed Jan 15, 2025
1 parent 2dda486 commit d87e711
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
14 changes: 14 additions & 0 deletions prisma/migrations/20250115142547_add_raw_release/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "RawRelease" (
"id" TEXT NOT NULL,
"body" JSONB NOT NULL,
"releaseId" TEXT NOT NULL,

CONSTRAINT "RawRelease_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "RawRelease_releaseId_key" ON "RawRelease"("releaseId");

-- AddForeignKey
ALTER TABLE "RawRelease" ADD CONSTRAINT "RawRelease_releaseId_fkey" FOREIGN KEY ("releaseId") REFERENCES "Release"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
11 changes: 10 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ model Alert {
}

model Release {
id String @id @default(cuid())
id String @id @default(cuid())
name String
org String
repo String
Expand All @@ -35,6 +35,7 @@ model Release {
publishedAt DateTime
authors String[]
summary String
rawRelease RawRelease?
}

enum Source {
Expand All @@ -54,3 +55,11 @@ model AlertContext {
alert Alert @relation(fields: [alertId], references: [id], onDelete: Cascade)
}

model RawRelease {
id String @id @default(cuid())
body Json
releaseId String @unique
release Release @relation(fields: [releaseId], references: [id], onDelete: Cascade)
}
3 changes: 2 additions & 1 deletion src/aggregator/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ ${stringify(
{ indent: 2 }
).slice(0, 200000)}
Check-results amd checkly configuration details are already provided in the UI. Focus on the root cause analyisis and potential mitigations. Help the user to resolve the issue.
Check-results amd checkly configuration details are already provided in the UI. Focus on the root cause analysis and potential mitigations. Help the user to resolve the issue.
Generate a condensed summary of your root cause analysis of the current situation.
Focus on the essentials, provide a concise overview and actionable insights.
Provide reasoning and the source of the information. Max. 100 words. Include links to relevant context if applicable.
Be concise, insightful and actionable, skip the fluff, no yapping.
If a recent release is the most likely root cause, provide a link to the release diff.
*Summary:* `,
maxTokens: 500,
Expand Down
13 changes: 10 additions & 3 deletions src/routes/githubwebhook.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PrismaClient} from '@prisma/client';
import {Prisma, PrismaClient} from '@prisma/client';

import crypto, {sign} from "crypto";
import timers from "node:timers/promises";
Expand Down Expand Up @@ -96,7 +96,7 @@ router.post(
releaseEvent.repository.owner.login
);

const previousRelease = await withRetry(() =>github.getPreviousReleaseTag(
const previousRelease = await withRetry(() => github.getPreviousReleaseTag(
releaseEvent.repository.owner.login,
releaseEvent.repository.name,
releaseEvent.release.tag_name
Expand Down Expand Up @@ -126,7 +126,7 @@ router.post(
}).blocks;

console.log('Creating a new release in the database');
await prisma.release.create({
const createdRelease = await prisma.release.create({
data: {
name: releaseName,
releaseUrl: releaseEvent.release.html_url,
Expand All @@ -140,6 +140,13 @@ router.post(
summary: release.summary,
}
});
await prisma.rawRelease.create({
data: {
body: releaseEvent as unknown as Prisma.InputJsonValue,
releaseId: createdRelease.id,
},
});

console.log('Posting a message to Slack');
await app.client.chat.postMessage({
channel: process.env.SLACK_RELEASE_CHANNEL_ID as string,
Expand Down

0 comments on commit d87e711

Please sign in to comment.