From 6b9f84615402ab54ce342925dfc8603fa02af53c Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Wed, 20 Oct 2021 22:48:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=20pipeline=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintcache | 1 + package-lock.json | 6 +++--- src/app.module.ts | 2 +- .../exceptions/application.exception.ts | 4 ++-- src/commons/filters/all.exception-filter.ts | 10 +++++++--- src/commons/services/base-db.service.ts | 1 + .../configurations.resolver.spec.ts | 6 ++++++ .../configurations.service.spec.ts | 7 ++++++- src/configurations/configurations.service.ts | 18 +++++++++++++++++- .../dtos/create-pipeline-task.input.ts | 2 +- .../models/work-unit-metadata.model.ts | 2 +- src/pipeline-tasks/pipeline-tasks.resolver.ts | 9 --------- .../pipeline-tasks.service.spec.ts | 2 -- src/pipeline-tasks/pipeline-tasks.service.ts | 3 --- src/pipelines/dtos/create-pipeline.input.ts | 4 ++++ src/pipelines/pipeline.entity.ts | 5 ++++- src/pipelines/pipelines.service.spec.ts | 3 --- src/pipelines/pipelines.service.ts | 4 +++- src/projects/project.entity.ts | 2 +- src/repos/dtos/branch-list.model.ts | 7 +------ src/repos/repos.service.spec.ts | 6 +++--- src/webhooks/webhooks.module.ts | 5 ++--- 22 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 .eslintcache diff --git a/.eslintcache b/.eslintcache new file mode 100644 index 0000000..9cb4aaa --- /dev/null +++ b/.eslintcache @@ -0,0 +1 @@ +[{"/Users/ivan/Projects/Fennec/fennec-be/src/app.module.ts":"1","/Users/ivan/Projects/Fennec/fennec-be/src/commons/exceptions/application.exception.ts":"2","/Users/ivan/Projects/Fennec/fennec-be/src/commons/filters/all.exception-filter.ts":"3","/Users/ivan/Projects/Fennec/fennec-be/src/commons/services/base-db.service.ts":"4","/Users/ivan/Projects/Fennec/fennec-be/src/configurations/configurations.service.spec.ts":"5","/Users/ivan/Projects/Fennec/fennec-be/src/configurations/configurations.service.ts":"6","/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/dtos/create-pipeline-task.input.ts":"7","/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/models/work-unit-metadata.model.ts":"8","/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.resolver.ts":"9","/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.service.spec.ts":"10","/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.service.ts":"11","/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/dtos/create-pipeline.input.ts":"12","/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipeline.entity.ts":"13","/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipelines.service.spec.ts":"14","/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipelines.service.ts":"15","/Users/ivan/Projects/Fennec/fennec-be/src/projects/project.entity.ts":"16","/Users/ivan/Projects/Fennec/fennec-be/src/repos/dtos/branch-list.model.ts":"17","/Users/ivan/Projects/Fennec/fennec-be/src/repos/repos.service.spec.ts":"18","/Users/ivan/Projects/Fennec/fennec-be/src/webhooks/webhooks.module.ts":"19"},{"size":4521,"mtime":1634657570496,"results":"20","hashOfConfig":"21"},{"size":591,"mtime":1634657293673,"results":"22","hashOfConfig":"21"},{"size":1812,"mtime":1634657540601,"results":"23","hashOfConfig":"21"},{"size":5812,"mtime":1634657611831,"results":"24","hashOfConfig":"21"},{"size":1299,"mtime":1634657534660,"results":"25","hashOfConfig":"21"},{"size":1790,"mtime":1634558065347,"results":"26","hashOfConfig":"21"},{"size":230,"mtime":1634657622737,"results":"27","hashOfConfig":"21"},{"size":459,"mtime":1634657515596,"results":"28","hashOfConfig":"21"},{"size":1931,"mtime":1634657508547,"results":"29","hashOfConfig":"21"},{"size":3376,"mtime":1634657489760,"results":"30","hashOfConfig":"21"},{"size":5110,"mtime":1634657434396,"results":"31","hashOfConfig":"21"},{"size":690,"mtime":1634444141145,"results":"32","hashOfConfig":"21"},{"size":668,"mtime":1634385769403,"results":"33","hashOfConfig":"21"},{"size":1293,"mtime":1634657449820,"results":"34","hashOfConfig":"21"},{"size":2635,"mtime":1634558988513,"results":"35","hashOfConfig":"21"},{"size":457,"mtime":1634657410911,"results":"36","hashOfConfig":"21"},{"size":391,"mtime":1634657306247,"results":"37","hashOfConfig":"21"},{"size":7004,"mtime":1634657400244,"results":"38","hashOfConfig":"21"},{"size":538,"mtime":1634657473044,"results":"39","hashOfConfig":"21"},{"filePath":"40","messages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"cvxbq5",{"filePath":"42","messages":"43","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"44","messages":"45","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"50","messages":"51","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"62","messages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/ivan/Projects/Fennec/fennec-be/src/app.module.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/commons/exceptions/application.exception.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/commons/filters/all.exception-filter.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/commons/services/base-db.service.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/configurations/configurations.service.spec.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/configurations/configurations.service.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/dtos/create-pipeline-task.input.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/models/work-unit-metadata.model.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.resolver.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.service.spec.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipeline-tasks/pipeline-tasks.service.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/dtos/create-pipeline.input.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipeline.entity.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipelines.service.spec.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/pipelines/pipelines.service.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/projects/project.entity.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/repos/dtos/branch-list.model.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/repos/repos.service.spec.ts",[],"/Users/ivan/Projects/Fennec/fennec-be/src/webhooks/webhooks.module.ts",[]] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1bc83e8..c4ae0f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,7 @@ } }, "../configuration": { - "version": "1.0.0", + "version": "0.0.1", "license": "MIT", "dependencies": { "debug": "^4.3.2", @@ -90,7 +90,7 @@ "@types/node": "^14.17.17", "rimraf": "^3.0.2", "ts-node": "^10.2.1", - "typescript": "^4.4.3" + "typescript": "^4.4.4" } }, "node_modules/@angular-devkit/core": { @@ -23187,7 +23187,7 @@ "js-yaml": "^4.1.0", "rimraf": "^3.0.2", "ts-node": "^10.2.1", - "typescript": "^4.4.3" + "typescript": "^4.4.4" } }, "consola": { diff --git a/src/app.module.ts b/src/app.module.ts index 3459125..d60aba0 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -65,7 +65,7 @@ import { ConfigurationsModule } from './configurations/configurations.module'; playground: true, autoSchemaFile: true, installSubscriptionHandlers: true, - context: ({ req, connection, ...args }) => { + context: ({ req, connection }) => { return connection ? { req: connection.context } : { req }; }, subscriptions: { diff --git a/src/commons/exceptions/application.exception.ts b/src/commons/exceptions/application.exception.ts index 1a01717..574d64b 100644 --- a/src/commons/exceptions/application.exception.ts +++ b/src/commons/exceptions/application.exception.ts @@ -13,9 +13,9 @@ export class ApplicationException extends Error { this.error = message.error; this.message = message.message as any; } else if (typeof message === 'string') { - super((message as unknown) as any); + super(message as unknown as any); } else { - super((message as unknown) as any); + super(message as unknown as any); } } diff --git a/src/commons/filters/all.exception-filter.ts b/src/commons/filters/all.exception-filter.ts index 7daaefa..133dd31 100644 --- a/src/commons/filters/all.exception-filter.ts +++ b/src/commons/filters/all.exception-filter.ts @@ -19,12 +19,16 @@ export class HttpExceptionFilter implements ExceptionFilter { case 'graphql': { const errorName = exception.message; const extensions: Record = {}; - const err = exception.getResponse(); + const err = exception.getResponse() as any; if (typeof err === 'string') { extensions.message = err; } else { - Object.assign(extensions, (err as any).extension); - extensions.message = (err as any).message; + Object.assign(extensions, err.extension); + if (typeof err.message === 'string') { + extensions.message = err.message; + } else { + extensions.message = err.error; + } } extensions.error = errorName; this.logger.error(extensions); diff --git a/src/commons/services/base-db.service.ts b/src/commons/services/base-db.service.ts index 9235755..00c15c7 100644 --- a/src/commons/services/base-db.service.ts +++ b/src/commons/services/base-db.service.ts @@ -126,6 +126,7 @@ export class BaseDbService extends TypeormHelper { } } + // eslint-disable-next-line @typescript-eslint/no-unused-vars async canYouRemoveWithIds(ids: string[]): Promise { return; } diff --git a/src/configurations/configurations.resolver.spec.ts b/src/configurations/configurations.resolver.spec.ts index 5be2c48..8f6e97f 100644 --- a/src/configurations/configurations.resolver.spec.ts +++ b/src/configurations/configurations.resolver.spec.ts @@ -1,3 +1,4 @@ +import { JwtService } from '@nestjs-lib/auth'; import { Test, TestingModule } from '@nestjs/testing'; import { ConfigurationsResolver } from './configurations.resolver'; import { ConfigurationsService } from './configurations.service'; @@ -8,10 +9,15 @@ describe('ConfigurationsResolver', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ + ConfigurationsResolver, { provide: ConfigurationsService, useValue: {}, }, + { + provide: JwtService, + useValue: {}, + }, ], }).compile(); diff --git a/src/configurations/configurations.service.spec.ts b/src/configurations/configurations.service.spec.ts index 61ded7f..1ea71cd 100644 --- a/src/configurations/configurations.service.spec.ts +++ b/src/configurations/configurations.service.spec.ts @@ -3,6 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ConfigurationsService } from './configurations.service'; import { Configuration } from './entities/configuration.entity'; import { IsNull } from 'typeorm'; +import { Etcd3 } from 'etcd3'; describe('ConfigurationsService', () => { let service: ConfigurationsService; @@ -15,6 +16,10 @@ describe('ConfigurationsService', () => { provide: getRepositoryToken(Configuration), useValue: {}, }, + { + provide: Etcd3, + useValue: {}, + }, ], }).compile(); @@ -28,7 +33,7 @@ describe('ConfigurationsService', () => { describe('findOneByConditions', () => { it('should select by projectId only', async () => { const entity = new Configuration(); - const findOne = jest.fn((_) => Promise.resolve(entity)); + const findOne = jest.fn(() => Promise.resolve(entity)); service['repository'].findOne = findOne; await expect( diff --git a/src/configurations/configurations.service.ts b/src/configurations/configurations.service.ts index e2bd90f..394ebcd 100644 --- a/src/configurations/configurations.service.ts +++ b/src/configurations/configurations.service.ts @@ -26,7 +26,7 @@ export class ConfigurationsService extends BaseDbService { entity = this.repository.create(dto); } entity = await this.repository.save(entity); - this.etcd.put(`share/config/${entity.id}`).value(entity.content); + await this.syncToEtcd(entity); return entity; } @@ -36,4 +36,20 @@ export class ConfigurationsService extends BaseDbService { } return await this.repository.findOne(dto); } + + async syncToEtcd({ pipelineId, id }: { pipelineId?: string; id?: string }) { + const config = await this.repository.findOneOrFail({ + where: { pipelineId, id }, + relations: ['pipeline', 'project'], + }); + + await this.etcd + .put(`share/config/${config.id}`) + .value(config.content) + .exec(); + await this.etcd + .put(`share/config/${config.pipeline.environment}/${config.project.name}`) + .value(config.content) + .exec(); + } } diff --git a/src/pipeline-tasks/dtos/create-pipeline-task.input.ts b/src/pipeline-tasks/dtos/create-pipeline-task.input.ts index 0119481..340d50e 100644 --- a/src/pipeline-tasks/dtos/create-pipeline-task.input.ts +++ b/src/pipeline-tasks/dtos/create-pipeline-task.input.ts @@ -1,4 +1,4 @@ -import { Field, InputType } from '@nestjs/graphql'; +import { InputType } from '@nestjs/graphql'; import { PipelineUnits } from '../enums/pipeline-units.enum'; @InputType() diff --git a/src/pipeline-tasks/models/work-unit-metadata.model.ts b/src/pipeline-tasks/models/work-unit-metadata.model.ts index b884fc3..5788ec6 100644 --- a/src/pipeline-tasks/models/work-unit-metadata.model.ts +++ b/src/pipeline-tasks/models/work-unit-metadata.model.ts @@ -1,6 +1,6 @@ import { Field, InputType, Int, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; -import { IsInstance, isInstance, ValidateNested } from 'class-validator'; +import { IsInstance, ValidateNested } from 'class-validator'; import { WorkUnit } from './work-unit.model'; @InputType('WorkUnitMetadataInput') diff --git a/src/pipeline-tasks/pipeline-tasks.resolver.ts b/src/pipeline-tasks/pipeline-tasks.resolver.ts index 4b242cc..d30d246 100644 --- a/src/pipeline-tasks/pipeline-tasks.resolver.ts +++ b/src/pipeline-tasks/pipeline-tasks.resolver.ts @@ -35,15 +35,6 @@ export class PipelineTasksResolver { ); } - @Subscription(() => PipelineTask, { - resolve: (value) => { - return value; - }, - }) - async pipelineTaskChanged(@Args('id') id: string) { - // return await this.service.watchTaskUpdated(id); - } - @Query(() => [PipelineTask]) async listPipelineTaskByPipelineId(@Args('pipelineId') pipelineId: string) { return await this.service.listTasksByPipelineId(pipelineId); diff --git a/src/pipeline-tasks/pipeline-tasks.service.spec.ts b/src/pipeline-tasks/pipeline-tasks.service.spec.ts index 2113ad3..b7f7b2e 100644 --- a/src/pipeline-tasks/pipeline-tasks.service.spec.ts +++ b/src/pipeline-tasks/pipeline-tasks.service.spec.ts @@ -12,7 +12,6 @@ describe('PipelineTasksService', () => { let service: PipelineTasksService; let module: TestingModule; let taskRepository: Repository; - let pipelineRepository: Repository; beforeEach(async () => { module = await Test.createTestingModule({ @@ -43,7 +42,6 @@ describe('PipelineTasksService', () => { service = module.get(PipelineTasksService); taskRepository = module.get(getRepositoryToken(PipelineTask)); - pipelineRepository = module.get(getRepositoryToken(Pipeline)); jest .spyOn(taskRepository, 'save') .mockImplementation(async (data: any) => data); diff --git a/src/pipeline-tasks/pipeline-tasks.service.ts b/src/pipeline-tasks/pipeline-tasks.service.ts index 9782255..b30e9af 100644 --- a/src/pipeline-tasks/pipeline-tasks.service.ts +++ b/src/pipeline-tasks/pipeline-tasks.service.ts @@ -4,7 +4,6 @@ import { PipelineTask } from './pipeline-task.entity'; import { Repository } from 'typeorm'; import { CreatePipelineTaskInput } from './dtos/create-pipeline-task.input'; import { Pipeline } from '../pipelines/pipeline.entity'; -import debug from 'debug'; import { AmqpConnection, RabbitRPC } from '@golevelup/nestjs-rabbitmq'; import { EXCHANGE_PIPELINE_TASK_TOPIC, @@ -19,8 +18,6 @@ import { InjectPinoLogger, PinoLogger } from 'nestjs-pino'; import { getAppInstanceRouteKey } from '../commons/utils/rabbit-mq'; import { ROUTE_PIPELINE_TASK_KILL } from './pipeline-tasks.constants'; -const log = debug('fennec:pipeline-tasks:service'); - @Injectable() export class PipelineTasksService { constructor( diff --git a/src/pipelines/dtos/create-pipeline.input.ts b/src/pipelines/dtos/create-pipeline.input.ts index 37e2870..48a9b0d 100644 --- a/src/pipelines/dtos/create-pipeline.input.ts +++ b/src/pipelines/dtos/create-pipeline.input.ts @@ -28,4 +28,8 @@ export class CreatePipelineInput { @ValidateNested() @IsInstance(WorkUnitMetadata) workUnitMetadata: WorkUnitMetadata; + + @IsString() + @MaxLength(100) + environment: string; } diff --git a/src/pipelines/pipeline.entity.ts b/src/pipelines/pipeline.entity.ts index b15905f..6fb2411 100644 --- a/src/pipelines/pipeline.entity.ts +++ b/src/pipelines/pipeline.entity.ts @@ -12,7 +12,7 @@ export class Pipeline extends AppBaseEntity { @Column() projectId: string; - @Column({ comment: 'eg: remotes/origin/master' }) + @Column({ comment: 'E.g., remotes/origin/master' }) branch: string; @Column() @@ -20,4 +20,7 @@ export class Pipeline extends AppBaseEntity { @Column({ type: 'jsonb' }) workUnitMetadata: WorkUnitMetadata; + + @Column() + environment: string; } diff --git a/src/pipelines/pipelines.service.spec.ts b/src/pipelines/pipelines.service.spec.ts index 400194c..b2e859d 100644 --- a/src/pipelines/pipelines.service.spec.ts +++ b/src/pipelines/pipelines.service.spec.ts @@ -2,13 +2,11 @@ import { Test, TestingModule } from '@nestjs/testing'; import { PipelinesService } from './pipelines.service'; import { Pipeline } from './pipeline.entity'; import { getRepositoryToken } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; import { Project } from '../projects/project.entity'; import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; describe('PipelinesService', () => { let service: PipelinesService; - let repository: Repository; let pipeline: Pipeline; beforeEach(async () => { @@ -40,7 +38,6 @@ describe('PipelinesService', () => { }).compile(); service = module.get(PipelinesService); - repository = module.get(getRepositoryToken(Pipeline)); }); it('should be defined', () => { diff --git a/src/pipelines/pipelines.service.ts b/src/pipelines/pipelines.service.ts index 1c7f8ee..892a8df 100644 --- a/src/pipelines/pipelines.service.ts +++ b/src/pipelines/pipelines.service.ts @@ -19,7 +19,9 @@ import { plainToClass } from 'class-transformer'; @Injectable() export class PipelinesService extends BaseDbService { - readonly uniqueFields: Array> = [['projectId', 'name']]; + readonly uniqueFields: Array> = [ + ['projectId', 'name', 'environment'], + ]; constructor( @InjectRepository(Pipeline) readonly repository: Repository, diff --git a/src/projects/project.entity.ts b/src/projects/project.entity.ts index 6ddb034..004efeb 100644 --- a/src/projects/project.entity.ts +++ b/src/projects/project.entity.ts @@ -1,5 +1,5 @@ import { ObjectType } from '@nestjs/graphql'; -import { Entity, Column, DeleteDateColumn } from 'typeorm'; +import { Entity, Column } from 'typeorm'; import { AppBaseEntity } from '../commons/entities/app-base-entity'; @ObjectType() diff --git a/src/repos/dtos/branch-list.model.ts b/src/repos/dtos/branch-list.model.ts index 4ec71d7..47e4c20 100644 --- a/src/repos/dtos/branch-list.model.ts +++ b/src/repos/dtos/branch-list.model.ts @@ -1,10 +1,5 @@ import { ObjectType, Field } from '@nestjs/graphql'; -import { - LogResult, - DefaultLogFields, - BranchSummary, - BranchSummaryBranch, -} from 'simple-git'; +import { BranchSummaryBranch } from 'simple-git'; @ObjectType() export class Branch implements BranchSummaryBranch { diff --git a/src/repos/repos.service.spec.ts b/src/repos/repos.service.spec.ts index afad1f0..c9a85a9 100644 --- a/src/repos/repos.service.spec.ts +++ b/src/repos/repos.service.spec.ts @@ -161,7 +161,7 @@ describe('ReposService', () => { const project = new Project(); const pipeline = new Pipeline(); pipeline.branch = 'test'; - const fetch = jest.fn((_: any) => Promise.resolve()); + const fetch = jest.fn(() => Promise.resolve()); pipeline.project = project; const getGit = jest.spyOn(service, 'getGit').mockImplementation(() => Promise.resolve({ @@ -182,7 +182,7 @@ describe('ReposService', () => { const project = new Project(); const pipeline = new Pipeline(); pipeline.branch = 'test'; - const fetch = jest.fn((_: any) => Promise.resolve()); + const fetch = jest.fn(() => Promise.resolve()); pipeline.project = project; const getGit = jest .spyOn(service, 'getGit') @@ -196,7 +196,7 @@ describe('ReposService', () => { const project = new Project(); const pipeline = new Pipeline(); pipeline.branch = 'test'; - const fetch = jest.fn((_: any) => Promise.reject('error')); + const fetch = jest.fn(() => Promise.reject('error')); pipeline.project = project; const getGit = jest.spyOn(service, 'getGit').mockImplementation(() => Promise.resolve({ diff --git a/src/webhooks/webhooks.module.ts b/src/webhooks/webhooks.module.ts index 254bc87..082e285 100644 --- a/src/webhooks/webhooks.module.ts +++ b/src/webhooks/webhooks.module.ts @@ -1,4 +1,4 @@ -import { MiddlewareConsumer, Module } from '@nestjs/common'; +import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { PipelineTasksModule } from '../pipeline-tasks/pipeline-tasks.module'; import { GiteaWebhooksController } from './gitea-webhooks.controller'; @@ -10,5 +10,4 @@ import { WebhooksService } from './webhooks.service'; controllers: [GiteaWebhooksController], providers: [WebhooksService], }) -export class WebhooksModule { -} +export class WebhooksModule {}