Compare commits

..

No commits in common. "574e7ecae7fe8efe79194f664d1587d15aa50e79" and "aec7f65434f85dbaabb6fe9e5ddde8a813f0c7a9" have entirely different histories.

9 changed files with 10 additions and 57 deletions

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"@golevelup/nestjs-rabbitmq": "^1.16.1", "@golevelup/nestjs-rabbitmq": "^1.16.1",
"@nestjs-lib/auth": "^0.2.1", "@nestjs-lib/auth": "^0.2.0",
"@nestjs/common": "^7.5.1", "@nestjs/common": "^7.5.1",
"@nestjs/config": "^0.6.2", "@nestjs/config": "^0.6.2",
"@nestjs/core": "^7.5.1", "@nestjs/core": "^7.5.1",
@ -2894,9 +2894,9 @@
"integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==" "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA=="
}, },
"node_modules/@nestjs-lib/auth": { "node_modules/@nestjs-lib/auth": {
"version": "0.2.1", "version": "0.2.0",
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz", "resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.0.tgz",
"integrity": "sha512-HNOjIWh6H/PVTjp+nQ11LmKY/09zNhlLZqruukTteAPKQGvkeLUU51/OIp/vj0WWzMxp4qMWnfCrLaRYjkQ1Yw==", "integrity": "sha512-izveLtKIkE9aBjn0CH85B8XOx4gKzhOEfjH03DVZvh1nWVxUVIv91N1Igxd2unnMPgelucsZ3viyTFJzIz0IGw==",
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
"@nestjs/common": "^7.0.0", "@nestjs/common": "^7.0.0",
@ -18836,9 +18836,9 @@
"integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==" "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA=="
}, },
"@nestjs-lib/auth": { "@nestjs-lib/auth": {
"version": "0.2.1", "version": "0.2.0",
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz", "resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.0.tgz",
"integrity": "sha512-HNOjIWh6H/PVTjp+nQ11LmKY/09zNhlLZqruukTteAPKQGvkeLUU51/OIp/vj0WWzMxp4qMWnfCrLaRYjkQ1Yw==", "integrity": "sha512-izveLtKIkE9aBjn0CH85B8XOx4gKzhOEfjH03DVZvh1nWVxUVIv91N1Igxd2unnMPgelucsZ3viyTFJzIz0IGw==",
"requires": {} "requires": {}
}, },
"@nestjs/cli": { "@nestjs/cli": {

View File

@ -22,7 +22,7 @@
}, },
"dependencies": { "dependencies": {
"@golevelup/nestjs-rabbitmq": "^1.16.1", "@golevelup/nestjs-rabbitmq": "^1.16.1",
"@nestjs-lib/auth": "^0.2.1", "@nestjs-lib/auth": "^0.2.0",
"@nestjs/common": "^7.5.1", "@nestjs/common": "^7.5.1",
"@nestjs/config": "^0.6.2", "@nestjs/config": "^0.6.2",
"@nestjs/core": "^7.5.1", "@nestjs/core": "^7.5.1",

View File

@ -145,7 +145,7 @@ describe('PipelineTaskRunner', () => {
await runner.doTask(task); await runner.doTask(task);
expect(checkout).toBeCalledTimes(1); expect(checkout).toBeCalledTimes(1);
expect(doTaskUnit).toBeCalledTimes(1); expect(doTaskUnit).toBeCalledTimes(2);
expect(emitEvent).toBeCalledTimes(2); expect(emitEvent).toBeCalledTimes(2);
}); });

View File

@ -27,8 +27,6 @@ import {
getSelfInstanceQueueKey, getSelfInstanceQueueKey,
getSelfInstanceRouteKey, getSelfInstanceRouteKey,
} from '../commons/utils/rabbit-mq'; } from '../commons/utils/rabbit-mq';
import { rm, unlink } from 'fs/promises';
import { rename } from 'fs/promises';
type Spawn = typeof spawn; type Spawn = typeof spawn;
@ -112,7 +110,7 @@ export class PipelineTaskRunner {
this.logger.info('running task [%s].', task.id); this.logger.info('running task [%s].', task.id);
try { try {
let workspaceRoot = await this.checkout(task); const workspaceRoot = await this.checkout(task);
const units = task.units const units = task.units
.filter((unit) => unit !== PipelineUnits.checkout) .filter((unit) => unit !== PipelineUnits.checkout)
.map( .map(
@ -123,22 +121,6 @@ export class PipelineTaskRunner {
); );
this.logger.info({ units }, 'begin run units.'); this.logger.info({ units }, 'begin run units.');
for (const unit of units) { for (const unit of units) {
if (unit.type === PipelineUnits.deploy) {
const oldRoot = workspaceRoot;
workspaceRoot = this.reposService.getDeployRoot(task);
if (oldRoot !== workspaceRoot) {
await rm(workspaceRoot, { force: true, recursive: true });
await rename(oldRoot, workspaceRoot);
}
await this.emitEvent(
task,
unit.type,
TaskStatuses.success,
`[deploy] change deploy folder content success`,
'stdout',
);
}
await this.doTaskUnit(unit.type, unit.scripts, task, workspaceRoot); await this.doTaskUnit(unit.type, unit.scripts, task, workspaceRoot);
} }
await this.emitEvent( await this.emitEvent(
@ -231,7 +213,6 @@ export class PipelineTaskRunner {
'checkout failed.', 'checkout failed.',
'stderr', 'stderr',
); );
throw err;
} }
} }

View File

@ -1,4 +1,3 @@
import { JwtService } from '@nestjs-lib/auth';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { PipelineTaskLogger } from './pipeline-task.logger'; import { PipelineTaskLogger } from './pipeline-task.logger';
import { PipelineTasksResolver } from './pipeline-tasks.resolver'; import { PipelineTasksResolver } from './pipeline-tasks.resolver';
@ -19,10 +18,6 @@ describe('PipelineTasksResolver', () => {
provide: PipelineTaskLogger, provide: PipelineTaskLogger,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,4 +1,3 @@
import { JwtService } from '@nestjs-lib/auth';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { PipelineTasksService } from '../pipeline-tasks/pipeline-tasks.service'; import { PipelineTasksService } from '../pipeline-tasks/pipeline-tasks.service';
import { CommitLogsResolver } from './commit-logs.resolver'; import { CommitLogsResolver } from './commit-logs.resolver';
@ -19,10 +18,6 @@ describe('CommitLogsResolver', () => {
provide: PipelineTasksService, provide: PipelineTasksService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,4 +1,3 @@
import { JwtService } from '@nestjs-lib/auth';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { PipelinesResolver } from './pipelines.resolver'; import { PipelinesResolver } from './pipelines.resolver';
import { PipelinesService } from './pipelines.service'; import { PipelinesService } from './pipelines.service';
@ -14,10 +13,6 @@ describe('PipelinesResolver', () => {
provide: PipelinesService, provide: PipelinesService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,4 +1,3 @@
import { JwtService } from '@nestjs-lib/auth';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { ProjectsResolver } from './projects.resolver'; import { ProjectsResolver } from './projects.resolver';
import { ProjectsService } from './projects.service'; import { ProjectsService } from './projects.service';
@ -14,10 +13,6 @@ describe('ProjectsResolver', () => {
provide: ProjectsService, provide: ProjectsService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -56,14 +56,6 @@ export class ReposService {
); );
} }
getDeployRoot(task: PipelineTask) {
return join(
this.configService.get<string>('workspaces.root'),
encodeURIComponent(task.pipeline.project.name),
encodeURIComponent(`deploy-${task.pipeline.name}`),
);
}
async getGit( async getGit(
project: Project, project: Project,
workspaceRoot?: string, workspaceRoot?: string,