@lbdudc/linea-cli 0.0.0-stage → 0.1.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/README.md +268 -2
- package/dist/analysis/wheels/micropip-0.6.0-py3-none-any.whl +0 -0
- package/dist/analysis/wheels/packaging-23.2-py3-none-any.whl +0 -0
- package/dist/chunk-0kg4evyp.js +58 -0
- package/dist/chunk-6y69424k.js +45138 -0
- package/dist/chunk-byt4gzdm.js +9071 -0
- package/dist/chunk-e0n1mfcb.js +12 -0
- package/dist/chunk-fnmh0b0b.js +35 -0
- package/dist/chunk-gmz1f6fc.js +27 -0
- package/dist/chunk-pb6gdhgt.js +3210 -0
- package/dist/chunk-r3nqk2zv.js +50157 -0
- package/dist/chunk-tg9jv9kp.js +11 -0
- package/dist/chunk-x95qa7s6.js +35 -0
- package/dist/chunk-ymrp07ym.js +2452 -0
- package/dist/core/analysisWorker.js +45 -0
- package/dist/index.js +40 -0
- package/dist/line/templates/core/extra.js +54 -0
- package/dist/line/templates/core/transformation.js +208 -0
- package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -0
- package/dist/line/templates/pipeline/ci/test-client.sh +16 -0
- package/dist/line/templates/pipeline/ci/test-server.sh +16 -0
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/package.json +52 -4
- package/src/index.tsx +58 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
analyzeLocalFeatureModelBdd,
|
|
4
|
+
analyzeLocalMetric,
|
|
5
|
+
analyzeLocalFeatureModel
|
|
6
|
+
} from "../chunk-6y69424k.js";
|
|
7
|
+
|
|
8
|
+
// src/core/analysisWorker.ts
|
|
9
|
+
function plain(value, seen = new WeakSet) {
|
|
10
|
+
if (value === null || typeof value !== "object")
|
|
11
|
+
return typeof value === "function" || typeof value === "symbol" ? undefined : value;
|
|
12
|
+
if (seen.has(value))
|
|
13
|
+
return;
|
|
14
|
+
seen.add(value);
|
|
15
|
+
const kind = Object.getPrototypeOf(value)?.constructor?.name;
|
|
16
|
+
if (kind && kind !== "Object" && kind !== "Array" && kind !== "Set" && kind !== "Map") {
|
|
17
|
+
const name = value.name;
|
|
18
|
+
if (typeof name === "string")
|
|
19
|
+
return name;
|
|
20
|
+
const text = String(value);
|
|
21
|
+
return text.startsWith("[object") ? undefined : text;
|
|
22
|
+
}
|
|
23
|
+
if (value instanceof Set)
|
|
24
|
+
return [...value].map((v) => plain(v, seen));
|
|
25
|
+
if (value instanceof Map)
|
|
26
|
+
return Object.fromEntries([...value].map(([k, v]) => [String(k), plain(v, seen)]));
|
|
27
|
+
if (Array.isArray(value))
|
|
28
|
+
return value.map((v) => plain(v, seen));
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const [k, v] of Object.entries(value)) {
|
|
31
|
+
const p = plain(v, seen);
|
|
32
|
+
if (p !== undefined)
|
|
33
|
+
out[k] = p;
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
self.onmessage = async (e) => {
|
|
38
|
+
const job = e.data;
|
|
39
|
+
try {
|
|
40
|
+
const result = job.kind === "analyze" ? await analyzeLocalFeatureModel(job.dir, job.mode) : job.kind === "bdd" ? await analyzeLocalFeatureModelBdd(job.dir) : await analyzeLocalMetric(job.dir, job.metric, job.mode);
|
|
41
|
+
self.postMessage({ ok: true, result: plain(result) });
|
|
42
|
+
} catch (err) {
|
|
43
|
+
self.postMessage({ ok: false, error: err.message ?? String(err) });
|
|
44
|
+
}
|
|
45
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
import {
|
|
4
|
+
package_default
|
|
5
|
+
} from "./chunk-0kg4evyp.js";
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
var args = process.argv.slice(2);
|
|
9
|
+
var HELP = [`linea ${package_default.version} \u2014 the SPLALM command line`, "", "Usage:", " linea the interactive window", " linea <command> [args] run one command and exit (scripts, CI)", "", "A command is `<noun> <verb>`, or a verb on its own:", " linea get my-spl bring an SPL and its products from LINEA (again: update them)", " linea open open what you are in with your editor", " linea check check the SPL / product / package of this folder", " linea push send your changes back as a merge/pull request", " linea spl list | product list | module list | fm show \u2026", " linea help every command", "", "Flags for any command: --json (data for a program) --local (do not talk to the server)", "Exit code: 0 ok \xB7 1 failed, or a check found problems \xB7 2 used wrong", "", "Env:", " LINEA_BASE_URL backend URL (default http://localhost:3000)", " LINEA_TOKEN dev-only JWT override (skips login)", " LINEA_OAUTH_PORT loopback port login listens on (default 53682)", ""].join(`
|
|
10
|
+
`);
|
|
11
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
|
|
12
|
+
process.stdout.write(`linea ${package_default.version}
|
|
13
|
+
`);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
17
|
+
process.stdout.write(HELP);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
if (args[0] === "credential") {
|
|
21
|
+
const {
|
|
22
|
+
credentialHelper,
|
|
23
|
+
traceHelper
|
|
24
|
+
} = await import("./chunk-e0n1mfcb.js");
|
|
25
|
+
const request = await Bun.stdin.text();
|
|
26
|
+
const answer = credentialHelper(args[1], request);
|
|
27
|
+
traceHelper(args[1], request, answer);
|
|
28
|
+
process.stdout.write(answer);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
if (args.length > 0) {
|
|
32
|
+
const {
|
|
33
|
+
runShell
|
|
34
|
+
} = await import("./chunk-tg9jv9kp.js");
|
|
35
|
+
process.exit(await runShell(args));
|
|
36
|
+
}
|
|
37
|
+
var {
|
|
38
|
+
runInteractive
|
|
39
|
+
} = await import("./chunk-gmz1f6fc.js");
|
|
40
|
+
await runInteractive();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function pluralize(name) {
|
|
2
|
+
return name + "s";
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function capitalizeOneWord(word) {
|
|
6
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function camelToSnakeCase(str) {
|
|
10
|
+
return str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => '_' + letter.toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function normalizeKebabCase(str) {
|
|
14
|
+
return str
|
|
15
|
+
.replace(/[\s-]+/g, '-')
|
|
16
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeSnakeCase(str) {
|
|
21
|
+
return str
|
|
22
|
+
.replace(/[\s-]+/g, '_')
|
|
23
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeUrl(str) {
|
|
28
|
+
return str
|
|
29
|
+
.normalize("NFKD")
|
|
30
|
+
.replace(/[\u0300-\u036F]/g, "")
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/[\s]/g, "-")
|
|
33
|
+
.toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getDatabaseConfigFromSpec(data, name, defaultValue) {
|
|
37
|
+
var dataBase = data.basicData.database;
|
|
38
|
+
if (dataBase) {
|
|
39
|
+
if (dataBase[name] && dataBase[name] != "") {
|
|
40
|
+
return dataBase[name];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return defaultValue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getExtraConfigFromSpec(data, name, defaultValue) {
|
|
47
|
+
var extra = data.basicData.extra;
|
|
48
|
+
if (extra) {
|
|
49
|
+
if (extra[name] && extra[name] != "") {
|
|
50
|
+
return extra[name];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return defaultValue;
|
|
54
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
module.exports = modelTransformation;
|
|
2
|
+
|
|
3
|
+
var _metamodelProcessors = [];
|
|
4
|
+
|
|
5
|
+
function registerMetamodelProcessor(fn) {
|
|
6
|
+
_metamodelProcessors.push(fn);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function modelTransformation(input) {
|
|
10
|
+
if (input.data && input.data.basicData) return input;
|
|
11
|
+
|
|
12
|
+
let ret = {};
|
|
13
|
+
ret.features = input.features;
|
|
14
|
+
ret.data = Object.assign({}, modelData(input));
|
|
15
|
+
ret.data.basicData = ret.data.basicData
|
|
16
|
+
? withVersion(ret.data.basicData, input.basicData)
|
|
17
|
+
: basicData(input.basicData);
|
|
18
|
+
|
|
19
|
+
_metamodelProcessors.forEach(function(processor) {
|
|
20
|
+
processor(ret, input);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
ret.data.gui = Object.assign(gui(ret.features, ret.data.basicData.name), ret.data.gui);
|
|
24
|
+
ret.data.menus = Array.isArray(ret.data.menus) && ret.data.menus.length ? ret.data.menus : menus(ret);
|
|
25
|
+
ret.data.statics = ret.data.statics !== undefined ? ret.data.statics : statics(input.statics);
|
|
26
|
+
return ret;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function modelData(input) {
|
|
30
|
+
return input.models && input.models.data ? input.models.data : {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function withVersion(fromModels, given) {
|
|
34
|
+
const ret = Object.assign({}, fromModels);
|
|
35
|
+
if (ret.version === undefined && given && given.version !== undefined) ret.version = given.version;
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function normalize(str, upper) {
|
|
40
|
+
return str
|
|
41
|
+
.normalize("NFKD")
|
|
42
|
+
.replace(/[\u0300-\u036F]/g, "")
|
|
43
|
+
.replace(/[-_]+/g, " ")
|
|
44
|
+
.replace(/[^\w\s]/gi, "")
|
|
45
|
+
.replace(/\s(.)/g, function ($1) {
|
|
46
|
+
return $1.toUpperCase();
|
|
47
|
+
})
|
|
48
|
+
.replace(/\s/g, "")
|
|
49
|
+
.replace(/^(.)/, function ($1) {
|
|
50
|
+
return upper ? $1.toUpperCase() : $1.toLowerCase();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function basicData(input) {
|
|
55
|
+
return {
|
|
56
|
+
index: {
|
|
57
|
+
component: "STATIC",
|
|
58
|
+
view: "welcome",
|
|
59
|
+
},
|
|
60
|
+
languages: input.languages || [],
|
|
61
|
+
name: input.name,
|
|
62
|
+
packageInfo: {
|
|
63
|
+
artifact: normalize(input.name).toLowerCase(),
|
|
64
|
+
group: input.packageGroup || "com.example",
|
|
65
|
+
},
|
|
66
|
+
database: input.database,
|
|
67
|
+
extra: input.extra,
|
|
68
|
+
SRID: input.SRID,
|
|
69
|
+
version: input.version,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function gui(features, name) {
|
|
74
|
+
const ret = {
|
|
75
|
+
settings: {
|
|
76
|
+
font: { family: "Arial", size: "14px" },
|
|
77
|
+
colorset: ["#fff", "#eee", "#777", "#555", "#577492", "#333", "#222"],
|
|
78
|
+
header: { type: "Text", text: name },
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (features.indexOf("GUI_M_Top") !== -1) {
|
|
83
|
+
ret.design = "1";
|
|
84
|
+
} else if (features.indexOf("GUI_M_Left") !== -1) {
|
|
85
|
+
ret.design = "5";
|
|
86
|
+
} else if (features.indexOf("GUI_M_Right") !== -1) {
|
|
87
|
+
ret.design = "6";
|
|
88
|
+
} else {
|
|
89
|
+
ret.design = "4";
|
|
90
|
+
}
|
|
91
|
+
if (features.indexOf("GUI_M_Top") !== -1 && features.indexOf("GUI_M_Left") !== -1) {
|
|
92
|
+
ret.design = "2";
|
|
93
|
+
}
|
|
94
|
+
if (features.indexOf("GUI_M_Top") !== -1 && features.indexOf("GUI_M_Right") !== -1) {
|
|
95
|
+
ret.design = "3";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function statics(input) {
|
|
102
|
+
return input;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function menus(product) {
|
|
106
|
+
const ret = [];
|
|
107
|
+
|
|
108
|
+
switch (product.data.gui.design) {
|
|
109
|
+
case "1": ret.push({ id: "top", elements: [] }); break;
|
|
110
|
+
case "2": ret.push({ id: "top", elements: [] }); ret.push({ id: "left", elements: [] }); break;
|
|
111
|
+
case "3": ret.push({ id: "top", elements: [] }); ret.push({ id: "right", elements: [] }); break;
|
|
112
|
+
case "4": return [];
|
|
113
|
+
case "5": ret.push({ id: "left", elements: [] }); break;
|
|
114
|
+
case "6": ret.push({ id: "right", elements: [] }); break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (product.data.lists && product.features.indexOf("GUI_Lists") !== -1) {
|
|
118
|
+
ret[0].elements.push(listMenu(product.data.lists));
|
|
119
|
+
}
|
|
120
|
+
ret[0].elements.push(listComponents(product.features));
|
|
121
|
+
|
|
122
|
+
if (product.features.indexOf("UserManagement") !== -1) {
|
|
123
|
+
ret[0].elements.push(listUserManagement(product.features));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return ret;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function listMenu(lists) {
|
|
130
|
+
return {
|
|
131
|
+
id: "Lists",
|
|
132
|
+
type: "MENU",
|
|
133
|
+
elements: lists.map((l) => ({
|
|
134
|
+
id: l.id,
|
|
135
|
+
type: "VIEW",
|
|
136
|
+
view: { component: "LIST", view: l.id },
|
|
137
|
+
})),
|
|
138
|
+
access: { admin: true, logged: true },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function listComponents(features) {
|
|
143
|
+
return {
|
|
144
|
+
id: "Components",
|
|
145
|
+
type: "MENU",
|
|
146
|
+
elements: features
|
|
147
|
+
.filter((f) => featureMenu(f, features))
|
|
148
|
+
.map((f) => featureMenu(f, features)),
|
|
149
|
+
access: { admin: true, logged: true },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function featureMenu(feature, features) {
|
|
154
|
+
// Add cases for your platform's features here
|
|
155
|
+
// Example: case "MY_FEATURE": return view("MY_COMPONENT", "My View");
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function listUserManagement(features) {
|
|
160
|
+
const list = [];
|
|
161
|
+
let aux;
|
|
162
|
+
|
|
163
|
+
if (features.indexOf("UM_Authentication") !== -1) {
|
|
164
|
+
aux = view("USER_MANAGEMENT", "Sign in");
|
|
165
|
+
aux.access = { anonymous: true };
|
|
166
|
+
list.push(aux);
|
|
167
|
+
}
|
|
168
|
+
if (features.indexOf("UM_R_Anonymous") !== -1) {
|
|
169
|
+
aux = view("USER_MANAGEMENT", "Registration");
|
|
170
|
+
aux.access = { anonymous: true };
|
|
171
|
+
list.push(aux);
|
|
172
|
+
}
|
|
173
|
+
if (features.indexOf("UM_UP_ByUser") !== -1) {
|
|
174
|
+
aux = view("USER_MANAGEMENT", "Change password");
|
|
175
|
+
aux.access = { admin: true, logged: true };
|
|
176
|
+
list.push(aux);
|
|
177
|
+
}
|
|
178
|
+
if (features.indexOf("UM_UserProfile") !== -1) {
|
|
179
|
+
aux = view("USER_MANAGEMENT", "Profile details");
|
|
180
|
+
aux.access = { admin: true, logged: true };
|
|
181
|
+
list.push(aux);
|
|
182
|
+
}
|
|
183
|
+
if (features.indexOf("UM_UserSessions") !== -1) {
|
|
184
|
+
aux = view("USER_MANAGEMENT", "Sessions");
|
|
185
|
+
aux.access = { admin: true, logged: true };
|
|
186
|
+
list.push(aux);
|
|
187
|
+
}
|
|
188
|
+
if (features.indexOf("UM_UserCRUD") !== -1) {
|
|
189
|
+
aux = view("USER_MANAGEMENT", "User Management");
|
|
190
|
+
aux.access = { admin: true };
|
|
191
|
+
list.push(aux);
|
|
192
|
+
}
|
|
193
|
+
if (features.indexOf("UM_Authentication") !== -1) {
|
|
194
|
+
aux = view("USER_MANAGEMENT", "Exit");
|
|
195
|
+
aux.access = { admin: true, logged: true };
|
|
196
|
+
list.push(aux);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return { id: "Account", type: "MENU", elements: list };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function view(comp, view) {
|
|
203
|
+
return {
|
|
204
|
+
id: view,
|
|
205
|
+
type: "VIEW",
|
|
206
|
+
view: { component: comp, view: view },
|
|
207
|
+
};
|
|
208
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
|
|
3
|
+
# Stages run in sequential order, but jobs within stages run in parallel.
|
|
4
|
+
#
|
|
5
|
+
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
|
|
6
|
+
|
|
7
|
+
stages:
|
|
8
|
+
- test
|
|
9
|
+
|
|
10
|
+
# Test commands live in ci/test-server.sh and ci/test-client.sh.
|
|
11
|
+
# Domain engineers edit those scripts to wire in real tests; this YAML should
|
|
12
|
+
# not need changes.
|
|
13
|
+
|
|
14
|
+
test_server:
|
|
15
|
+
stage: test
|
|
16
|
+
image: gradle:8-jdk21
|
|
17
|
+
variables:
|
|
18
|
+
GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"
|
|
19
|
+
script:
|
|
20
|
+
- sh ./ci/test-server.sh
|
|
21
|
+
cache:
|
|
22
|
+
key: gradle-$CI_COMMIT_REF_SLUG
|
|
23
|
+
paths:
|
|
24
|
+
- .gradle/caches
|
|
25
|
+
- .gradle/wrapper
|
|
26
|
+
artifacts:
|
|
27
|
+
when: always
|
|
28
|
+
reports:
|
|
29
|
+
junit: server/build/test-results/test/**/TEST-*.xml
|
|
30
|
+
expire_in: 1 week
|
|
31
|
+
rules:
|
|
32
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
33
|
+
- if: '$CI_COMMIT_BRANCH'
|
|
34
|
+
|
|
35
|
+
test_client:
|
|
36
|
+
stage: test
|
|
37
|
+
image: node:20
|
|
38
|
+
script:
|
|
39
|
+
- sh ./ci/test-client.sh
|
|
40
|
+
cache:
|
|
41
|
+
key: node-$CI_COMMIT_REF_SLUG
|
|
42
|
+
paths:
|
|
43
|
+
- client/node_modules
|
|
44
|
+
artifacts:
|
|
45
|
+
when: always
|
|
46
|
+
reports:
|
|
47
|
+
junit: client/test-results/**/junit*.xml
|
|
48
|
+
expire_in: 1 week
|
|
49
|
+
rules:
|
|
50
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
51
|
+
- if: '$CI_COMMIT_BRANCH'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# Client test command for this product.
|
|
4
|
+
#
|
|
5
|
+
# Default is a no-op (exit 0) so generated products with no tests yield a
|
|
6
|
+
# green pipeline. Replace the echo+exit below with the real test command,
|
|
7
|
+
# e.g.:
|
|
8
|
+
#
|
|
9
|
+
# cd client && npm ci && npm test
|
|
10
|
+
# cd client && yarn install --frozen-lockfile && yarn test
|
|
11
|
+
#
|
|
12
|
+
# Any non-zero exit will fail the test_client job in .gitlab-ci.yml.
|
|
13
|
+
|
|
14
|
+
echo "[test-client] No client tests defined for this product."
|
|
15
|
+
echo "[test-client] Edit ci/test-client.sh to wire in real tests."
|
|
16
|
+
exit 0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# Server test command for this product.
|
|
4
|
+
#
|
|
5
|
+
# Default is a no-op (exit 0) so generated products with no tests yield a
|
|
6
|
+
# green pipeline. Replace the echo+exit below with the real test command,
|
|
7
|
+
# e.g.:
|
|
8
|
+
#
|
|
9
|
+
# cd server && ./gradlew test
|
|
10
|
+
# cd server && mvn test
|
|
11
|
+
#
|
|
12
|
+
# Any non-zero exit will fail the test_server job in .gitlab-ci.yml.
|
|
13
|
+
|
|
14
|
+
echo "[test-server] No server tests defined for this product."
|
|
15
|
+
echo "[test-server] Edit ci/test-server.sh to wire in real tests."
|
|
16
|
+
exit 0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# The same two jobs as .gitlab-ci.yml, for GitHub Actions.
|
|
2
|
+
#
|
|
3
|
+
# Test commands live in ci/test-server.sh and ci/test-client.sh.
|
|
4
|
+
# Domain engineers edit those scripts to wire in real tests; this YAML should
|
|
5
|
+
# not need changes.
|
|
6
|
+
|
|
7
|
+
name: CI
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
pull_request:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test_server:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
container: gradle:8-jdk21
|
|
17
|
+
env:
|
|
18
|
+
GRADLE_USER_HOME: ${{ github.workspace }}/.gradle
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: actions/cache@v4
|
|
22
|
+
with:
|
|
23
|
+
key: gradle-${{ github.ref_name }}
|
|
24
|
+
path: |
|
|
25
|
+
.gradle/caches
|
|
26
|
+
.gradle/wrapper
|
|
27
|
+
- run: sh ./ci/test-server.sh
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
if: always()
|
|
30
|
+
with:
|
|
31
|
+
name: server-test-results
|
|
32
|
+
path: server/build/test-results/test/**/TEST-*.xml
|
|
33
|
+
retention-days: 7
|
|
34
|
+
|
|
35
|
+
test_client:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
container: node:20
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/cache@v4
|
|
41
|
+
with:
|
|
42
|
+
key: node-${{ github.ref_name }}
|
|
43
|
+
path: client/node_modules
|
|
44
|
+
- run: sh ./ci/test-client.sh
|
|
45
|
+
- uses: actions/upload-artifact@v4
|
|
46
|
+
if: always()
|
|
47
|
+
with:
|
|
48
|
+
name: client-test-results
|
|
49
|
+
path: client/test-results/**/junit*.xml
|
|
50
|
+
retention-days: 7
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#
|
|
2
|
+
# CI of an SPL: what a merge request does to the products that already exist.
|
|
3
|
+
#
|
|
4
|
+
# validate the feature model against the real products (their .linea/spec.json is fetched from
|
|
5
|
+
# the repositories listed in products.json); the version of the line is raised when
|
|
6
|
+
# features are removed
|
|
7
|
+
# select the products the change can break (the ones that have a feature the changed code tests)
|
|
8
|
+
# products a child pipeline: each selected product is derived from the proposed code, checked for
|
|
9
|
+
# annotations left in it, derived twice to see that it is deterministic, and tested
|
|
10
|
+
# metrics the selected products are derived from the proposed code and from the target branch and
|
|
11
|
+
# measured (cyclomatic complexity); what each touched feature brings is measured by deriving
|
|
12
|
+
# a product with and without it. The result is a note on the merge request and the Code
|
|
13
|
+
# Quality widget.
|
|
14
|
+
# test GitLab's security scans (SAST, secret detection, dependency scanning)
|
|
15
|
+
#
|
|
16
|
+
# A scheduled pipeline (or one started by hand) does more:
|
|
17
|
+
# - every product of the SPL is derived and checked, and what is committed in each product is compared
|
|
18
|
+
# with what the line generates (drift: someone edited the generated code by hand)
|
|
19
|
+
# - a pairwise sample of configurations (every pair of features together once) is derived and tested,
|
|
20
|
+
# to find interactions between features that no real product has
|
|
21
|
+
#
|
|
22
|
+
# Pushing a tag asks LINEA to generate again every product of the SPL (release), once LINEA_URL and LINEA_TOKEN are
|
|
23
|
+
# set: without them there is no release job, and a tag runs nothing.
|
|
24
|
+
#
|
|
25
|
+
# Needs these CI/CD variables:
|
|
26
|
+
# LINEA_CI_TOKEN a token that can read the product repositories and the registry of packages, and
|
|
27
|
+
# comment on merge requests
|
|
28
|
+
# LINEA_CI_PACKAGE where linea-ci is installed from (npm name, git URL or tarball)
|
|
29
|
+
# LINEA_URL, LINEA_TOKEN only for releases: the address of LINEA and a session token of a user who
|
|
30
|
+
# can generate the products
|
|
31
|
+
|
|
32
|
+
include:
|
|
33
|
+
- template: Security/SAST.gitlab-ci.yml
|
|
34
|
+
- template: Security/Secret-Detection.gitlab-ci.yml
|
|
35
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
36
|
+
|
|
37
|
+
workflow:
|
|
38
|
+
rules:
|
|
39
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
40
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
|
41
|
+
- if: '$CI_PIPELINE_SOURCE == "web"'
|
|
42
|
+
- if: '$CI_COMMIT_TAG'
|
|
43
|
+
|
|
44
|
+
variables:
|
|
45
|
+
LINEA_CI_PACKAGE: "git+https://$CI_SERVER_HOST/linea/linea-ci.git"
|
|
46
|
+
LINEA_CI_MAX_PRODUCTS: "5"
|
|
47
|
+
LINEA_CI_MAX_SAMPLES: "30"
|
|
48
|
+
LINEA_CI_MAX_CCN: "15"
|
|
49
|
+
LINEA_CI_SPECS: ".linea-ci/specs"
|
|
50
|
+
|
|
51
|
+
stages:
|
|
52
|
+
- validate
|
|
53
|
+
- select
|
|
54
|
+
- products
|
|
55
|
+
- metrics
|
|
56
|
+
- test
|
|
57
|
+
- release
|
|
58
|
+
|
|
59
|
+
.linea-ci:
|
|
60
|
+
image: node:22
|
|
61
|
+
before_script:
|
|
62
|
+
# a package kept in this GitLab (a git URL on its host) is cloned with the token of the job
|
|
63
|
+
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/".insteadOf "https://${CI_SERVER_HOST}/"
|
|
64
|
+
- npm install --global "$LINEA_CI_PACKAGE"
|
|
65
|
+
|
|
66
|
+
.not-on-tags:
|
|
67
|
+
rules:
|
|
68
|
+
- if: '$CI_COMMIT_TAG'
|
|
69
|
+
when: never
|
|
70
|
+
- when: on_success
|
|
71
|
+
|
|
72
|
+
specs:
|
|
73
|
+
extends: [.linea-ci, .not-on-tags]
|
|
74
|
+
stage: validate
|
|
75
|
+
script:
|
|
76
|
+
- linea-ci fetch-specs --line . --out "$LINEA_CI_SPECS"
|
|
77
|
+
- linea-ci validate-specs --line . "$LINEA_CI_SPECS"
|
|
78
|
+
artifacts:
|
|
79
|
+
paths:
|
|
80
|
+
- .linea-ci/specs/
|
|
81
|
+
expire_in: 1 week
|
|
82
|
+
|
|
83
|
+
version:
|
|
84
|
+
extends: .linea-ci
|
|
85
|
+
stage: validate
|
|
86
|
+
variables:
|
|
87
|
+
GIT_DEPTH: "0"
|
|
88
|
+
script:
|
|
89
|
+
- git worktree add ../base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
90
|
+
- linea-ci check-version --line . --base-line ../base
|
|
91
|
+
rules:
|
|
92
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
93
|
+
|
|
94
|
+
select:
|
|
95
|
+
extends: [.linea-ci, .not-on-tags]
|
|
96
|
+
stage: select
|
|
97
|
+
needs: [specs]
|
|
98
|
+
script:
|
|
99
|
+
- |
|
|
100
|
+
if [ "$CI_PIPELINE_SOURCE" = "merge_request_event" ]; then
|
|
101
|
+
RANGE="--base $CI_MERGE_REQUEST_DIFF_BASE_SHA --head $CI_COMMIT_SHA --max $LINEA_CI_MAX_PRODUCTS"
|
|
102
|
+
else
|
|
103
|
+
# nightly or by hand: the feature model is touched as far as the selection goes, so every product is rebuilt and compared with its repository
|
|
104
|
+
RANGE="--changed src/platform/model.uvl --with-drift"
|
|
105
|
+
fi
|
|
106
|
+
linea-ci select-products --line . --specs "$LINEA_CI_SPECS" $RANGE --pipeline-out .linea-ci/child.yml | tee .linea-ci/selection.json
|
|
107
|
+
artifacts:
|
|
108
|
+
paths:
|
|
109
|
+
- .linea-ci/
|
|
110
|
+
expire_in: 1 week
|
|
111
|
+
|
|
112
|
+
products:
|
|
113
|
+
stage: products
|
|
114
|
+
needs: [select]
|
|
115
|
+
variables:
|
|
116
|
+
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
|
117
|
+
trigger:
|
|
118
|
+
include:
|
|
119
|
+
- artifact: .linea-ci/child.yml
|
|
120
|
+
job: select
|
|
121
|
+
strategy: depend
|
|
122
|
+
rules:
|
|
123
|
+
- if: '$CI_COMMIT_TAG'
|
|
124
|
+
when: never
|
|
125
|
+
- when: on_success
|
|
126
|
+
|
|
127
|
+
sample:
|
|
128
|
+
extends: .linea-ci
|
|
129
|
+
stage: select
|
|
130
|
+
needs: [specs]
|
|
131
|
+
script:
|
|
132
|
+
- linea-ci sample-configs --line . --specs "$LINEA_CI_SPECS" --out .linea-ci/samples --max "$LINEA_CI_MAX_SAMPLES" --pipeline-out .linea-ci/samples-child.yml
|
|
133
|
+
artifacts:
|
|
134
|
+
paths:
|
|
135
|
+
- .linea-ci/
|
|
136
|
+
expire_in: 1 week
|
|
137
|
+
rules:
|
|
138
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"'
|
|
139
|
+
|
|
140
|
+
samples:
|
|
141
|
+
stage: products
|
|
142
|
+
needs: [sample]
|
|
143
|
+
variables:
|
|
144
|
+
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
|
145
|
+
trigger:
|
|
146
|
+
include:
|
|
147
|
+
- artifact: .linea-ci/samples-child.yml
|
|
148
|
+
job: sample
|
|
149
|
+
strategy: depend
|
|
150
|
+
rules:
|
|
151
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"'
|
|
152
|
+
|
|
153
|
+
metrics:
|
|
154
|
+
extends: .linea-ci
|
|
155
|
+
stage: metrics
|
|
156
|
+
needs: [select]
|
|
157
|
+
variables:
|
|
158
|
+
GIT_DEPTH: "0"
|
|
159
|
+
script:
|
|
160
|
+
- apt-get update -qq && apt-get install -y -qq python3-pip > /dev/null && pip install --quiet --break-system-packages lizard
|
|
161
|
+
- git worktree add ../base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
162
|
+
- linea-ci mr-metrics --line . --specs "$LINEA_CI_SPECS" --selection .linea-ci/selection.json --base-line ../base --max-ccn "$LINEA_CI_MAX_CCN" --out .linea-ci/metrics
|
|
163
|
+
- linea-ci mr-note .linea-ci/metrics/metrics.md || echo "The note could not be posted (LINEA_CI_TOKEN needs the api scope)."
|
|
164
|
+
artifacts:
|
|
165
|
+
when: always
|
|
166
|
+
paths:
|
|
167
|
+
- .linea-ci/metrics/metrics.md
|
|
168
|
+
- .linea-ci/metrics/metrics.json
|
|
169
|
+
reports:
|
|
170
|
+
codequality: .linea-ci/metrics/gl-code-quality-report.json
|
|
171
|
+
expire_in: 1 week
|
|
172
|
+
allow_failure: true
|
|
173
|
+
rules:
|
|
174
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
175
|
+
|
|
176
|
+
release:
|
|
177
|
+
extends: .linea-ci
|
|
178
|
+
stage: release
|
|
179
|
+
script:
|
|
180
|
+
- linea-ci release-products --linea-url "$LINEA_URL" --line "$CI_PROJECT_NAME"
|
|
181
|
+
rules:
|
|
182
|
+
- if: '$CI_COMMIT_TAG && $LINEA_TOKEN'
|