Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ name: CI
on:
push:
branches:
- main
- master
- prod
paths-ignore:
- 'README.md'
- '*.md'
- 'docs/**'
pull_request:
branches:
- prod
paths-ignore:
- 'README.md'
- '*.md'
- 'docs/**'

permissions:
contents: read
Expand Down Expand Up @@ -58,3 +67,16 @@ jobs:

- name: Run build
run: npm run build

- name: Trigger Inngest CI Workflow
if: ${{ secrets.INNGEST_EVENT_KEY != '' }}
run: |
curl --fail -X POST https://api.inngest.com/e/${{ secrets.INNGEST_EVENT_KEY }} \
-H "Content-Type: application/json" \
-d '{
"name": "ci/workflow.triggered",
"data": {
"ref": "${{ github.ref }}",
"sha": "${{ github.sha }}"
}
}'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
25 changes: 24 additions & 1 deletion app/api/inngest/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,33 @@ import { runVibetest } from "@/lib/test-functions/vibetest-run";
import { runSecurityAgent } from "@/lib/security-agent/functions";
import { indexDeploymentLogs, cronReindexLogs } from "@/lib/vector-indexer"; // ← add this

const handleCiWorkflow = inngest.createFunction(
{ id: "handle-ci-workflow" },
{ event: "ci/workflow.triggered" },
async ({ event, step }) => {
const { ref, sha } = event.data;

await step.run("execute-safely", async () => {
console.log(`Processing build for Ref: ${ref}, SHA: ${sha}`);

// Send the event to start the actual test suites in the app
await inngest.send({
name: "test/suite.run",
data: {
runId: `ci-${sha.slice(0, 7)}`,
sandboxId: "production-ci-environment",
},
});

return { status: "test_suite_dispatched" };
});
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
);

// Allow Inngest handler up to 5 minutes (max for Vercel hobby plan)
export const maxDuration = 300;

export const { GET, POST, PUT } = serve({
client: inngest,
functions: [runTestSuite, runSecurityScan, runApiTests, runPerformanceTests, runVibetest, runSecurityAgent, indexDeploymentLogs, cronReindexLogs],
functions: [runTestSuite, runSecurityScan, runApiTests, runPerformanceTests, runVibetest, runSecurityAgent, indexDeploymentLogs, cronReindexLogs, handleCiWorkflow],
});
2 changes: 1 addition & 1 deletion app/api/tests/run/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getDb, ensureTables } from "@/lib/db";
import { randomBytes } from "node:crypto";
import { auth } from "@/lib/auth";

const EVENT_MAP: Record<string, string> = {
const EVENT_MAP: Record<string, "test/suite.run" | "test/security.run" | "test/api.run" | "test/performance.run" | "test/vibetest.run"> = {
suite: "test/suite.run",
security: "test/security.run",
api: "test/api.run",
Expand Down
25 changes: 21 additions & 4 deletions lib/inngest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import { Inngest } from "inngest";
import { Inngest, EventSchemas } from "inngest";

export const inngest = new Inngest({
id: "secdev",
eventKey: process.env.INNGEST_EVENT_KEY,
type Events = {
"ci/workflow.triggered": {
data: {
ref: string;
sha: string;
};
};
"log/index.requested": { data: { sandboxId: string; userId: string; ttlDays: number } };
"log/index.cron": { data: Record<string, never> };
"security-agent/scan.run": { data: { runId: string; sandboxId: string } };
"test/api.run": { data: { runId: string; sandboxId: string } };
"test/performance.run": { data: { runId: string; sandboxId: string } };
"test/security.run": { data: { runId: string; sandboxId: string } };
"test/suite.run": { data: { runId: string; sandboxId: string } };
"test/vibetest.run": { data: { runId: string; sandboxId: string } };
};

export const inngest = new Inngest({
id: "secdev-app",
schemas: new EventSchemas().fromRecord<Events>()
});