Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pnpm-debug.log*

# Dependencies
node_modules
**/__pycache__/
.pnp
.pnp.js

Expand Down Expand Up @@ -38,3 +39,4 @@ coverage
.env.*

/src/generated/prisma
.npmrc
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM node:22-alpine AS build
WORKDIR /app

COPY package.json package-lock.json ./
COPY vendor ./vendor
RUN --mount=type=secret,id=npm_token \
printf "@coveritlabs:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=$(cat /run/secrets/npm_token)\n" > .npmrc \
&& npm ci --ignore-scripts \
Expand All @@ -25,6 +26,7 @@ WORKDIR /app
ENV NODE_ENV=production

COPY package.json package-lock.json ./
COPY vendor ./vendor
RUN --mount=type=secret,id=npm_token \
printf "@coveritlabs:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=$(cat /run/secrets/npm_token)\n" > .npmrc \
&& npm ci --ignore-scripts --omit=dev \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /app

# Install dependencies (including devDependencies)
COPY package.json package-lock.json ./
COPY vendor ./vendor
RUN --mount=type=secret,id=npm_token \
printf "@coveritlabs:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=$(cat /run/secrets/npm_token)\n" > .npmrc \
&& npm ci --ignore-scripts \
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ services:
condition: service_healthy
redis:
condition: service_healthy

db:
image: postgres:18
container_name: coverit-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${DB_USER:-postgres}
- POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
'^@lib/(.*)$': '<rootDir>/src/lib/$1',
'^@services/(.*)$': '<rootDir>/src/services/$1',
'^@utils/(.*)$': '<rootDir>/src/utils/$1',
'^@mappers/(.*)$': '<rootDir>/src/mappers/$1',
'^@models/(.*)$': '<rootDir>/src/models/$1',
'^@constants/(.*)$': '<rootDir>/src/constants/$1',
'^@generated/(.*)$': '<rootDir>/src/generated/$1',
Expand Down
1,247 changes: 652 additions & 595 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev": "nodemon",
"build": "prisma generate && tsc && tsc-alias",
"start": "node dist/index.js",
"worker:email": "ts-node -r tsconfig-paths/register src/workers/email.worker.ts",
"postinstall": "prisma generate",
"db:migrate": "prisma migrate dev",
"db:deploy": "prisma migrate deploy",
Expand All @@ -26,7 +27,7 @@
"dependencies": {
"@asteasolutions/zod-to-openapi": "^8.4.3",
"@bufbuild/protobuf": "^2.11.0",
"@coveritlabs/contracts": "^1.3.1",
"@coveritlabs/contracts": "file:vendor/coveritlabs-contracts-1.6.1.tgz",
"@prisma/adapter-pg": "^7.4.2",
"@prisma/client": "^7.4.2",
"argon2": "^0.44.0",
Expand Down Expand Up @@ -80,4 +81,4 @@
"overrides": {
"ioredis": "^5.10.0"
}
}
}
47 changes: 47 additions & 0 deletions prisma/migrations/4_add_crawl_sessions/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'CrawlStatus') THEN
CREATE TYPE "CrawlStatus" AS ENUM (
'UNSPECIFIED',
'QUEUED',
'RUNNING',
'COMPLETED',
'FAILED',
'ABORTED',
'PAUSED',
'NEW'
);
END IF;
END $$;

DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'CrawlTriggerType') THEN
CREATE TYPE "CrawlTriggerType" AS ENUM (
'UNSPECIFIED',
'MANUAL',
'SCHEDULED',
'CI_TRIGGER',
'WEBHOOK'
);
END IF;
END $$;

CREATE TABLE IF NOT EXISTS "crawl_sessions" (
"crawl_session_id" UUID NOT NULL,
"app_version_id" UUID NOT NULL,
"status" "CrawlStatus" NOT NULL DEFAULT 'NEW',
"trigger_type" "CrawlTriggerType" NOT NULL,
"config" JSONB NOT NULL,
"state_count" INTEGER NOT NULL DEFAULT 0,
"transition_count" INTEGER NOT NULL DEFAULT 0,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"started_at" TIMESTAMP(3),
"finished_at" TIMESTAMP(3),
"error" TEXT,
CONSTRAINT "crawl_sessions_pkey" PRIMARY KEY ("crawl_session_id")
);

ALTER TABLE "crawl_sessions"
ADD CONSTRAINT "crawl_sessions_app_version_id_fkey"
FOREIGN KEY ("app_version_id")
REFERENCES "target_application_versions"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
38 changes: 37 additions & 1 deletion prisma/schema.prisma
Comment thread
Mo2Hefny marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ enum ProjectRole {
VIEWER
}

enum CrawlStatus {
UNSPECIFIED
QUEUED
RUNNING
COMPLETED
FAILED
ABORTED
PAUSED
NEW
}

enum CrawlTriggerType {
UNSPECIFIED
MANUAL
SCHEDULED
CI_TRIGGER
WEBHOOK
}

model ProjectMember {
id String @id @default(uuid()) @db.Uuid
projectId String @map("project_id") @db.Uuid
Expand Down Expand Up @@ -105,7 +124,7 @@ model TargetApplicationVersion {
updatedAt DateTime @updatedAt @map("updated_at")

targetApplication TargetApplication @relation(fields: [targetApplicationId], references: [id], onDelete: Cascade)

crawlSessions CrawlSession[]
@@unique([targetApplicationId, version])
@@map("target_application_versions")
}
Expand All @@ -126,4 +145,21 @@ model RegressionCodebase {
targetApplication TargetApplication @relation(fields: [targetApplicationId], references: [id], onDelete: Cascade)
@@map("regression_codebases")
@@unique([targetApplicationId, repositoryUrl])
}

model CrawlSession {
id String @id @default(uuid()) @map("crawl_session_id") @db.Uuid
appVersionId String @map("app_version_id") @db.Uuid
status CrawlStatus @default(NEW)
triggerType CrawlTriggerType @map("trigger_type")
config Json
stateCount Int @default(0) @map("state_count")
transitionCount Int @default(0) @map("transition_count")
createdAt DateTime @default(now()) @map("created_at")
startedAt DateTime? @map("started_at")
finishedAt DateTime? @map("finished_at")
error String? @db.Text
appVersion TargetApplicationVersion @relation(fields: [appVersionId], references: [id], onDelete: Cascade)

@@map("crawl_sessions")
}
Loading
Loading