Skip to content

Commit

Permalink
chore: repo overall update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 27, 2024
1 parent 70a4ebb commit 8bbd8cd
Show file tree
Hide file tree
Showing 31 changed files with 6,195 additions and 174 deletions.
3 changes: 3 additions & 0 deletions packages/canyon-collect/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ pids

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json


db/sql
5 changes: 4 additions & 1 deletion packages/canyon-collect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"prisma": "5.16.1",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"zod": "^3.23.8"
"zod": "^3.23.8",
"@nestjs/typeorm": "^10.0.2",
"typeorm": "^0.3.20",
"sqlite3": "^5.1.7"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down
51 changes: 7 additions & 44 deletions packages/canyon-collect/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,14 @@ model Coverage {
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(3)
@@map("canyon_v2_coverage")
@@map("canyon_v3_coverage")
}

model CoverageOld {
id String @id @default(cuid())
sha String @map("sha")
branch String
compareTarget String @map("compare_target")
provider String
buildProvider String @map("build_provider") // 通过侦测CI环境变量来判断
buildID String @map("build_id")
projectID String @map("project_id")
reporter String
reportID String @map("report_id") // 未来聚合的一句,区分case
covType String @map("cov_type") // 普通类型,all、agg
// 代码覆盖率
branchesTotal Int @map("branches_total")
branchesCovered Int @map("branches_covered")
functionsTotal Int @map("functions_total")
functionsCovered Int @map("functions_covered")
linesTotal Int @map("lines_total")
linesCovered Int @map("lines_covered")
statementsTotal Int @map("statements_total")
statementsCovered Int @map("statements_covered")
newlinesTotal Int @map("newlines_total")
newlinesCovered Int @map("newlines_covered")
summary String?
// 代码覆盖率详情
hit String
// 通用
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(3)
@@map("coverage")
}

model CoverageMap {
id String @id @default(cuid())
projectID String @map("project_id")
sha String @map("sha")
path String
map String
model Distributedlock {
lockName String @id
isLocked Boolean @default(false)
lockTimestamp DateTime?
lockExpiration DateTime?
// 再添加一个path索引
@@index(fields: [path])
@@index([projectID, sha]) // 联合索引
@@map("coverage_map")
@@map("canyon_v3_distributedlock")
}
13 changes: 11 additions & 2 deletions packages/canyon-collect/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CollectModule } from './apps/collect/collect.module';
import { PrismaService } from './prisma/prisma.service';

import { TypeOrmModule } from '@nestjs/typeorm';
import { CoveragediskEntity } from './apps/collect/entity/coveragedisk.entity';
@Module({
imports: [CollectModule],
imports: [
TypeOrmModule.forRoot({
type: 'sqlite',
database: 'db/sql',
synchronize: true,
entities: [CoveragediskEntity],
}),
CollectModule,
],
controllers: [AppController],
providers: [AppService, PrismaService],
})
Expand Down
26 changes: 20 additions & 6 deletions packages/canyon-collect/src/apps/collect/collect.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import { Module } from '@nestjs/common';
import { CollectController } from './collect.controller';
import { PrismaModule } from '../../prisma/prisma.module';
import { CoverageClientService } from './services/coverage-client.service';
import { CoverageMapClientService } from './services/coverage-map-client.service';
// import {AppController} from "../../app.controller";
// import {AppService} from "../../app.service";
import { CoveragediskService } from './services/core/coveragedisk.service';
import { ConsumerCoverageService } from './services/core/consumer-coverage.service';
import { CoveragediskEntity } from './entity/coveragedisk.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PrismaService } from '../../prisma/prisma.service';

@Module({
imports: [PrismaModule],
imports: [TypeOrmModule.forFeature([CoveragediskEntity])],
controllers: [CollectController],
providers: [CoverageClientService, CoverageMapClientService],
providers: [
PrismaService,
CoverageClientService,
CoverageMapClientService,
ConsumerCoverageService,
CoveragediskService,
],
})
export class CollectModule {}
export class CollectModule {
constructor(
private readonly consumerCoverageService: ConsumerCoverageService,
) {
this.consumerCoverageService.invoke();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('coveragedisk')
export class CoveragediskEntity {
@PrimaryGeneratedColumn()
id: number;

@Column()
pid: string;

@Column()
projectID: string;

@Column()
reportID: string;

@Column()
sha: string;

@Column()
data: string;

@Column()
createdAt: Date;
}
Loading

0 comments on commit 8bbd8cd

Please sign in to comment.