feat-pipelines #1
@ -13,9 +13,7 @@ import { ListLogsOption } from '../repos/models/list-logs.options';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PipelinesService extends BaseDbService<Pipeline> {
|
export class PipelinesService extends BaseDbService<Pipeline> {
|
||||||
readonly uniqueFields: Array<Array<keyof Pipeline>> = [
|
readonly uniqueFields: Array<Array<keyof Pipeline>> = [['projectId', 'name']];
|
||||||
['branch', 'projectId'],
|
|
||||||
];
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(Pipeline)
|
@InjectRepository(Pipeline)
|
||||||
readonly repository: Repository<Pipeline>,
|
readonly repository: Repository<Pipeline>,
|
||||||
|
@ -8,6 +8,7 @@ import { ProjectsModule } from '../projects/projects.module';
|
|||||||
import { BullModule } from '@nestjs/bull';
|
import { BullModule } from '@nestjs/bull';
|
||||||
import { LIST_LOGS_TASK, LIST_LOGS_PUB_SUB } from './repos.constants';
|
import { LIST_LOGS_TASK, LIST_LOGS_PUB_SUB } from './repos.constants';
|
||||||
import { PubSub } from 'graphql-subscriptions';
|
import { PubSub } from 'graphql-subscriptions';
|
||||||
|
import { ListLogsConsumer } from './list-logs.consumer';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -21,6 +22,7 @@ import { PubSub } from 'graphql-subscriptions';
|
|||||||
providers: [
|
providers: [
|
||||||
ReposResolver,
|
ReposResolver,
|
||||||
ReposService,
|
ReposService,
|
||||||
|
ListLogsConsumer,
|
||||||
{
|
{
|
||||||
provide: LIST_LOGS_PUB_SUB,
|
provide: LIST_LOGS_PUB_SUB,
|
||||||
useValue: new PubSub(),
|
useValue: new PubSub(),
|
||||||
|
@ -10,7 +10,11 @@ export class ReposResolver {
|
|||||||
@Inject(LIST_LOGS_PUB_SUB)
|
@Inject(LIST_LOGS_PUB_SUB)
|
||||||
private readonly pubSub: PubSub,
|
private readonly pubSub: PubSub,
|
||||||
) {}
|
) {}
|
||||||
@Subscription(() => LogList)
|
@Subscription(() => LogList, {
|
||||||
|
resolve: (value) => {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
})
|
||||||
listLogsDone() {
|
listLogsDone() {
|
||||||
return this.pubSub.asyncIterator(LIST_LOGS_DONE);
|
return this.pubSub.asyncIterator(LIST_LOGS_DONE);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,10 @@ describe('ReposService', () => {
|
|||||||
});
|
});
|
||||||
describe('listLogs', () => {
|
describe('listLogs', () => {
|
||||||
it('should be return logs', async () => {
|
it('should be return logs', async () => {
|
||||||
const result = await service.listLogs({ projectId: '1' });
|
const result = await service.listLogs({
|
||||||
|
project: getTest1Project(),
|
||||||
|
branch: 'master',
|
||||||
|
});
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
}, 20_000);
|
}, 20_000);
|
||||||
});
|
});
|
||||||
@ -71,7 +74,7 @@ describe('ReposService', () => {
|
|||||||
it('should be return branches', async () => {
|
it('should be return branches', async () => {
|
||||||
const result = await service.listBranches({ projectId: '1' });
|
const result = await service.listBranches({ projectId: '1' });
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
}, 10_000);
|
}, 20_000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.skip('checkout', () => {
|
describe.skip('checkout', () => {
|
||||||
|
@ -40,7 +40,7 @@ export class ReposService {
|
|||||||
await mkdir(workspaceRoot, { recursive: true });
|
await mkdir(workspaceRoot, { recursive: true });
|
||||||
});
|
});
|
||||||
const git = gitP(workspaceRoot);
|
const git = gitP(workspaceRoot);
|
||||||
if (!(await git.checkIsRepo())) {
|
if (!(await git.checkIsRepo().catch(() => false))) {
|
||||||
await git.init();
|
await git.init();
|
||||||
await git.addRemote(DEFAULT_REMOTE_NAME, project.sshUrl);
|
await git.addRemote(DEFAULT_REMOTE_NAME, project.sshUrl);
|
||||||
}
|
}
|
||||||
@ -50,7 +50,9 @@ export class ReposService {
|
|||||||
|
|
||||||
async listLogs({ project, branch }: ListLogsOption) {
|
async listLogs({ project, branch }: ListLogsOption) {
|
||||||
const git = await this.getGit(project);
|
const git = await this.getGit(project);
|
||||||
return await git.log(branch ? ['--branches', branch, '--'] : ['--all']);
|
return await git.log(
|
||||||
|
branch ? ['--branches', `remotes/origin/${branch}`, '--'] : ['--all'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async listBranches(dto: ListBranchesArgs) {
|
async listBranches(dto: ListBranchesArgs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user