feat: 使用单独目录部署。

This commit is contained in:
Ivan Li 2021-07-22 20:48:30 +08:00
parent c86772a5dd
commit 1b469e34f9
7 changed files with 26 additions and 5 deletions

4
package-lock.json generated
View File

@ -2896,7 +2896,7 @@
"node_modules/@nestjs-lib/auth": { "node_modules/@nestjs-lib/auth": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz", "resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz",
"integrity": "sha512-kGO8iPp69bG1PuTK8k1o0Ew9AZk0O+jhhsvSki9vOMzMYdRe7HMhwjXqdFTsgt2be9actoyA4nafZ/iHAXfqGw==", "integrity": "sha512-HNOjIWh6H/PVTjp+nQ11LmKY/09zNhlLZqruukTteAPKQGvkeLUU51/OIp/vj0WWzMxp4qMWnfCrLaRYjkQ1Yw==",
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
"@nestjs/common": "^7.0.0", "@nestjs/common": "^7.0.0",
@ -18838,7 +18838,7 @@
"@nestjs-lib/auth": { "@nestjs-lib/auth": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz", "resolved": "https://npm.ivanli.cc/@nestjs-lib%2fauth/-/auth-0.2.1.tgz",
"integrity": "sha512-kGO8iPp69bG1PuTK8k1o0Ew9AZk0O+jhhsvSki9vOMzMYdRe7HMhwjXqdFTsgt2be9actoyA4nafZ/iHAXfqGw==", "integrity": "sha512-HNOjIWh6H/PVTjp+nQ11LmKY/09zNhlLZqruukTteAPKQGvkeLUU51/OIp/vj0WWzMxp4qMWnfCrLaRYjkQ1Yw==",
"requires": {} "requires": {}
}, },
"@nestjs/cli": { "@nestjs/cli": {

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(2); expect(doTaskUnit).toBeCalledTimes(1);
expect(emitEvent).toBeCalledTimes(2); expect(emitEvent).toBeCalledTimes(2);
}); });

View File

@ -27,7 +27,7 @@ import {
getSelfInstanceQueueKey, getSelfInstanceQueueKey,
getSelfInstanceRouteKey, getSelfInstanceRouteKey,
} from '../commons/utils/rabbit-mq'; } from '../commons/utils/rabbit-mq';
import { unlink } from 'fs/promises'; import { rm, unlink } from 'fs/promises';
import { rename } from 'fs/promises'; import { rename } from 'fs/promises';
type Spawn = typeof spawn; type Spawn = typeof spawn;
@ -127,7 +127,7 @@ export class PipelineTaskRunner {
const oldRoot = workspaceRoot; const oldRoot = workspaceRoot;
workspaceRoot = this.reposService.getDeployRoot(task); workspaceRoot = this.reposService.getDeployRoot(task);
if (oldRoot !== workspaceRoot) { if (oldRoot !== workspaceRoot) {
await unlink(workspaceRoot).catch(() => void 0); await rm(workspaceRoot, { force: true, recursive: true });
await rename(oldRoot, workspaceRoot); await rename(oldRoot, workspaceRoot);
} }
@ -231,6 +231,7 @@ export class PipelineTaskRunner {
'checkout failed.', 'checkout failed.',
'stderr', 'stderr',
); );
throw err;
} }
} }

View File

@ -1,3 +1,4 @@
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';
@ -18,6 +19,10 @@ describe('PipelineTasksResolver', () => {
provide: PipelineTaskLogger, provide: PipelineTaskLogger,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,3 +1,4 @@
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';
@ -18,6 +19,10 @@ describe('CommitLogsResolver', () => {
provide: PipelineTasksService, provide: PipelineTasksService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,3 +1,4 @@
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';
@ -13,6 +14,10 @@ describe('PipelinesResolver', () => {
provide: PipelinesService, provide: PipelinesService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();

View File

@ -1,3 +1,4 @@
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';
@ -13,6 +14,10 @@ describe('ProjectsResolver', () => {
provide: ProjectsService, provide: ProjectsService,
useValue: {}, useValue: {},
}, },
{
provide: JwtService,
useValue: {},
},
], ],
}).compile(); }).compile();