Compare commits

..

No commits in common. "cdc28cb10235e180c819d514c8e0e011f062aeb3" and "4e7c825170eb542a7755bd8bc27a00c68cd367f0" have entirely different histories.

5 changed files with 9 additions and 40 deletions

View File

@ -6,19 +6,16 @@ import { Field, HideField, ObjectType } from '@nestjs/graphql';
export class PipelineTaskLogMessage {
@HideField()
task: PipelineTask;
@Field(() => PipelineUnits, { nullable: true })
unit?: PipelineUnits;
@Field()
@Field(() => PipelineUnits)
unit: PipelineUnits;
time: Date;
@Field()
message: string;
static create(task: PipelineTask, unit: PipelineUnits, message: string) {
static create(task: PipelineTask, message: string) {
return Object.assign(new PipelineTaskLogMessage(), {
task,
message,
time: new Date(),
unit,
});
}
}

View File

@ -6,7 +6,7 @@ import { Field, ObjectType } from '@nestjs/graphql';
export class PipelineTaskLogs {
@Field(() => PipelineUnits)
unit: PipelineUnits;
@Field(() => TaskStatuses)
@Field(() => PipelineUnits)
status: TaskStatuses;
startedAt?: Date;
endedAt?: Date;

View File

@ -57,12 +57,7 @@ export class PipelineTaskConsumer {
}
for (const script of unit.scripts) {
unitLog.logs += `[RUN SCRIPT] ${script}`;
const messages = await this.runScript(
script,
workspaceRoot,
task,
unit.type,
);
const messages = await this.runScript(script, workspaceRoot, task);
unitLog.logs += messages.join('');
}
unitLog.status = TaskStatuses.success;
@ -88,7 +83,6 @@ export class PipelineTaskConsumer {
script: string,
workspaceRoot: string,
task?: PipelineTask,
unit?: PipelineUnits,
): Promise<string[]> {
return new Promise((resolve, reject) => {
const errorMessages: string[] = [];
@ -101,16 +95,12 @@ export class PipelineTaskConsumer {
const str = data.toString();
errorMessages.push(str);
logs.push(str);
this.logsService.recordLog(
PipelineTaskLogMessage.create(task, unit, str),
);
this.logsService.recordLog(PipelineTaskLogMessage.create(task, str));
});
sub.stdout.on('data', (data: Buffer) => {
const str = data.toString();
logs.push(str);
this.logsService.recordLog(
PipelineTaskLogMessage.create(task, unit, str),
);
this.logsService.recordLog(PipelineTaskLogMessage.create(task, str));
});
sub.addListener('close', (code) => {
if (code === 0) {

View File

@ -1,4 +1,4 @@
import { Resolver, Args, Mutation, Subscription, Query } from '@nestjs/graphql';
import { Resolver, Args, Mutation, Subscription } from '@nestjs/graphql';
import { PipelineTask } from './pipeline-task.entity';
import { PipelineTasksService } from './pipeline-tasks.service';
import { CreatePipelineTaskInput } from './dtos/create-pipeline-task.input';
@ -18,24 +18,10 @@ export class PipelineTasksResolver {
return await this.service.addTask(taskDto);
}
@Subscription(() => PipelineTaskLogMessage, {
resolve: (value) => {
return value;
},
})
@Subscription(() => PipelineTaskLogMessage)
async pipelineTaskLog(@Args() args: PipelineTaskLogArgs) {
const task = await this.service.findTaskById(args.taskId);
const asyncIterator = this.logsService.watchLogs(task);
return asyncIterator;
}
@Query(() => [PipelineTask])
async listPipelineTaskByPipelineId(@Args('pipelineId') pipelineId: string) {
return await this.service.listTasksByPipelineId(pipelineId);
}
@Query(() => PipelineTask)
async findPipelineTask(@Args('id') id: string) {
return await this.service.findTaskById(id);
}
}

View File

@ -40,10 +40,6 @@ export class PipelineTasksService {
return await this.repository.findOneOrFail({ id });
}
async listTasksByPipelineId(pipelineId: string) {
return await this.repository.find({ pipelineId });
}
async doNextTask(pipeline: Pipeline) {
const [lckKey, tasksKey] = this.getRedisTokens(pipeline);
const redis = this.redis.getClient();