From 4b7bcd37c3f671028416d11f6c14fac9e4ef0162 Mon Sep 17 00:00:00 2001 From: zhangtao25 Date: Tue, 19 Nov 2024 10:40:44 +0800 Subject: [PATCH] chore: repo overall update --- .../src/apps/collect/collect.controller.ts | 2 +- .../apps/collect/dto/coverage-map-client.dto.ts | 8 ++++---- .../collect/services/coverage-client.service.ts | 17 ++++++----------- .../services/coverage-map-client.service.ts | 11 ++++++----- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/canyon-collect/src/apps/collect/collect.controller.ts b/packages/canyon-collect/src/apps/collect/collect.controller.ts index a1a5de97..fe2f1540 100644 --- a/packages/canyon-collect/src/apps/collect/collect.controller.ts +++ b/packages/canyon-collect/src/apps/collect/collect.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Post, UseInterceptors } from '@nestjs/common'; +import { Body, Controller, Post, UseInterceptors } from '@nestjs/common'; import { PrismaService } from '../../prisma/prisma.service'; import { CoverageClientService } from './services/coverage-client.service'; import { CoverageClientDto } from './dto/coverage-client.dto'; diff --git a/packages/canyon-collect/src/apps/collect/dto/coverage-map-client.dto.ts b/packages/canyon-collect/src/apps/collect/dto/coverage-map-client.dto.ts index 2142dbd5..5e9e31bb 100755 --- a/packages/canyon-collect/src/apps/collect/dto/coverage-map-client.dto.ts +++ b/packages/canyon-collect/src/apps/collect/dto/coverage-map-client.dto.ts @@ -15,10 +15,10 @@ export class CoverageMapClientDto { @IsNotEmpty({ message: 'sha 不能为空' }) sha: string; - // @IsString() - // @MinLength(1, { message: "branch长度最小为1" }) - // @IsOptional({ message: "branch 可以为空" }) - // branch: string; + @IsString() + @MinLength(1, { message: 'branch长度最小为1' }) + @IsOptional({ message: 'branch 可以为空' }) + branch: string; // @IsString() // @MinLength(1, { message: "buildID长度最小为1" }) diff --git a/packages/canyon-collect/src/apps/collect/services/coverage-client.service.ts b/packages/canyon-collect/src/apps/collect/services/coverage-client.service.ts index e01902ac..a0c913cc 100755 --- a/packages/canyon-collect/src/apps/collect/services/coverage-client.service.ts +++ b/packages/canyon-collect/src/apps/collect/services/coverage-client.service.ts @@ -1,21 +1,13 @@ -import { - HttpException, - Injectable, - UnauthorizedException, -} from '@nestjs/common'; +import { HttpException, Injectable } from '@nestjs/common'; import { PrismaService } from '../../../prisma/prisma.service'; import { IstanbulHitMapSchema } from '../../../zod/istanbul.zod'; import { compressedData } from '../../../utils/zstd'; -import { - formatReportObject, - regularData, - resetCoverageData, -} from '../../../utils/coverage'; +import { formatReportObject, regularData } from '../../../utils/coverage'; @Injectable() export class CoverageClientService { constructor(private readonly prisma: PrismaService) {} - async invoke({ sha, projectID, coverage, instrumentCwd, branch, reportID }) { + async invoke({ sha, projectID, coverage, instrumentCwd }) { // 1. 检查是否上传map const coverageMapCount = await this.prisma.coverage.count({ where: { @@ -47,6 +39,9 @@ export class CoverageClientService { // const size = new TextEncoder().encode(formatCoverageStr).length; const compressedFormatCoverageStr = await compressedData(formatCoverageStr); + // 先不考虑分布式,直接存储 + // this.prisma.coverage.upsert() + return this.prisma.coverage.updateMany({ where: { projectID: projectID, diff --git a/packages/canyon-collect/src/apps/collect/services/coverage-map-client.service.ts b/packages/canyon-collect/src/apps/collect/services/coverage-map-client.service.ts index d8e4acbd..2cf3c0ea 100755 --- a/packages/canyon-collect/src/apps/collect/services/coverage-map-client.service.ts +++ b/packages/canyon-collect/src/apps/collect/services/coverage-map-client.service.ts @@ -4,7 +4,7 @@ import { // IstanbulHitMapSchema, IstanbulMapMapSchema, } from '../../../zod/istanbul.zod'; -import { compressedData, decompressedData } from '../../../utils/zstd'; +import { compressedData } from '../../../utils/zstd'; import { formatReportObject, regularData, @@ -15,7 +15,7 @@ import { coverageObj } from '../models/coverage.model'; @Injectable() export class CoverageMapClientService { constructor(private readonly prisma: PrismaService) {} - async invoke({ sha, projectID, coverage, instrumentCwd, branch, reportID }) { + async invoke({ sha, projectID, coverage, instrumentCwd, branch }) { // const { sha, projectID } = invoke; const coverageObject = @@ -54,12 +54,13 @@ export class CoverageMapClientService { projectID: projectID, sha: sha, reporter: 'canyon', - reportID: reportID || sha, + reportID: sha, covType: 'all', //map都是all statementsTotal: 0, statementsCovered: 0, - summary: '', - hit: '', + //空bytes + summary: Buffer.from([]), + hit: Buffer.from([]), map: compressedFormatCoverageStr, }, })