Skip to content

Commit d639dc5

Browse files
committed
perf(ci): split runsRepository 2->4 + webapp 8->10 shards (makespan ~90s)
1 parent b07889f commit d639dc5

6 files changed

Lines changed: 808 additions & 772 deletions

File tree

.github/workflows/unit-tests-webapp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
# one flaky shard shouldn't cancel its siblings - lets us re-run only the failed shard
2020
fail-fast: false
2121
matrix:
22-
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
23-
shardTotal: [8]
22+
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
23+
shardTotal: [10]
2424
env:
2525
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
2626
SHARD_INDEX: ${{ matrix.shardIndex }}

apps/webapp/test/runsRepository.part1.test.ts

Lines changed: 2 additions & 328 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { setupClickhouseReplication } from "./utils/replicationUtils";
1313

1414
vi.setConfig({ testTimeout: 60_000 });
1515

16-
describe("RunsRepository (part 1/2)", () => {
16+
describe("RunsRepository (part 1/4)", () => {
1717
replicationContainerTest(
1818
"should list runs, using clickhouse as the source",
1919
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
@@ -420,330 +420,4 @@ describe("RunsRepository (part 1/2)", () => {
420420
}
421421
);
422422

423-
replicationContainerTest(
424-
"should filter runs by tags",
425-
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
426-
const { clickhouse } = await setupClickhouseReplication({
427-
prisma,
428-
databaseUrl: postgresContainer.getConnectionUri(),
429-
clickhouseUrl: clickhouseContainer.getConnectionUrl(),
430-
redisOptions,
431-
});
432-
433-
const organization = await prisma.organization.create({
434-
data: {
435-
title: "test",
436-
slug: "test",
437-
},
438-
});
439-
440-
const project = await prisma.project.create({
441-
data: {
442-
name: "test",
443-
slug: "test",
444-
organizationId: organization.id,
445-
externalRef: "test",
446-
},
447-
});
448-
449-
const runtimeEnvironment = await prisma.runtimeEnvironment.create({
450-
data: {
451-
slug: "test",
452-
type: "DEVELOPMENT",
453-
projectId: project.id,
454-
organizationId: organization.id,
455-
apiKey: "test",
456-
pkApiKey: "test",
457-
shortcode: "test",
458-
},
459-
});
460-
461-
// Create runs with different tags
462-
const taskRun1 = await prisma.taskRun.create({
463-
data: {
464-
friendlyId: "run_urgent",
465-
taskIdentifier: "my-task",
466-
runTags: ["urgent", "production"],
467-
payload: JSON.stringify({ foo: "bar" }),
468-
traceId: "1234",
469-
spanId: "1234",
470-
queue: "test",
471-
runtimeEnvironmentId: runtimeEnvironment.id,
472-
projectId: project.id,
473-
organizationId: organization.id,
474-
environmentType: "DEVELOPMENT",
475-
engine: "V2",
476-
},
477-
});
478-
479-
const taskRun2 = await prisma.taskRun.create({
480-
data: {
481-
friendlyId: "run_regular",
482-
taskIdentifier: "my-task",
483-
runTags: ["regular", "development"],
484-
payload: JSON.stringify({ foo: "bar" }),
485-
traceId: "1235",
486-
spanId: "1235",
487-
queue: "test",
488-
runtimeEnvironmentId: runtimeEnvironment.id,
489-
projectId: project.id,
490-
organizationId: organization.id,
491-
environmentType: "DEVELOPMENT",
492-
engine: "V2",
493-
},
494-
});
495-
496-
const taskRun3 = await prisma.taskRun.create({
497-
data: {
498-
friendlyId: "run_urgent_dev",
499-
taskIdentifier: "my-task",
500-
runTags: ["urgent", "development"],
501-
payload: JSON.stringify({ foo: "bar" }),
502-
traceId: "1236",
503-
spanId: "1236",
504-
queue: "test",
505-
runtimeEnvironmentId: runtimeEnvironment.id,
506-
projectId: project.id,
507-
organizationId: organization.id,
508-
environmentType: "DEVELOPMENT",
509-
engine: "V2",
510-
},
511-
});
512-
513-
await setTimeout(1000);
514-
515-
const runsRepository = new RunsRepository({
516-
prisma,
517-
clickhouse,
518-
});
519-
520-
// Test filtering by tags
521-
const { runs } = await runsRepository.listRuns({
522-
page: { size: 10 },
523-
projectId: project.id,
524-
environmentId: runtimeEnvironment.id,
525-
organizationId: organization.id,
526-
tags: ["urgent"],
527-
});
528-
529-
expect(runs).toHaveLength(2);
530-
expect(runs.map((r) => r.friendlyId).sort()).toEqual(["run_urgent", "run_urgent_dev"]);
531-
}
532-
);
533-
534-
replicationContainerTest(
535-
"should filter runs by scheduleId",
536-
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
537-
const { clickhouse } = await setupClickhouseReplication({
538-
prisma,
539-
databaseUrl: postgresContainer.getConnectionUri(),
540-
clickhouseUrl: clickhouseContainer.getConnectionUrl(),
541-
redisOptions,
542-
});
543-
544-
const organization = await prisma.organization.create({
545-
data: {
546-
title: "test",
547-
slug: "test",
548-
},
549-
});
550-
551-
const project = await prisma.project.create({
552-
data: {
553-
name: "test",
554-
slug: "test",
555-
organizationId: organization.id,
556-
externalRef: "test",
557-
},
558-
});
559-
560-
const runtimeEnvironment = await prisma.runtimeEnvironment.create({
561-
data: {
562-
slug: "test",
563-
type: "DEVELOPMENT",
564-
projectId: project.id,
565-
organizationId: organization.id,
566-
apiKey: "test",
567-
pkApiKey: "test",
568-
shortcode: "test",
569-
},
570-
});
571-
572-
// Create runs with different schedule IDs
573-
await prisma.taskRun.create({
574-
data: {
575-
friendlyId: "run_scheduled_1",
576-
taskIdentifier: "my-task",
577-
scheduleId: "schedule_1",
578-
payload: JSON.stringify({ foo: "bar" }),
579-
traceId: "1234",
580-
spanId: "1234",
581-
queue: "test",
582-
runtimeEnvironmentId: runtimeEnvironment.id,
583-
projectId: project.id,
584-
organizationId: organization.id,
585-
environmentType: "DEVELOPMENT",
586-
engine: "V2",
587-
},
588-
});
589-
590-
await prisma.taskRun.create({
591-
data: {
592-
friendlyId: "run_scheduled_2",
593-
taskIdentifier: "my-task",
594-
scheduleId: "schedule_2",
595-
payload: JSON.stringify({ foo: "bar" }),
596-
traceId: "1235",
597-
spanId: "1235",
598-
queue: "test",
599-
runtimeEnvironmentId: runtimeEnvironment.id,
600-
projectId: project.id,
601-
organizationId: organization.id,
602-
environmentType: "DEVELOPMENT",
603-
engine: "V2",
604-
},
605-
});
606-
607-
await prisma.taskRun.create({
608-
data: {
609-
friendlyId: "run_unscheduled",
610-
taskIdentifier: "my-task",
611-
payload: JSON.stringify({ foo: "bar" }),
612-
traceId: "1236",
613-
spanId: "1236",
614-
queue: "test",
615-
runtimeEnvironmentId: runtimeEnvironment.id,
616-
projectId: project.id,
617-
organizationId: organization.id,
618-
environmentType: "DEVELOPMENT",
619-
engine: "V2",
620-
},
621-
});
622-
623-
await setTimeout(1000);
624-
625-
const runsRepository = new RunsRepository({
626-
prisma,
627-
clickhouse,
628-
});
629-
630-
// Test filtering by schedule ID
631-
const { runs } = await runsRepository.listRuns({
632-
page: { size: 10 },
633-
projectId: project.id,
634-
environmentId: runtimeEnvironment.id,
635-
organizationId: organization.id,
636-
scheduleId: "schedule_1",
637-
});
638-
639-
expect(runs).toHaveLength(1);
640-
expect(runs[0].friendlyId).toBe("run_scheduled_1");
641-
}
642-
);
643-
644-
replicationContainerTest(
645-
"should filter runs by isTest flag",
646-
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
647-
const { clickhouse } = await setupClickhouseReplication({
648-
prisma,
649-
databaseUrl: postgresContainer.getConnectionUri(),
650-
clickhouseUrl: clickhouseContainer.getConnectionUrl(),
651-
redisOptions,
652-
});
653-
654-
const organization = await prisma.organization.create({
655-
data: {
656-
title: "test",
657-
slug: "test",
658-
},
659-
});
660-
661-
const project = await prisma.project.create({
662-
data: {
663-
name: "test",
664-
slug: "test",
665-
organizationId: organization.id,
666-
externalRef: "test",
667-
},
668-
});
669-
670-
const runtimeEnvironment = await prisma.runtimeEnvironment.create({
671-
data: {
672-
slug: "test",
673-
type: "DEVELOPMENT",
674-
projectId: project.id,
675-
organizationId: organization.id,
676-
apiKey: "test",
677-
pkApiKey: "test",
678-
shortcode: "test",
679-
},
680-
});
681-
682-
// Create test and non-test runs
683-
await prisma.taskRun.create({
684-
data: {
685-
friendlyId: "run_test",
686-
taskIdentifier: "my-task",
687-
isTest: true,
688-
payload: JSON.stringify({ foo: "bar" }),
689-
traceId: "1234",
690-
spanId: "1234",
691-
queue: "test",
692-
runtimeEnvironmentId: runtimeEnvironment.id,
693-
projectId: project.id,
694-
organizationId: organization.id,
695-
environmentType: "DEVELOPMENT",
696-
engine: "V2",
697-
},
698-
});
699-
700-
await prisma.taskRun.create({
701-
data: {
702-
friendlyId: "run_production",
703-
taskIdentifier: "my-task",
704-
isTest: false,
705-
payload: JSON.stringify({ foo: "bar" }),
706-
traceId: "1235",
707-
spanId: "1235",
708-
queue: "test",
709-
runtimeEnvironmentId: runtimeEnvironment.id,
710-
projectId: project.id,
711-
organizationId: organization.id,
712-
environmentType: "DEVELOPMENT",
713-
engine: "V2",
714-
},
715-
});
716-
717-
await setTimeout(1000);
718-
719-
const runsRepository = new RunsRepository({
720-
prisma,
721-
clickhouse,
722-
});
723-
724-
// Test filtering by isTest=true
725-
const testRuns = await runsRepository.listRuns({
726-
page: { size: 10 },
727-
projectId: project.id,
728-
environmentId: runtimeEnvironment.id,
729-
organizationId: organization.id,
730-
isTest: true,
731-
});
732-
733-
expect(testRuns.runs).toHaveLength(1);
734-
expect(testRuns.runs[0].friendlyId).toBe("run_test");
735-
736-
// Test filtering by isTest=false
737-
const productionRuns = await runsRepository.listRuns({
738-
page: { size: 10 },
739-
projectId: project.id,
740-
environmentId: runtimeEnvironment.id,
741-
organizationId: organization.id,
742-
isTest: false,
743-
});
744-
745-
expect(productionRuns.runs).toHaveLength(1);
746-
expect(productionRuns.runs[0].friendlyId).toBe("run_production");
747-
}
748-
);
749-
});
423+
});

0 commit comments

Comments
 (0)