plugin-workflow-ci 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client-v2.js +1 -0
- package/client.js +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/externalVersion.js +21 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +105 -0
- package/dist/locale/vi-VN.json +105 -0
- package/dist/locale/zh-CN.json +105 -0
- package/dist/server/actions/ci-manager.js +307 -0
- package/dist/server/collections/ci-gate-runs.js +85 -0
- package/dist/server/collections/ci-git-feedback-outbox.js +51 -0
- package/dist/server/collections/ci-pipelines.js +88 -0
- package/dist/server/index.js +62 -0
- package/dist/server/instructions/CiInstructions.js +180 -0
- package/dist/server/migrations/20261206000001-harden-workflow-ci-v020.js +91 -0
- package/dist/server/plugin.js +255 -0
- package/dist/server/services/AiTriageService.js +215 -0
- package/dist/server/services/CiGateWorkflowService.js +1776 -0
- package/dist/server/services/EphemeralContainerService.js +891 -0
- package/dist/server/services/GitFeedbackService.js +995 -0
- package/dist/server/services/constants-internal.js +65 -0
- package/dist/shared/collection-schemas.js +125 -0
- package/dist/shared/constants.js +120 -0
- package/dist/shared/runtime-context.js +67 -0
- package/dist/shared/types.js +24 -0
- package/dist/shared/ui/CiPipelinesSettingsView.js +700 -0
- package/package.json +58 -4
- package/server.js +1 -0
- package/src/client/index.tsx +10 -0
- package/src/client/locale.ts +31 -0
- package/src/client/plugin.tsx +62 -0
- package/src/client/workflow.tsx +119 -0
- package/src/client-v2/index.tsx +10 -0
- package/src/client-v2/locale.ts +32 -0
- package/src/client-v2/plugin.tsx +77 -0
- package/src/client-v2/workflow.tsx +124 -0
- package/src/index.ts +11 -0
- package/src/locale/en-US.json +105 -0
- package/src/locale/vi-VN.json +105 -0
- package/src/locale/zh-CN.json +105 -0
- package/src/server/actions/ci-manager.ts +377 -0
- package/src/server/collections/ci-gate-runs.ts +65 -0
- package/src/server/collections/ci-git-feedback-outbox.ts +31 -0
- package/src/server/collections/ci-pipelines.ts +68 -0
- package/src/server/index.ts +17 -0
- package/src/server/instructions/CiInstructions.ts +180 -0
- package/src/server/migrations/20261206000001-harden-workflow-ci-v020.ts +78 -0
- package/src/server/plugin.ts +274 -0
- package/src/server/services/AiTriageService.ts +254 -0
- package/src/server/services/CiGateWorkflowService.ts +2310 -0
- package/src/server/services/EphemeralContainerService.ts +1170 -0
- package/src/server/services/GitFeedbackService.ts +1224 -0
- package/src/server/services/constants-internal.ts +27 -0
- package/src/shared/collection-schemas.ts +98 -0
- package/src/shared/constants.ts +50 -0
- package/src/shared/runtime-context.tsx +55 -0
- package/src/shared/types.ts +203 -0
- package/src/shared/ui/CiPipelinesSettingsView.tsx +1035 -0
- package/README.md +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugin-workflow-ci",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"displayName": "CI Testing & Quality Gate Workflows",
|
|
4
|
+
"displayName.zh-CN": "CI 持续测试与质量门禁工作流",
|
|
5
|
+
"displayName.vi-VN": "Luồng CI Kiểm thử & Quality Gate",
|
|
6
|
+
"description": "Workflow-native CI orchestration bridging Git Webhooks/MRs, Test Manager, Ephemeral Portainer/Cluster Containers, Pre-Deploy Quality Gates, and Agent Failure Triage.",
|
|
7
|
+
"description.zh-CN": "基于 NocoBase 工作流的 CI 持续测试编排插件:连接 Git Webhook/MR、测试中心、Portainer/Cluster 一次性容器、部署前质量门禁与 AI 故障诊断。",
|
|
8
|
+
"description.vi-VN": "Điều phối luồng CI Testing trên NocoBase Workflow: kết nối Git Webhook/MR, Commit Status & Sticky Comment, One-shot Container qua Portainer/Cluster, Pre-Deploy Gate và AI Failure Triage.",
|
|
9
|
+
"version": "0.2.0",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/server/index.js",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"NocoBase",
|
|
14
|
+
"Workflow",
|
|
15
|
+
"CI",
|
|
16
|
+
"Testing",
|
|
17
|
+
"QualityGate",
|
|
18
|
+
"Git",
|
|
19
|
+
"Portainer",
|
|
20
|
+
"Cluster"
|
|
21
|
+
],
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src",
|
|
25
|
+
"!src/**/__tests__/**",
|
|
26
|
+
"client.js",
|
|
27
|
+
"client-v2.js",
|
|
28
|
+
"server.js"
|
|
29
|
+
],
|
|
30
|
+
"nocobase": {
|
|
31
|
+
"supportedVersions": [
|
|
32
|
+
"2.x"
|
|
33
|
+
],
|
|
34
|
+
"editionLevel": 0
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@ant-design/icons": "^5.0.0",
|
|
38
|
+
"@nocobase/acl": "2.x",
|
|
39
|
+
"@nocobase/actions": "2.x",
|
|
40
|
+
"@nocobase/client": "2.x",
|
|
41
|
+
"@nocobase/client-v2": "2.x",
|
|
42
|
+
"@nocobase/database": "2.x",
|
|
43
|
+
"@nocobase/flow-engine": "2.x",
|
|
44
|
+
"@nocobase/plugin-workflow": "2.x",
|
|
45
|
+
"@nocobase/resourcer": "2.x",
|
|
46
|
+
"@nocobase/server": "2.x",
|
|
47
|
+
"antd": "5.x",
|
|
48
|
+
"react": "^18.x"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/OrgGem/nocobase-beta.git",
|
|
53
|
+
"directory": "packages/plugins/plugin-workflow-ci"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "9e65319a2b4ab4af9db8a08bcaded945344c2415",
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public",
|
|
58
|
+
"registry": "https://registry.npmjs.org/"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { default, PluginWorkflowCiClient } from './plugin';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useAPIClient, useApp } from '@nocobase/client';
|
|
11
|
+
import { useCallback } from 'react';
|
|
12
|
+
import { NAMESPACE } from '../shared/constants';
|
|
13
|
+
import type { TranslateFn, WorkflowCiApiLike } from '../shared/runtime-context';
|
|
14
|
+
|
|
15
|
+
export function useT(): TranslateFn {
|
|
16
|
+
const app = useApp();
|
|
17
|
+
return useCallback(
|
|
18
|
+
(key: string, options?: Record<string, unknown>): string =>
|
|
19
|
+
app.i18n.t(key, { ns: [NAMESPACE, 'client'], nsMode: 'fallback', ...options }) as unknown as string,
|
|
20
|
+
[app.i18n],
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useV1ApiAdapter(): WorkflowCiApiLike {
|
|
25
|
+
const api = useAPIClient();
|
|
26
|
+
return api as unknown as WorkflowCiApiLike;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function tStr(key: string): string {
|
|
30
|
+
return `{{t(${JSON.stringify(key)}, { ns: ['${NAMESPACE}', 'client'], nsMode: 'fallback' })}}`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Plugin, type DataSource } from '@nocobase/client';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { allWorkflowCiCollections } from '../shared/collection-schemas';
|
|
13
|
+
import { CI_MANAGER_ACL_SNIPPET, NAMESPACE } from '../shared/constants';
|
|
14
|
+
import { WorkflowCiRuntimeProvider } from '../shared/runtime-context';
|
|
15
|
+
import { CiPipelinesSettingsView } from '../shared/ui/CiPipelinesSettingsView';
|
|
16
|
+
import { useT, useV1ApiAdapter } from './locale';
|
|
17
|
+
import { registerWorkflowCiInstructionsV1, type WorkflowRegistryV1Like } from './workflow';
|
|
18
|
+
|
|
19
|
+
const CiSettingsPageV1: React.FC = () => {
|
|
20
|
+
const api = useV1ApiAdapter();
|
|
21
|
+
const t = useT();
|
|
22
|
+
return (
|
|
23
|
+
<WorkflowCiRuntimeProvider api={api} t={t}>
|
|
24
|
+
<CiPipelinesSettingsView section="all" />
|
|
25
|
+
</WorkflowCiRuntimeProvider>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function registerCollectionsOnDataSource(dataSource: DataSource) {
|
|
30
|
+
dataSource.collectionManager.addCollections(allWorkflowCiCollections);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class PluginWorkflowCiClient extends Plugin {
|
|
34
|
+
private t(key: string): string {
|
|
35
|
+
return this.app.i18n.t(key, { ns: [NAMESPACE, 'client'], nsMode: 'fallback' }) as string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async load() {
|
|
39
|
+
const workflow = (this.app.pm.get('workflow') || this.app.pm.get('@nocobase/plugin-workflow')) as
|
|
40
|
+
| WorkflowRegistryV1Like
|
|
41
|
+
| undefined;
|
|
42
|
+
if (workflow) {
|
|
43
|
+
registerWorkflowCiInstructionsV1(workflow);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const mainDataSource = this.app.dataSourceManager.getDataSource('main');
|
|
47
|
+
if (mainDataSource) {
|
|
48
|
+
const syncCollections = () => registerCollectionsOnDataSource(mainDataSource);
|
|
49
|
+
syncCollections();
|
|
50
|
+
mainDataSource.addReloadCallback(syncCollections);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.app.pluginSettingsManager.add(NAMESPACE, {
|
|
54
|
+
title: this.t('CI Testing & Quality Gate'),
|
|
55
|
+
icon: 'SafetyCertificateOutlined',
|
|
56
|
+
Component: CiSettingsPageV1,
|
|
57
|
+
aclSnippet: CI_MANAGER_ACL_SNIPPET,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default PluginWorkflowCiClient;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CloudUploadOutlined,
|
|
12
|
+
CommentOutlined,
|
|
13
|
+
ContainerOutlined,
|
|
14
|
+
RobotOutlined,
|
|
15
|
+
SafetyCertificateOutlined,
|
|
16
|
+
} from '@ant-design/icons';
|
|
17
|
+
import { Instruction } from '@nocobase/plugin-workflow/client';
|
|
18
|
+
import { Alert, Form, Input } from 'antd';
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { CI_INSTRUCTIONS, CI_WORKFLOW_GROUP_KEY } from '../shared/constants';
|
|
21
|
+
import { tStr, useT } from './locale';
|
|
22
|
+
|
|
23
|
+
function makeCiV1Fieldset(descriptionKey: string): React.FC {
|
|
24
|
+
const StageFieldset: React.FC = () => {
|
|
25
|
+
const t = useT();
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<Alert type="info" showIcon style={{ marginBottom: 12 }} message={t(descriptionKey)} />
|
|
29
|
+
<Form.Item name={['config', 'gateRunId']} label={t('CI Gate Run ID (optional override)')}>
|
|
30
|
+
<Input placeholder="{{$context.data.id}}" />
|
|
31
|
+
</Form.Item>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
return StageFieldset;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class CiDispatchRunInstructionV1 extends Instruction {
|
|
39
|
+
title = tStr('Dispatch CI Test Run & Ephemeral Container');
|
|
40
|
+
type = CI_INSTRUCTIONS.dispatchRun;
|
|
41
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
42
|
+
icon = (<ContainerOutlined />);
|
|
43
|
+
FieldsetLoader = async () => ({
|
|
44
|
+
default: makeCiV1Fieldset(
|
|
45
|
+
'Publishes pending Git commit status, enqueues an isolated Test Manager run, and optionally launches a one-shot ephemeral container.',
|
|
46
|
+
),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class CiAiTriageInstructionV1 extends Instruction {
|
|
51
|
+
title = tStr('AI Failure Triage & Agent Loop');
|
|
52
|
+
type = CI_INSTRUCTIONS.aiTriage;
|
|
53
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
54
|
+
icon = (<RobotOutlined />);
|
|
55
|
+
FieldsetLoader = async () => ({
|
|
56
|
+
default: makeCiV1Fieldset(
|
|
57
|
+
'Classifies failed or mismatched CI runs (code regression vs baseline change vs infra flake) and optionally triggers Agent Orchestrator.',
|
|
58
|
+
),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class CiPublishGitFeedbackInstructionV1 extends Instruction {
|
|
63
|
+
title = tStr('Publish Git Commit Status & Sticky PR Comment');
|
|
64
|
+
type = CI_INSTRUCTIONS.publishGitFeedback;
|
|
65
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
66
|
+
icon = (<CommentOutlined />);
|
|
67
|
+
FieldsetLoader = async () => ({
|
|
68
|
+
default: makeCiV1Fieldset(
|
|
69
|
+
'Updates GitHub/GitLab commit status, upserts a sticky Markdown summary comment on the PR/MR, and enriches pending AI Git Reviews.',
|
|
70
|
+
),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class CiWaitApprovalInstructionV1 extends Instruction {
|
|
75
|
+
title = tStr('Await Authorized QA Baseline Approval');
|
|
76
|
+
type = CI_INSTRUCTIONS.waitApproval;
|
|
77
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
78
|
+
icon = (<SafetyCertificateOutlined />);
|
|
79
|
+
FieldsetLoader = async () => ({
|
|
80
|
+
default: makeCiV1Fieldset(
|
|
81
|
+
'Pauses execution on pure baseline diff mismatches until an authorized user in gateApproverIds approves the baseline.',
|
|
82
|
+
),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class CiPromoteDeployInstructionV1 extends Instruction {
|
|
87
|
+
title = tStr('Enforce CI Quality Gate & Promote Runtime Stack');
|
|
88
|
+
type = CI_INSTRUCTIONS.promoteDeploy;
|
|
89
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
90
|
+
icon = (<CloudUploadOutlined />);
|
|
91
|
+
FieldsetLoader = async () => ({
|
|
92
|
+
default: makeCiV1Fieldset(
|
|
93
|
+
'Promotes the verified build tag to the runtime Portainer stack when tests pass, or blocks/awaits baseline approval on failure.',
|
|
94
|
+
),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface WorkflowRegistryV1Like {
|
|
99
|
+
registerInstruction?: (type: string, ctor: typeof Instruction) => void;
|
|
100
|
+
instructions?: { register?: (type: string, instance: Instruction) => void };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function registerWorkflowCiInstructionsV1(workflow: WorkflowRegistryV1Like): void {
|
|
104
|
+
const entries: Array<[string, typeof Instruction]> = [
|
|
105
|
+
[CI_INSTRUCTIONS.dispatchRun, CiDispatchRunInstructionV1],
|
|
106
|
+
[CI_INSTRUCTIONS.aiTriage, CiAiTriageInstructionV1],
|
|
107
|
+
[CI_INSTRUCTIONS.publishGitFeedback, CiPublishGitFeedbackInstructionV1],
|
|
108
|
+
[CI_INSTRUCTIONS.waitApproval, CiWaitApprovalInstructionV1],
|
|
109
|
+
[CI_INSTRUCTIONS.promoteDeploy, CiPromoteDeployInstructionV1],
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
for (const [type, Ctor] of entries) {
|
|
113
|
+
if (typeof workflow.registerInstruction === 'function') {
|
|
114
|
+
workflow.registerInstruction(type, Ctor);
|
|
115
|
+
} else {
|
|
116
|
+
workflow.instructions?.register?.(type, new Ctor());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { default, PluginWorkflowCiClientV2 } from './plugin';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useApp } from '@nocobase/client-v2';
|
|
11
|
+
import { tExpr as baseTExpr } from '@nocobase/flow-engine';
|
|
12
|
+
import { useCallback } from 'react';
|
|
13
|
+
import { NAMESPACE } from '../shared/constants';
|
|
14
|
+
import type { TranslateFn, WorkflowCiApiLike } from '../shared/runtime-context';
|
|
15
|
+
|
|
16
|
+
export function useT(): TranslateFn {
|
|
17
|
+
const app = useApp();
|
|
18
|
+
return useCallback(
|
|
19
|
+
(key: string, options?: Record<string, unknown>): string =>
|
|
20
|
+
app.i18n.t(key, { ns: [NAMESPACE, 'client'], nsMode: 'fallback', ...options }) as unknown as string,
|
|
21
|
+
[app.i18n],
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useV2ApiAdapter(): WorkflowCiApiLike {
|
|
26
|
+
const app = useApp();
|
|
27
|
+
return app.apiClient as unknown as WorkflowCiApiLike;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function tExpr(key: string): string {
|
|
31
|
+
return baseTExpr(key, { ns: [NAMESPACE, 'client'], nsMode: 'fallback' });
|
|
32
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Application, ExtendCollectionsProvider, Plugin } from '@nocobase/client-v2';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { allWorkflowCiCollections } from '../shared/collection-schemas';
|
|
13
|
+
import { CI_MANAGER_ACL_SNIPPET, NAMESPACE } from '../shared/constants';
|
|
14
|
+
import { WorkflowCiRuntimeProvider } from '../shared/runtime-context';
|
|
15
|
+
import { CiPipelinesSettingsView } from '../shared/ui/CiPipelinesSettingsView';
|
|
16
|
+
import { useT, useV2ApiAdapter } from './locale';
|
|
17
|
+
import { registerWorkflowCiInstructionsV2, type WorkflowRegistryV2Like } from './workflow';
|
|
18
|
+
|
|
19
|
+
const MENU_KEY = 'workflow-ci';
|
|
20
|
+
|
|
21
|
+
const CiSettingsSectionTab: React.FC<{ section: 'pipelines' | 'runs' }> = ({ section }) => {
|
|
22
|
+
const api = useV2ApiAdapter();
|
|
23
|
+
const t = useT();
|
|
24
|
+
return (
|
|
25
|
+
<WorkflowCiRuntimeProvider api={api} t={t}>
|
|
26
|
+
<CiPipelinesSettingsView section={section} />
|
|
27
|
+
</WorkflowCiRuntimeProvider>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export class PluginWorkflowCiClientV2 extends Plugin<Record<string, never>, Application> {
|
|
32
|
+
async load() {
|
|
33
|
+
const pluginName = this.options?.name || NAMESPACE;
|
|
34
|
+
|
|
35
|
+
this.app.addProvider(ExtendCollectionsProvider, {
|
|
36
|
+
collections: allWorkflowCiCollections,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const workflow = (this.app.pm.get('workflow') || this.app.pm.get('@nocobase/plugin-workflow')) as
|
|
40
|
+
| WorkflowRegistryV2Like
|
|
41
|
+
| undefined;
|
|
42
|
+
if (workflow) {
|
|
43
|
+
registerWorkflowCiInstructionsV2(workflow);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.pluginSettingsManager.addMenuItem({
|
|
47
|
+
key: MENU_KEY,
|
|
48
|
+
title: this.t('CI Testing & Quality Gate'),
|
|
49
|
+
icon: 'SafetyCertificateOutlined',
|
|
50
|
+
aclSnippet: CI_MANAGER_ACL_SNIPPET,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
54
|
+
menuKey: MENU_KEY,
|
|
55
|
+
key: 'pipelines',
|
|
56
|
+
title: this.t('CI Pipelines & Webhooks'),
|
|
57
|
+
aclSnippet: CI_MANAGER_ACL_SNIPPET,
|
|
58
|
+
componentLoader: async () => ({
|
|
59
|
+
default: () => <CiSettingsSectionTab section="pipelines" />,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
64
|
+
menuKey: MENU_KEY,
|
|
65
|
+
key: 'runs',
|
|
66
|
+
title: this.t('CI Gate Runs & Approvals'),
|
|
67
|
+
aclSnippet: CI_MANAGER_ACL_SNIPPET,
|
|
68
|
+
componentLoader: async () => ({
|
|
69
|
+
default: () => <CiSettingsSectionTab section="runs" />,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.pluginSettingsManager.setPluginSettingsLink?.(pluginName, MENU_KEY);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default PluginWorkflowCiClientV2;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CloudUploadOutlined,
|
|
12
|
+
CommentOutlined,
|
|
13
|
+
ContainerOutlined,
|
|
14
|
+
RobotOutlined,
|
|
15
|
+
SafetyCertificateOutlined,
|
|
16
|
+
} from '@ant-design/icons';
|
|
17
|
+
import { Instruction, NodeDefaultView } from '@nocobase/plugin-workflow/client-v2';
|
|
18
|
+
import { Alert, Form, Input } from 'antd';
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { CI_INSTRUCTIONS, CI_WORKFLOW_GROUP_KEY } from '../shared/constants';
|
|
21
|
+
import { tExpr, useT } from './locale';
|
|
22
|
+
|
|
23
|
+
function makeCiStageFieldset(descriptionKey: string): React.FC {
|
|
24
|
+
const StageFieldset: React.FC = () => {
|
|
25
|
+
const t = useT();
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<Alert type="info" showIcon style={{ marginBottom: 12 }} message={t(descriptionKey)} />
|
|
29
|
+
<Form.Item name={['config', 'gateRunId']} label={t('CI Gate Run ID (optional override)')}>
|
|
30
|
+
<Input placeholder="{{$context.data.id}}" />
|
|
31
|
+
</Form.Item>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
return StageFieldset;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class CiDispatchRunInstructionV2 extends Instruction {
|
|
39
|
+
title = tExpr('Dispatch CI Test Run & Ephemeral Container');
|
|
40
|
+
type = CI_INSTRUCTIONS.dispatchRun;
|
|
41
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
42
|
+
icon = (<ContainerOutlined />);
|
|
43
|
+
Component = NodeDefaultView;
|
|
44
|
+
FieldsetLoader = async () => ({
|
|
45
|
+
default: makeCiStageFieldset(
|
|
46
|
+
'Publishes pending Git commit status, enqueues an isolated Test Manager run, and optionally launches a one-shot ephemeral container.',
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class CiAiTriageInstructionV2 extends Instruction {
|
|
52
|
+
title = tExpr('AI Failure Triage & Agent Loop');
|
|
53
|
+
type = CI_INSTRUCTIONS.aiTriage;
|
|
54
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
55
|
+
icon = (<RobotOutlined />);
|
|
56
|
+
Component = NodeDefaultView;
|
|
57
|
+
FieldsetLoader = async () => ({
|
|
58
|
+
default: makeCiStageFieldset(
|
|
59
|
+
'Classifies failed or mismatched CI runs (code regression vs baseline change vs infra flake) and optionally triggers Agent Orchestrator.',
|
|
60
|
+
),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class CiPublishGitFeedbackInstructionV2 extends Instruction {
|
|
65
|
+
title = tExpr('Publish Git Commit Status & Sticky PR Comment');
|
|
66
|
+
type = CI_INSTRUCTIONS.publishGitFeedback;
|
|
67
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
68
|
+
icon = (<CommentOutlined />);
|
|
69
|
+
Component = NodeDefaultView;
|
|
70
|
+
FieldsetLoader = async () => ({
|
|
71
|
+
default: makeCiStageFieldset(
|
|
72
|
+
'Updates GitHub/GitLab commit status, upserts a sticky Markdown summary comment on the PR/MR, and enriches pending AI Git Reviews.',
|
|
73
|
+
),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class CiWaitApprovalInstructionV2 extends Instruction {
|
|
78
|
+
title = tExpr('Await Authorized QA Baseline Approval');
|
|
79
|
+
type = CI_INSTRUCTIONS.waitApproval;
|
|
80
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
81
|
+
icon = (<SafetyCertificateOutlined />);
|
|
82
|
+
Component = NodeDefaultView;
|
|
83
|
+
FieldsetLoader = async () => ({
|
|
84
|
+
default: makeCiStageFieldset(
|
|
85
|
+
'Pauses execution on pure baseline diff mismatches until an authorized user in gateApproverIds approves the baseline.',
|
|
86
|
+
),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class CiPromoteDeployInstructionV2 extends Instruction {
|
|
91
|
+
title = tExpr('Enforce CI Quality Gate & Promote Runtime Stack');
|
|
92
|
+
type = CI_INSTRUCTIONS.promoteDeploy;
|
|
93
|
+
group = CI_WORKFLOW_GROUP_KEY;
|
|
94
|
+
icon = (<CloudUploadOutlined />);
|
|
95
|
+
Component = NodeDefaultView;
|
|
96
|
+
FieldsetLoader = async () => ({
|
|
97
|
+
default: makeCiStageFieldset(
|
|
98
|
+
'Promotes the verified build tag to the runtime Portainer stack when tests pass, or blocks/awaits baseline approval on failure.',
|
|
99
|
+
),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface WorkflowRegistryV2Like {
|
|
104
|
+
registerInstruction?: (type: string, ctor: typeof Instruction) => void;
|
|
105
|
+
instructions?: { register?: (type: string, instance: Instruction) => void };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function registerWorkflowCiInstructionsV2(workflow: WorkflowRegistryV2Like): void {
|
|
109
|
+
const entries: Array<[string, typeof Instruction]> = [
|
|
110
|
+
[CI_INSTRUCTIONS.dispatchRun, CiDispatchRunInstructionV2],
|
|
111
|
+
[CI_INSTRUCTIONS.aiTriage, CiAiTriageInstructionV2],
|
|
112
|
+
[CI_INSTRUCTIONS.publishGitFeedback, CiPublishGitFeedbackInstructionV2],
|
|
113
|
+
[CI_INSTRUCTIONS.waitApproval, CiWaitApprovalInstructionV2],
|
|
114
|
+
[CI_INSTRUCTIONS.promoteDeploy, CiPromoteDeployInstructionV2],
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
for (const [type, Ctor] of entries) {
|
|
118
|
+
if (typeof workflow.registerInstruction === 'function') {
|
|
119
|
+
workflow.registerInstruction(type, Ctor);
|
|
120
|
+
} else {
|
|
121
|
+
workflow.instructions?.register?.(type, new Ctor());
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './server';
|
|
11
|
+
export { default } from './server';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"CI Testing & Quality Gate": "CI Testing & Quality Gate",
|
|
3
|
+
"CI Testing & Quality Gate Workflows": "CI Testing & Quality Gate Workflows",
|
|
4
|
+
"CI Pipelines & Webhooks": "CI Pipelines & Webhooks",
|
|
5
|
+
"CI Gate Runs & Approvals": "CI Gate Runs & Approvals",
|
|
6
|
+
"Create CI Pipeline": "Create CI Pipeline",
|
|
7
|
+
"Edit CI Pipeline": "Edit CI Pipeline",
|
|
8
|
+
"Pipeline": "Pipeline",
|
|
9
|
+
"Pipeline Key": "Pipeline Key",
|
|
10
|
+
"Pipeline Name": "Pipeline Name",
|
|
11
|
+
"Enabled": "Enabled",
|
|
12
|
+
"Target Test Tenant": "Target Test Tenant",
|
|
13
|
+
"Git Repository": "Git Repository",
|
|
14
|
+
"Branch Pattern": "Branch Pattern",
|
|
15
|
+
"Trigger on Push": "Trigger on Push",
|
|
16
|
+
"Trigger on PR / MR": "Trigger on PR / MR",
|
|
17
|
+
"Poll MRs (NAT Fallback)": "Poll MRs (NAT Fallback)",
|
|
18
|
+
"Git Webhook HMAC / Token Secret": "Git Webhook HMAC / Token Secret",
|
|
19
|
+
"Runner Backend": "Runner Backend",
|
|
20
|
+
"External CI (GitHub Actions / GitLab CI Ingest)": "External CI (GitHub Actions / GitLab CI Ingest)",
|
|
21
|
+
"Portainer One-shot Ephemeral Container": "Portainer One-shot Ephemeral Container",
|
|
22
|
+
"Cluster Manager Ephemeral Container / K8s": "Cluster Manager Ephemeral Container / K8s",
|
|
23
|
+
"Test Manager Default Connectors": "Test Manager Default Connectors",
|
|
24
|
+
"Portainer Instance": "Portainer Instance",
|
|
25
|
+
"Endpoint ID": "Endpoint ID",
|
|
26
|
+
"QA Endpoint ID": "QA Endpoint ID",
|
|
27
|
+
"QA Stack ID (Lease)": "QA Stack ID (Lease)",
|
|
28
|
+
"QA App Services (comma-separated)": "QA App Services (comma-separated)",
|
|
29
|
+
"Prod Endpoint ID": "Prod Endpoint ID",
|
|
30
|
+
"Ephemeral Runner Docker Image": "Ephemeral Runner Docker Image",
|
|
31
|
+
"Docker Network": "Docker Network",
|
|
32
|
+
"Timeout (ms)": "Timeout (ms)",
|
|
33
|
+
"Ephemeral Container Command (optional)": "Ephemeral Container Command (optional)",
|
|
34
|
+
"Extra Runner Env JSON": "Extra Runner Env JSON",
|
|
35
|
+
"Pre-Deploy Quality Gate Mode": "Pre-Deploy Quality Gate Mode",
|
|
36
|
+
"No Runtime Promotion (CI Feedback Only)": "No Runtime Promotion (CI Feedback Only)",
|
|
37
|
+
"Auto-Promote Runtime Stack when Passed": "Auto-Promote Runtime Stack when Passed",
|
|
38
|
+
"Require Baseline Approval on Diff Mismatch": "Require Baseline Approval on Diff Mismatch",
|
|
39
|
+
"Linked Portainer Build Pipeline": "Linked Portainer Build Pipeline",
|
|
40
|
+
"Runtime Stack ID": "Runtime Stack ID",
|
|
41
|
+
"Authorized QA Gate Approvers": "Authorized QA Gate Approvers",
|
|
42
|
+
"Select dedicated QA approvers (no bypass)": "Select dedicated QA approvers (no bypass)",
|
|
43
|
+
"Protected Release Branches": "Protected Release Branches",
|
|
44
|
+
"Auto-Rollback Safe (DB Compat)": "Auto-Rollback Safe (DB Compat)",
|
|
45
|
+
"Publish Commit Status": "Publish Commit Status",
|
|
46
|
+
"Sticky PR Comment": "Sticky PR Comment",
|
|
47
|
+
"Enrich AI Git Review": "Enrich AI Git Review",
|
|
48
|
+
"Enable AI Triage": "Enable AI Triage",
|
|
49
|
+
"Cluster Hot-Reload Smoke": "Cluster Hot-Reload Smoke",
|
|
50
|
+
"Commit Status Context": "Commit Status Context",
|
|
51
|
+
"Agent Orchestrator Loop Pattern": "Agent Orchestrator Loop Pattern",
|
|
52
|
+
"Deploy Gate": "Deploy Gate",
|
|
53
|
+
"Approvers": "Approvers",
|
|
54
|
+
"AI & Git Features": "AI & Git Features",
|
|
55
|
+
"Actions": "Actions",
|
|
56
|
+
"Run CI": "Run CI",
|
|
57
|
+
"Edit": "Edit",
|
|
58
|
+
"Delete": "Delete",
|
|
59
|
+
"Delete this CI pipeline?": "Delete this CI pipeline?",
|
|
60
|
+
"Poll Open MRs": "Poll Open MRs",
|
|
61
|
+
"Refresh": "Refresh",
|
|
62
|
+
"Event & Branch": "Event & Branch",
|
|
63
|
+
"Test Run": "Test Run",
|
|
64
|
+
"Test Verdict": "Test Verdict",
|
|
65
|
+
"Approval Decision": "Approval Decision",
|
|
66
|
+
"Deploy Outcome": "Deploy Outcome",
|
|
67
|
+
"Gate State": "Gate State",
|
|
68
|
+
"Approve & Promote": "Approve & Promote",
|
|
69
|
+
"Logs & Triage": "Logs & Triage",
|
|
70
|
+
"CI Gate Run": "CI Gate Run",
|
|
71
|
+
"Commit SHA": "Commit SHA",
|
|
72
|
+
"Build Provenance": "Build Provenance",
|
|
73
|
+
"Git Feedback Sync": "Git Feedback Sync",
|
|
74
|
+
"Approved by": "Approved by",
|
|
75
|
+
"Automatic Production Rollback Verified": "Automatic Production Rollback Verified",
|
|
76
|
+
"Production Rollback Skipped / Failed — Ops Intervention Required": "Production Rollback Skipped / Failed — Ops Intervention Required",
|
|
77
|
+
"PROMOTION HALTED": "PROMOTION HALTED",
|
|
78
|
+
"Promotion Halted": "Promotion Halted",
|
|
79
|
+
"Ops intervention required before resuming production deployments.": "Ops intervention required before resuming production deployments.",
|
|
80
|
+
"Clear Halt": "Clear Halt",
|
|
81
|
+
"Cleared promotion halt on pipeline": "Cleared promotion halt on pipeline",
|
|
82
|
+
"Pending QA Approvals": "Pending QA Approvals",
|
|
83
|
+
"Git Feedback Retrying": "Git Feedback Retrying",
|
|
84
|
+
"Pending Container Cleanups": "Pending Container Cleanups",
|
|
85
|
+
"AI Failure Triage": "AI Failure Triage",
|
|
86
|
+
"Execution Logs": "Execution Logs",
|
|
87
|
+
"No logs recorded.": "No logs recorded.",
|
|
88
|
+
"No CI pipelines configured yet.": "No CI pipelines configured yet.",
|
|
89
|
+
"No CI Gate runs executed yet.": "No CI Gate runs executed yet.",
|
|
90
|
+
"CI Pipeline saved successfully": "CI Pipeline saved successfully",
|
|
91
|
+
"CI Gate run queued via workflow": "CI Gate run queued via workflow",
|
|
92
|
+
"Polled open Merge Requests for CI changes": "Polled open Merge Requests for CI changes",
|
|
93
|
+
"Approved dataset baselines and promoted deployment": "Approved dataset baselines and promoted deployment",
|
|
94
|
+
"CI Gate Run ID (optional override)": "CI Gate Run ID (optional override)",
|
|
95
|
+
"Dispatch CI Test Run & Ephemeral Container": "Dispatch CI Test Run & Ephemeral Container",
|
|
96
|
+
"AI Failure Triage & Agent Loop": "AI Failure Triage & Agent Loop",
|
|
97
|
+
"Publish Git Commit Status & Sticky PR Comment": "Publish Git Commit Status & Sticky PR Comment",
|
|
98
|
+
"Await Authorized QA Baseline Approval": "Await Authorized QA Baseline Approval",
|
|
99
|
+
"Enforce CI Quality Gate & Promote Runtime Stack": "Enforce CI Quality Gate & Promote Runtime Stack",
|
|
100
|
+
"Publishes pending Git commit status, enqueues an isolated Test Manager run, and optionally launches a one-shot ephemeral container.": "Publishes pending Git commit status, enqueues an isolated Test Manager run, and optionally launches a one-shot ephemeral container.",
|
|
101
|
+
"Classifies failed or mismatched CI runs (code regression vs baseline change vs infra flake) and optionally triggers Agent Orchestrator.": "Classifies failed or mismatched CI runs (code regression vs baseline change vs infra flake) and optionally triggers Agent Orchestrator.",
|
|
102
|
+
"Updates GitHub/GitLab commit status, upserts a sticky Markdown summary comment on the PR/MR, and enriches pending AI Git Reviews.": "Updates GitHub/GitLab commit status, upserts a sticky Markdown summary comment on the PR/MR, and enriches pending AI Git Reviews.",
|
|
103
|
+
"Pauses execution on pure baseline diff mismatches until an authorized user in gateApproverIds approves the baseline.": "Pauses execution on pure baseline diff mismatches until an authorized user in gateApproverIds approves the baseline.",
|
|
104
|
+
"Promotes the verified build tag to the runtime Portainer stack when tests pass, or blocks/awaits baseline approval on failure.": "Promotes the verified build tag to the runtime Portainer stack when tests pass, or blocks/awaits baseline approval on failure."
|
|
105
|
+
}
|