-
Notifications
You must be signed in to change notification settings - Fork 731
feat: pick repo implementation [CM-2384] #3254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mbani01
merged 5 commits into
feat/git_integration_processing_worker
from
feat/git_integration_pick_repo
Sep 3, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7574e41
feat: db migrations
mbani01 b56134d
chore: dependencies
mbani01 d1146e2
feat: implement pick repo with locking
mbani01 ac5d72d
fix: retry when acquiring repo
mbani01 c4c7ee9
feat: clone service base implementation (#3276)
mbani01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/U1751635377__addLockedAtToRepositories.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Remove lockedAt column from git.repositories table | ||
-- Rollback for V1751635377__addLockedAtToRepositories.sql | ||
|
||
ALTER TABLE git.repositories | ||
DROP COLUMN IF EXISTS "lockedAt"; |
2 changes: 2 additions & 0 deletions
2
backend/src/database/migrations/U1752752559__addLastProcessedCommit.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE git.repositories | ||
DROP COLUMN IF EXISTS "lastProcessedCommit"; |
7 changes: 7 additions & 0 deletions
7
backend/src/database/migrations/U1754395778__addSegmentAndIntegrationToRepositories.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DROP INDEX IF EXISTS "ix_git_repositories_integrationId_segmentId"; | ||
DROP INDEX IF EXISTS "ix_git_repositories_segmentId"; | ||
DROP INDEX IF EXISTS "ix_git_repositories_integrationId"; | ||
|
||
ALTER TABLE git.repositories | ||
DROP COLUMN IF EXISTS "integrationId", | ||
DROP COLUMN IF EXISTS "segmentId"; |
1 change: 1 addition & 0 deletions
1
backend/src/database/migrations/U1754406504__deleteRepositoryIntegrations.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
2 changes: 2 additions & 0 deletions
2
backend/src/database/migrations/U1756301737__addLastMaintainerRunAt.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE git.repositories | ||
DROP COLUMN IF EXISTS "lastMaintainerRunAt"; |
2 changes: 2 additions & 0 deletions
2
backend/src/database/migrations/U1756301963__addMaintainerFile.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE git.repositories | ||
DROP COLUMN IF EXISTS "maintainerFile"; |
4 changes: 4 additions & 0 deletions
4
backend/src/database/migrations/U1756387524__addMaintainersFields.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ALTER TABLE "maintainersInternal" | ||
DROP COLUMN IF EXISTS "originalRole", | ||
DROP COLUMN IF EXISTS "startDate", | ||
DROP COLUMN IF EXISTS "endDate"; |
20 changes: 20 additions & 0 deletions
20
backend/src/database/migrations/U1756671476__createServiceExecutionsTable.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Down migration: Remove service executions table and related objects | ||
|
||
-- Drop trigger first | ||
DROP TRIGGER IF EXISTS trigger_auto_cleanup_service_executions ON git."serviceExecutions"; | ||
|
||
-- Drop trigger function | ||
DROP FUNCTION IF EXISTS git.trigger_cleanup_service_executions(); | ||
|
||
-- Drop indexes | ||
DROP INDEX IF EXISTS git."idx_serviceExecutions_composite"; | ||
DROP INDEX IF EXISTS git."idx_serviceExecutions_createdAt"; | ||
DROP INDEX IF EXISTS git."idx_serviceExecutions_status"; | ||
DROP INDEX IF EXISTS git."idx_serviceExecutions_operationType"; | ||
DROP INDEX IF EXISTS git."idx_serviceExecutions_repoId"; | ||
|
||
-- Drop table (this will also drop the foreign key constraint) | ||
DROP TABLE IF EXISTS git."serviceExecutions"; | ||
|
||
-- Drop ENUM type | ||
DROP TYPE IF EXISTS git.execution_status; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
backend/src/database/migrations/V1751635377__addLockedAtToRepositories.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Add lockedAt column to git.repositories table | ||
-- This column tracks when a repository was locked for processing | ||
|
||
ALTER TABLE git.repositories | ||
ADD COLUMN "lockedAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL; | ||
|
||
-- Add comment for documentation | ||
COMMENT ON COLUMN git.repositories."lockedAt" IS 'Timestamp when the repository was locked for processing, NULL if not locked'; |
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/V1752752559__addLastProcessedCommit.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE git.repositories | ||
ADD COLUMN "lastProcessedCommit" VARCHAR(64) DEFAULT NULL; | ||
|
||
-- Add comment for documentation | ||
COMMENT ON COLUMN git.repositories."lastProcessedCommit" IS 'The most recent commit hash that has been processed'; |
12 changes: 12 additions & 0 deletions
12
backend/src/database/migrations/V1754395778__addSegmentAndIntegrationToRepositories.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Add integrationId and segmentId columns to git.repositories table | ||
-- These columns reference segments and integrations from public schema | ||
-- Both are nullable and set to null on delete | ||
|
||
ALTER TABLE git.repositories | ||
ADD COLUMN "integrationId" UUID REFERENCES public.integrations (id) ON DELETE SET NULL, | ||
ADD COLUMN "segmentId" UUID REFERENCES public.segments (id) ON DELETE SET NULL; | ||
|
||
-- Create indexes for better query performance | ||
CREATE INDEX "ix_git_repositories_integrationId" ON git.repositories ("integrationId"); | ||
CREATE INDEX "ix_git_repositories_segmentId" ON git.repositories ("segmentId"); | ||
CREATE INDEX "ix_git_repositories_integrationId_segmentId" ON git.repositories ("integrationId", "segmentId"); |
4 changes: 4 additions & 0 deletions
4
backend/src/database/migrations/V1754406504__deleteRepositoryIntegrations.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DROP TRIGGER IF EXISTS cleanup_orphaned_repositories_trigger ON git."repositoryIntegrations"; | ||
DROP FUNCTION IF EXISTS git.cleanup_orphaned_repositories(); | ||
|
||
DROP TABLE IF EXISTS git."repositoryIntegrations"; |
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/V1756301737__addLastMaintainerRunAt.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE git.repositories | ||
ADD COLUMN "lastMaintainerRunAt" TIMESTAMP WITH TIME ZONE DEFAULT NULL; | ||
|
||
-- Add comment for documentation | ||
COMMENT ON COLUMN git.repositories."lastMaintainerRunAt" IS 'Timestamp of when the repository maintainer processing was last executed'; |
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/V1756301963__addMaintainerFile.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE git.repositories | ||
ADD COLUMN "maintainerFile" text DEFAULT NULL; | ||
|
||
-- Add comment for documentation | ||
COMMENT ON COLUMN git.repositories."maintainerFile" IS 'Name of the file containing repository maintainer information and responsibilities (e.g., MAINTAINERS, CODEOWNERS)'; |
5 changes: 5 additions & 0 deletions
5
backend/src/database/migrations/V1756387524__addMaintainersFields.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Add missing columns to maintainersInternal table (only if they don't exist) | ||
ALTER TABLE "maintainersInternal" | ||
ADD COLUMN IF NOT EXISTS "originalRole" VARCHAR(255), | ||
ADD COLUMN IF NOT EXISTS "startDate" TIMESTAMP WITHOUT TIME ZONE, | ||
ADD COLUMN IF NOT EXISTS "endDate" TIMESTAMP WITHOUT TIME ZONE; |
40 changes: 40 additions & 0 deletions
40
backend/src/database/migrations/V1756671476__createServiceExecutionsTable.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- Create ENUM type for execution status | ||
CREATE TYPE git.execution_status AS ENUM ('success', 'failure'); | ||
|
||
-- Create service executions table for tracking service execution metrics | ||
CREATE TABLE IF NOT EXISTS git."serviceExecutions" ( | ||
id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(), | ||
"repoId" UUID NOT NULL REFERENCES git.repositories(id) ON DELETE CASCADE, | ||
"operationType" VARCHAR(50) NOT NULL, -- Service name (e.g., 'Clone', 'Commit', etc.) | ||
"status" git.execution_status NOT NULL, | ||
"errorCode" VARCHAR(50), -- Custom error codes | ||
"errorMessage" TEXT, -- Detailed error message if status is error | ||
"executionTimeSec" DECIMAL NOT NULL, -- Execution time in seconds | ||
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
-- Create indexes for efficient querying | ||
CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_repoId" ON git."serviceExecutions"("repoId"); | ||
CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_operationType" ON git."serviceExecutions"("operationType"); | ||
CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_status" ON git."serviceExecutions"("status"); | ||
CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_createdAt" ON git."serviceExecutions"("createdAt"); | ||
CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_composite" ON git."serviceExecutions"("repoId", "operationType", "status"); | ||
|
||
CREATE OR REPLACE FUNCTION git.trigger_cleanup_service_executions() | ||
RETURNS trigger AS $$ | ||
BEGIN | ||
-- Only run cleanup 1% of the time (1 in 100 inserts) - due to high write load, keep cleanup minimal to avoid performance impact | ||
IF RANDOM() < 0.01 THEN | ||
DELETE FROM git."serviceExecutions" | ||
WHERE "createdAt" < NOW() - INTERVAL '14 days'; | ||
END IF; | ||
|
||
RETURN NEW; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
-- Create trigger that fires on each insert | ||
CREATE TRIGGER trigger_auto_cleanup_service_executions | ||
AFTER INSERT ON git."serviceExecutions" | ||
FOR EACH ROW | ||
EXECUTE FUNCTION git.trigger_cleanup_service_executions(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DOCKERFILE="./services/docker/Dockerfile.git_integration" | ||
CONTEXT="../" | ||
REPO="sjc.ocir.io/axbydjxa5zuh/git-integration" | ||
SERVICES="git-integration" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
# Base image for both stages | ||
FROM python:3.13.5-slim-bullseye AS base | ||
|
||
# Go builder stage: build the software-value binary and install scc | ||
FROM golang:1.25-alpine AS go-builder | ||
|
||
WORKDIR /go/src/software-value | ||
|
||
# Install scc using the official Go toolchain (specific version as per project README) | ||
RUN go install github.com/boyter/scc/[email protected] | ||
|
||
# Copy Go module files | ||
COPY ./services/apps/git_integration/src/crowdgit/services/software_value/go.mod ./ | ||
COPY ./services/apps/git_integration/src/crowdgit/services/software_value/go.sum ./ | ||
|
||
# Download dependencies | ||
RUN go mod download | ||
|
||
# Copy source code | ||
COPY ./services/apps/git_integration/src/crowdgit/services/software_value/ ./ | ||
|
||
# Build the binary | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" -o software-value ./ | ||
|
||
# Builder stage: install build dependencies, uv, and dependencies | ||
FROM base AS builder | ||
|
||
|
@@ -59,11 +80,17 @@ WORKDIR /usr/crowd/app | |
COPY --from=builder /usr/crowd/app/.venv /usr/crowd/app/.venv | ||
COPY --from=builder /usr/crowd/app /usr/crowd/app | ||
|
||
# Copy both software-value and scc binaries from go-builder stage | ||
COPY --from=go-builder /go/src/software-value/software-value /usr/local/bin/software-value | ||
COPY --from=go-builder /go/bin/scc /usr/local/bin/scc | ||
|
||
# Add virtual environment bin to PATH | ||
ENV PATH="/usr/crowd/app/.venv/bin:$PATH" | ||
|
||
# Make runner script executable | ||
RUN chmod +x ./src/runner.sh | ||
# Make runner script and binaries executable | ||
RUN chmod +x ./src/runner.sh \ | ||
&& chmod +x /usr/local/bin/software-value \ | ||
&& chmod +x /usr/local/bin/scc | ||
|
||
EXPOSE 8085 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: would be nice if we can add documentation on this as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I've added it to the TODOs 🫡