@lbdudc/linea-core 0.1.1 → 0.1.2
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 +132 -260
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/transformation.js +17 -5
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +22 -7
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uvl-text.js","sourceRoot":"","sources":["../../src/analysis/uvl-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD;;;GAGG;AAEH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,UAAU;IACV,aAAa;IACb,IAAI;IACJ,UAAU;IACV,aAAa;CACd,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,SAAiB,EAAU,EAAE;IAClE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,qBAAqB,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,GAAG,CAAA;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AA;IACb,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC7E,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,aAAa,GAAG,IAAI,CAAA;YACpB,SAAQ;QACV,CAAC;QACD,IAAI,aAAa;YAAE,SAAQ;QAC3B,IAAI,OAAO,KAAK,UAAU;YAAE,SAAQ;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACpD,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YACvC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { InvalidArgumentError } from '../errors.js'\n\n/**\n * What the flamapy analysis needs of the UVL text it is given. (The feature model itself is bango's: a model of the feature metamodel, which\n * `printUvl` writes as UVL; these only prepare that text for the analysis service.)\n */\n\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\n 'mandatory',\n 'optional',\n 'alternative',\n 'or',\n 'features',\n 'constraints'\n])\n\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\n if (typeof uvl !== 'string') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\n }\n return uvl\n}\n\nconst expandTabs = (line: string, tabSize = 4): string => {\n let out = ''\n let column = 0\n for (const char of line) {\n if (char === '\\t') {\n const width = tabSize - (column % tabSize)\n out += ' '.repeat(width)\n column += width\n } else {\n out += char\n column += 1\n }\n }\n return out\n}\n\n/** The UVL with its tabs as spaces and its line breaks unified, as the analysis service reads it. */\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n return unified\n .split('\\n')\n .map((line) => expandTabs(line, 4))\n .join('\\n')\n}\n\n/** About how many features a UVL text declares: what decides how much of the analysis is worth asking for. */\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\n const document = assertUvlString(uvl, 'uvl')\n let inConstraints = false\n let count = 0\n for (const line of document.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\n if (trimmed === 'constraints') {\n inConstraints = true\n continue\n }\n if (inConstraints) continue\n if (trimmed === 'features') continue\n const indent = line.length - line.trimStart().length\n if (indent >= 2) {\n const name = trimmed.split(/[\\s{[]/)[0]\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\n }\n }\n return count\n}\n"]}
|
package/dist/assets.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Directory holding the packaged assets: `src/` when running from source,
|
|
3
|
-
* `dist/` when running from the published package.
|
|
4
|
-
*/
|
|
5
1
|
export declare const assetsRoot: () => string;
|
|
6
|
-
/**
|
|
7
|
-
* Resolves the absolute path of an asset shipped with linea-core.
|
|
8
|
-
*
|
|
9
|
-
* @param params.segments Path segments relative to the assets root,
|
|
10
|
-
* e.g. `resolveAsset({ segments: ['line', 'templates', 'config.json'] })`.
|
|
11
|
-
* @returns Absolute path of the asset.
|
|
12
|
-
* @throws {InvalidArgumentError} if `segments` is not an array of strings.
|
|
13
|
-
*/
|
|
14
2
|
export declare const resolveAsset: ({ segments }: {
|
|
15
3
|
segments: string[];
|
|
16
4
|
}) => string;
|
package/dist/assets.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolution of assets packaged with the library.
|
|
3
|
-
*
|
|
4
|
-
* Non-TypeScript files under `src/` (line templates, pipeline files...) are not
|
|
5
|
-
* compiled: `scripts/copy-assets.mjs` mirrors them into `dist/` at build time,
|
|
6
|
-
* preserving their relative path. That means `src/line/templates/x` ends up at
|
|
7
|
-
* `dist/line/templates/x`, so the path relative to THIS module is the same
|
|
8
|
-
* before and after the build.
|
|
9
|
-
*
|
|
10
|
-
* Resolution goes through `import.meta.url` and never through `process.cwd()`:
|
|
11
|
-
* linea-core is a library and must work regardless of where the host process was
|
|
12
|
-
* started from (ADR-014).
|
|
13
|
-
*/
|
|
14
1
|
import path from 'node:path';
|
|
15
2
|
import { fileURLToPath } from 'node:url';
|
|
16
3
|
import { InvalidArgumentError } from './errors.js';
|
|
17
|
-
/**
|
|
18
|
-
* Directory holding the packaged assets: `src/` when running from source,
|
|
19
|
-
* `dist/` when running from the published package.
|
|
20
|
-
*/
|
|
21
4
|
export const assetsRoot = () => path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the absolute path of an asset shipped with linea-core.
|
|
24
|
-
*
|
|
25
|
-
* @param params.segments Path segments relative to the assets root,
|
|
26
|
-
* e.g. `resolveAsset({ segments: ['line', 'templates', 'config.json'] })`.
|
|
27
|
-
* @returns Absolute path of the asset.
|
|
28
|
-
* @throws {InvalidArgumentError} if `segments` is not an array of strings.
|
|
29
|
-
*/
|
|
30
5
|
export const resolveAsset = ({ segments }) => {
|
|
31
6
|
if (!Array.isArray(segments) || segments.some((segment) => typeof segment !== 'string')) {
|
|
32
7
|
throw new InvalidArgumentError('"segments" must be an array of strings.');
|
package/dist/assets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAA0B,EAAU,EAAE;IAC3E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC;QACxF,MAAM,IAAI,oBAAoB,CAAC,yCAAyC,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { InvalidArgumentError } from './errors.js'\n\nexport const assetsRoot = (): string => path.dirname(fileURLToPath(import.meta.url))\n\nexport const resolveAsset = ({ segments }: { segments: string[] }): string => {\n if (!Array.isArray(segments) || segments.some((segment) => typeof segment !== 'string')) {\n throw new InvalidArgumentError('\"segments\" must be an array of strings.')\n }\n return path.join(assetsRoot(), ...segments)\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** What an SPL's annotated code mentions: for each file (relative to `src/platform/code`) the features it tests and how many times. */
|
|
2
|
+
export type FeaturesByFile = Record<string, Record<string, number>>;
|
|
3
|
+
/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */
|
|
4
|
+
export declare const analyzeAnnotations: ({ lineDir }: {
|
|
5
|
+
lineDir: string;
|
|
6
|
+
}) => Promise<FeaturesByFile>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createEngine } from '../derivation/engine.js';
|
|
2
|
+
/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */
|
|
3
|
+
export const analyzeAnnotations = async ({ lineDir }) => {
|
|
4
|
+
const engine = await createEngine(lineDir);
|
|
5
|
+
const report = await engine.analyseAnnotations();
|
|
6
|
+
const byFile = {};
|
|
7
|
+
for (const [file, result] of Object.entries(report.long())) {
|
|
8
|
+
byFile[file.split('\\').join('/').replace(/^\.?\//, '')] = { ...(result.feature ?? {}) };
|
|
9
|
+
}
|
|
10
|
+
return byFile;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/ci/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAStD,wHAAwH;AACxH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EAAE,OAAO,EAAuB,EAA2B,EAAE;IACpG,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAA2E,CAAA;IACpH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAA;IAChD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAA;IAC1F,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { createEngine } from '../derivation/engine.js'\n\n/** What an SPL's annotated code mentions: for each file (relative to `src/platform/code`) the features it tests and how many times. */\nexport type FeaturesByFile = Record<string, Record<string, number>>\n\ninterface AnalysisReportHandle {\n long: () => Record<string, { feature?: Record<string, number> }>\n}\n\n/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */\nexport const analyzeAnnotations = async ({ lineDir }: { lineDir: string }): Promise<FeaturesByFile> => {\n const engine = await createEngine(lineDir) as unknown as { analyseAnnotations: () => Promise<AnalysisReportHandle> }\n const report = await engine.analyseAnnotations()\n const byFile: FeaturesByFile = {}\n for (const [file, result] of Object.entries(report.long())) {\n byFile[file.split('\\\\').join('/').replace(/^\\.?\\//, '')] = { ...(result.feature ?? {}) }\n }\n return byFile\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The annotation delimiters of an SPL, as its platform `config.json` declares them. */
|
|
2
|
+
export interface LeftoverDelimiters {
|
|
3
|
+
readonly delimiters: readonly {
|
|
4
|
+
readonly start: string;
|
|
5
|
+
readonly end: string;
|
|
6
|
+
}[];
|
|
7
|
+
readonly ignore?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface Leftover {
|
|
10
|
+
/** Path relative to the checked directory, with forward slashes. */
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly line: number;
|
|
13
|
+
readonly delimiter: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked
|
|
17
|
+
* for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine
|
|
18
|
+
* does not process for it comes out untouched (a `/*% ... %*\/` in a `.json`, where only `###< >###` is processed).
|
|
19
|
+
*/
|
|
20
|
+
export declare const checkLeftovers: ({ productDir, config, exclude }: {
|
|
21
|
+
productDir: string;
|
|
22
|
+
config: LeftoverDelimiters;
|
|
23
|
+
/** Paths relative to `productDir` that are allowed to contain delimiters. */
|
|
24
|
+
exclude?: readonly string[];
|
|
25
|
+
}) => Leftover[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { InvalidArgumentError } from '../errors.js';
|
|
4
|
+
const ALWAYS_SKIPPED = new Set(['.git', 'node_modules']);
|
|
5
|
+
const isBinary = (content) => content.subarray(0, 8000).includes(0);
|
|
6
|
+
const walk = (dir, skipped, visit) => {
|
|
7
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
8
|
+
if (skipped.has(entry.name))
|
|
9
|
+
continue;
|
|
10
|
+
const full = path.join(dir, entry.name);
|
|
11
|
+
if (entry.isDirectory())
|
|
12
|
+
walk(full, skipped, visit);
|
|
13
|
+
else if (entry.isFile())
|
|
14
|
+
visit(full);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked
|
|
19
|
+
* for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine
|
|
20
|
+
* does not process for it comes out untouched (a `/*% ... %*\/` in a `.json`, where only `###< >###` is processed).
|
|
21
|
+
*/
|
|
22
|
+
export const checkLeftovers = ({ productDir, config, exclude = [] }) => {
|
|
23
|
+
if (typeof productDir !== 'string' || productDir.trim() === '') {
|
|
24
|
+
throw new InvalidArgumentError('"productDir" must be a non-empty path.');
|
|
25
|
+
}
|
|
26
|
+
const root = path.resolve(productDir);
|
|
27
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
|
|
28
|
+
throw new InvalidArgumentError(`"productDir" is not a directory: ${root}`);
|
|
29
|
+
}
|
|
30
|
+
const markers = [...new Set(config.delimiters.flatMap(({ start, end }) => [start, end]))]
|
|
31
|
+
.filter((marker) => marker !== '');
|
|
32
|
+
const skipped = new Set([...ALWAYS_SKIPPED, ...(config.ignore ?? [])]);
|
|
33
|
+
const excluded = new Set(exclude);
|
|
34
|
+
const found = [];
|
|
35
|
+
walk(root, skipped, (file) => {
|
|
36
|
+
const relative = path.relative(root, file).split(path.sep).join('/');
|
|
37
|
+
if (excluded.has(relative))
|
|
38
|
+
return;
|
|
39
|
+
const content = fs.readFileSync(file);
|
|
40
|
+
if (isBinary(content))
|
|
41
|
+
return;
|
|
42
|
+
content.toString('utf8').split('\n').forEach((text, index) => {
|
|
43
|
+
const delimiter = markers.find((marker) => text.includes(marker));
|
|
44
|
+
if (delimiter !== undefined)
|
|
45
|
+
found.push({ file: relative, line: index + 1, delimiter });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=leftovers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leftovers.js","sourceRoot":"","sources":["../../src/ci/leftovers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAenD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAExD,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEpF,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,OAA4B,EAAE,KAA6B,EAAQ,EAAE;IAC9F,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACjE,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,I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s'\nimport path from 'node:path'\nimport { InvalidArgumentError } from '../errors.js'\n\n/** The annotation delimiters of an SPL, as its platform `config.json` declares them. */\nexport interface LeftoverDelimiters {\n readonly delimiters: readonly { readonly start: string, readonly end: string }[]\n readonly ignore?: readonly string[]\n}\n\nexport interface Leftover {\n /** Path relative to the checked directory, with forward slashes. */\n readonly file: string\n readonly line: number\n readonly delimiter: string\n}\n\nconst ALWAYS_SKIPPED = new Set(['.git', 'node_modules'])\n\nconst isBinary = (content: Buffer): boolean => content.subarray(0, 8000).includes(0)\n\nconst walk = (dir: string, skipped: ReadonlySet<string>, visit: (file: string) => void): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (skipped.has(entry.name)) continue\n const full = path.join(dir, entry.name)\n if (entry.isDirectory()) walk(full, skipped, visit)\n else if (entry.isFile()) visit(full)\n }\n}\n\n/**\n * Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked\n * for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine\n * does not process for it comes out untouched (a `/*% ... %*\\/` in a `.json`, where only `###< >###` is processed).\n */\nexport const checkLeftovers = ({\n productDir,\n config,\n exclude = []\n}: {\n productDir: string\n config: LeftoverDelimiters\n /** Paths relative to `productDir` that are allowed to contain delimiters. */\n exclude?: readonly string[]\n}): Leftover[] => {\n if (typeof productDir !== 'string' || productDir.trim() === '') {\n throw new InvalidArgumentError('\"productDir\" must be a non-empty path.')\n }\n const root = path.resolve(productDir)\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n throw new InvalidArgumentError(`\"productDir\" is not a directory: ${root}`)\n }\n\n const markers = [...new Set(config.delimiters.flatMap(({ start, end }) => [start, end]))]\n .filter((marker) => marker !== '')\n const skipped = new Set([...ALWAYS_SKIPPED, ...(config.ignore ?? [])])\n const excluded = new Set(exclude)\n\n const found: Leftover[] = []\n walk(root, skipped, (file) => {\n const relative = path.relative(root, file).split(path.sep).join('/')\n if (excluded.has(relative)) return\n const content = fs.readFileSync(file)\n if (isBinary(content)) return\n content.toString('utf8').split('\\n').forEach((text, index) => {\n const delimiter = markers.find((marker) => text.includes(marker))\n if (delimiter !== undefined) found.push({ file: relative, line: index + 1, delimiter })\n })\n })\n return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../feature-model/uvl.js';
|
|
2
|
+
/**
|
|
3
|
+
* A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to
|
|
4
|
+
* look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least
|
|
5
|
+
* that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.
|
|
6
|
+
*/
|
|
7
|
+
export declare const pairwiseSelections: ({ tree, base, max }: {
|
|
8
|
+
tree: FeatureModelTree;
|
|
9
|
+
base?: readonly string[];
|
|
10
|
+
max?: number;
|
|
11
|
+
}) => string[][];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { featuresOf } from '../feature-model/uvl.js';
|
|
2
|
+
import { activateFeature, completeSelection } from './validate-specs.js';
|
|
3
|
+
/**
|
|
4
|
+
* A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to
|
|
5
|
+
* look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least
|
|
6
|
+
* that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.
|
|
7
|
+
*/
|
|
8
|
+
export const pairwiseSelections = ({ tree, base = [], max = 50 }) => {
|
|
9
|
+
const names = featuresOf({ tree }).map(({ name }) => name).filter((name) => name !== tree.root.name);
|
|
10
|
+
const pairKey = (a, b) => (a <= b ? `${a}\u0000${b}` : `${b}\u0000${a}`);
|
|
11
|
+
const pairsOf = (selection) => {
|
|
12
|
+
const on = names.filter((name) => selection.has(name));
|
|
13
|
+
return on.flatMap((a, i) => on.slice(i).map((b) => pairKey(a, b)));
|
|
14
|
+
};
|
|
15
|
+
const covered = new Set(pairsOf(completeSelection({ tree, features: base })));
|
|
16
|
+
const configurations = [];
|
|
17
|
+
for (let i = 0; i < names.length && configurations.length < max; i++) {
|
|
18
|
+
for (let j = i; j < names.length && configurations.length < max; j++) {
|
|
19
|
+
const [a, b] = [names[i], names[j]];
|
|
20
|
+
if (covered.has(pairKey(a, b)))
|
|
21
|
+
continue;
|
|
22
|
+
const withA = activateFeature({ tree, features: base, feature: a });
|
|
23
|
+
const both = withA === undefined ? undefined : a === b ? withA : activateFeature({ tree, features: withA, feature: b });
|
|
24
|
+
// what cannot be had is not tried again
|
|
25
|
+
covered.add(pairKey(a, b));
|
|
26
|
+
if (both === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
configurations.push(both);
|
|
29
|
+
for (const key of pairsOf(new Set(both)))
|
|
30
|
+
covered.add(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return configurations;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=pairwise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairwise.js","sourceRoot":"","sources":["../../src/ci/pairwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,yBAAyB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAsE,EAAc,EAAE;IAClJ,MAAM,KAAK,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC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AE,CAAC,CAAC,CAAC;gBAAE,SAAQ;YACxC,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;YACnE,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;YACvH,wCAAwC;YACxC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;YAC1B,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAQ;YAChC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACzB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA","sourcesContent":["import { featuresOf, type FeatureModelTree } from '../feature-model/uvl.js'\nimport { activateFeature, completeSelection } from './validate-specs.js'\n\n/**\n * A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to\n * look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least\n * that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.\n */\nexport const pairwiseSelections = ({ tree, base = [], max = 50 }: { tree: FeatureModelTree, base?: readonly string[], max?: number }): string[][] => {\n const names = featuresOf({ tree }).map(({ name }) => name).filter((name) => name !== tree.root.name)\n const pairKey = (a: string, b: string): string => (a <= b ? `${a}\\u0000${b}` : `${b}\\u0000${a}`)\n const pairsOf = (selection: ReadonlySet<string>): string[] => {\n const on = names.filter((name) => selection.has(name))\n return on.flatMap((a, i) => on.slice(i).map((b) => pairKey(a, b)))\n }\n\n const covered = new Set<string>(pairsOf(completeSelection({ tree, features: base })))\n const configurations: string[][] = []\n for (let i = 0; i < names.length && configurations.length < max; i++) {\n for (let j = i; j < names.length && configurations.length < max; j++) {\n const [a, b] = [names[i]!, names[j]!]\n if (covered.has(pairKey(a, b))) continue\n const withA = activateFeature({ tree, features: base, feature: a })\n const both = withA === undefined ? undefined : a === b ? withA : activateFeature({ tree, features: withA, feature: b })\n // what cannot be had is not tried again\n covered.add(pairKey(a, b))\n if (both === undefined) continue\n configurations.push(both)\n for (const key of pairsOf(new Set(both))) covered.add(key)\n }\n }\n return configurations\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations
|
|
3
|
+
* left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes
|
|
4
|
+
* `linea-ci` available in the job.
|
|
5
|
+
*/
|
|
6
|
+
export declare const renderChildPipeline: ({ products, specsDir, image, tooling, parentJob, repositories, tags }: {
|
|
7
|
+
products: readonly string[];
|
|
8
|
+
/** Where the specs of the products are, relative to the root of the SPL repository (`fetch-specs` writes them there). */
|
|
9
|
+
specsDir: string;
|
|
10
|
+
image?: string;
|
|
11
|
+
tooling?: string;
|
|
12
|
+
/** The job of the parent pipeline whose artifacts hold the specs and the SPL checkout. */
|
|
13
|
+
parentJob?: string;
|
|
14
|
+
/** Product name -> where its repository is: those listed also get `check-drift` (what is committed is what the line generates). */
|
|
15
|
+
repositories?: Readonly<Record<string, string>>;
|
|
16
|
+
/** The runner tags the jobs ask for (a runner that takes no untagged jobs runs nothing otherwise). */
|
|
17
|
+
tags?: readonly string[];
|
|
18
|
+
}) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const JOB_NAME_UNSAFE = /[^A-Za-z0-9_.-]/g;
|
|
2
|
+
/**
|
|
3
|
+
* The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations
|
|
4
|
+
* left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes
|
|
5
|
+
* `linea-ci` available in the job.
|
|
6
|
+
*/
|
|
7
|
+
export const renderChildPipeline = ({ products, specsDir, image = 'node:22', tooling = `git config --global url."https://gitlab-ci-token:\${CI_JOB_TOKEN}@\${CI_SERVER_HOST}/".insteadOf "https://\${CI_SERVER_HOST}/" && npm install --global "$LINEA_CI_PACKAGE"`, parentJob = 'select', repositories = {}, tags = [] }) => {
|
|
8
|
+
const tagLines = tags.length === 0 ? [] : [` tags: ${JSON.stringify(tags)}`];
|
|
9
|
+
if (products.length === 0) {
|
|
10
|
+
return [
|
|
11
|
+
'stages: [products]',
|
|
12
|
+
'no-products-affected:',
|
|
13
|
+
' stage: products',
|
|
14
|
+
` image: ${image}`,
|
|
15
|
+
...tagLines,
|
|
16
|
+
' script:',
|
|
17
|
+
' - echo "No product is affected by this change."'
|
|
18
|
+
].join('\n') + '\n';
|
|
19
|
+
}
|
|
20
|
+
const lines = ['stages: [products]', ''];
|
|
21
|
+
for (const name of products) {
|
|
22
|
+
lines.push(`product:${name.replace(JOB_NAME_UNSAFE, '_')}:`, ' stage: products', ` image: ${image}`, ...tagLines, ' interruptible: true', ' needs:', ' - pipeline: $PARENT_PIPELINE_ID', ` job: ${parentJob}`, ' script:', ` - ${tooling}`, ` - linea-ci derive --line . --spec ${specsDir}/${name}.json --out "$CI_PROJECT_DIR/derived/${name}"`, ` - linea-ci check-leftovers "$CI_PROJECT_DIR/derived/${name}" --line .`, ` - linea-ci check-determinism --line . --spec ${specsDir}/${name}.json`, ...(repositories[name] === undefined ? [] : [` - linea-ci check-drift --line . --spec ${specsDir}/${name}.json --repository ${JSON.stringify(repositories[name])}`]), ` - cd "derived/${name}" && for t in ci/test-server.sh ci/test-client.sh; do if [ -f "$t" ]; then sh "$t" || exit 1; fi; done`, ' artifacts:', ' when: always', ' expire_in: 1 week', ' paths:', ` - derived/${name}/`, '');
|
|
23
|
+
}
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/ci/pipeline.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,QAAQ,EACR,QAAQ,EACR,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,4KAA4K,EACtL,SAAS,GAAG,QAAQ,EACpB,YAAY,GAAG,EAAE,EACjB,IAAI,GAAG,EAAE,EAaV,EAAU,EAAE;IACX,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,oBAAoB;YACpB,uBAAuB;YACvB,mBAAmB;YACnB,YAAY,KAAK,EAAE;YACnB,GAAG,QAAQ;YACX,WAAW;YACX,qDAAqD;SACtD,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACrB,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CACR,WAAW,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,GAAG,EAChD,mBAAmB,EACnB,YAAY,KAAK,EAAE,EACnB,GAAG,QAAQ,EACX,uBAAuB,EACvB,UAAU,EACV,qCAAqC,EACrC,cAAc,SAAS,EAAE,EACzB,WAAW,EACX,SAAS,OAAO,EAAE,EAClB,yCAAyC,QAAQ,IAAI,IAAI,wCAAwC,IAAI,GAAG,EACxG,2DAA2D,IAAI,YAAY,EAC3E,oDAAoD,QAAQ,IAAI,IAAI,OAAO,EAC3E,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,8CAA8C,QAAQ,IAAI,IAAI,sBAAsB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EACvK,qBAAqB,IAAI,wGAAwG,EACjI,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,IAAI,GAAG,EAC1B,EAAE,CACH,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["const JOB_NAME_UNSAFE = /[^A-Za-z0-9_.-]/g\n\n/**\n * The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations\n * left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes\n * `linea-ci` available in the job.\n */\nexport const renderChildPipeline = ({\n products,\n specsDir,\n image = 'node:22',\n tooling = `git config --global url.\"https://gitlab-ci-token:\\${CI_JOB_TOKEN}@\\${CI_SERVER_HOST}/\".insteadOf \"https://\\${CI_SERVER_HOST}/\" && npm install --global \"$LINEA_CI_PACKAGE\"`,\n parentJob = 'select',\n repositories = {},\n tags = []\n}: {\n products: readonly string[]\n /** Where the specs of the products are, relative to the root of the SPL repository (`fetch-specs` writes them there). */\n specsDir: string\n image?: string\n tooling?: string\n /** The job of the parent pipeline whose artifacts hold the specs and the SPL checkout. */\n parentJob?: string\n /** Product name -> where its repository is: those listed also get `check-drift` (what is committed is what the line generates). */\n repositories?: Readonly<Record<string, string>>\n /** The runner tags the jobs ask for (a runner that takes no untagged jobs runs nothing otherwise). */\n tags?: readonly string[]\n}): string => {\n const tagLines = tags.length === 0 ? [] : [` tags: ${JSON.stringify(tags)}`]\n if (products.length === 0) {\n return [\n 'stages: [products]',\n 'no-products-affected:',\n ' stage: products',\n ` image: ${image}`,\n ...tagLines,\n ' script:',\n ' - echo \"No product is affected by this change.\"'\n ].join('\\n') + '\\n'\n }\n const lines = ['stages: [products]', '']\n for (const name of products) {\n lines.push(\n `product:${name.replace(JOB_NAME_UNSAFE, '_')}:`,\n ' stage: products',\n ` image: ${image}`,\n ...tagLines,\n ' interruptible: true',\n ' needs:',\n ' - pipeline: $PARENT_PIPELINE_ID',\n ` job: ${parentJob}`,\n ' script:',\n ` - ${tooling}`,\n ` - linea-ci derive --line . --spec ${specsDir}/${name}.json --out \"$CI_PROJECT_DIR/derived/${name}\"`,\n ` - linea-ci check-leftovers \"$CI_PROJECT_DIR/derived/${name}\" --line .`,\n ` - linea-ci check-determinism --line . --spec ${specsDir}/${name}.json`,\n ...(repositories[name] === undefined ? [] : [` - linea-ci check-drift --line . --spec ${specsDir}/${name}.json --repository ${JSON.stringify(repositories[name])}`]),\n ` - cd \"derived/${name}\" && for t in ci/test-server.sh ci/test-client.sh; do if [ -f \"$t\" ]; then sh \"$t\" || exit 1; fi; done`,\n ' artifacts:',\n ' when: always',\n ' expire_in: 1 week',\n ' paths:',\n ` - derived/${name}/`,\n ''\n )\n }\n return lines.join('\\n')\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SelectableProduct {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly features: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface ProductSelectionResult {
|
|
6
|
+
/** The names of the products to rebuild, the ones that share more of the touched features first. */
|
|
7
|
+
readonly selected: string[];
|
|
8
|
+
/** The features the change touches; empty when `all` is `true`. */
|
|
9
|
+
readonly touchedFeatures: string[];
|
|
10
|
+
/** Everything is selected: the change reaches every product (the platform files, code with no feature in it, a deleted file...). */
|
|
11
|
+
readonly all: boolean;
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of
|
|
16
|
+
* them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the
|
|
17
|
+
* analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so
|
|
18
|
+
* `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.
|
|
19
|
+
*/
|
|
20
|
+
export declare const selectProducts: ({ changedFiles, featuresByFile, products, max, baseline }: {
|
|
21
|
+
/** Paths from the root of the SPL repository. */
|
|
22
|
+
changedFiles: readonly string[];
|
|
23
|
+
/** `analyzeAnnotations`, of the head of the change. */
|
|
24
|
+
featuresByFile: Record<string, Record<string, number>>;
|
|
25
|
+
products: readonly SelectableProduct[];
|
|
26
|
+
max?: number;
|
|
27
|
+
baseline?: number;
|
|
28
|
+
}) => ProductSelectionResult;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PLATFORM_PATHS } from '../constants.js';
|
|
2
|
+
const normalize = (file) => file.split('\\').join('/').replace(/^\.\//, '');
|
|
3
|
+
/**
|
|
4
|
+
* Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of
|
|
5
|
+
* them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the
|
|
6
|
+
* analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so
|
|
7
|
+
* `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.
|
|
8
|
+
*/
|
|
9
|
+
export const selectProducts = ({ changedFiles, featuresByFile, products, max = Infinity, baseline = 1 }) => {
|
|
10
|
+
const codePrefix = `${PLATFORM_PATHS.code.replace(/\/$/, '')}/`;
|
|
11
|
+
const everything = (reason) => ({ selected: products.slice(0, max).map(({ name }) => name), touchedFeatures: [], all: true, reason });
|
|
12
|
+
const touched = new Set();
|
|
13
|
+
for (const raw of changedFiles) {
|
|
14
|
+
const file = normalize(raw);
|
|
15
|
+
if (!file.startsWith(codePrefix)) {
|
|
16
|
+
if (file === 'README.md' || file.startsWith('docs/') || file.startsWith('.gitlab-ci') || file.startsWith('ci/'))
|
|
17
|
+
continue;
|
|
18
|
+
return everything(`"${file}" is part of the platform of the SPL`);
|
|
19
|
+
}
|
|
20
|
+
const features = featuresByFile[file.slice(codePrefix.length)];
|
|
21
|
+
if (features === undefined)
|
|
22
|
+
return everything(`"${file}" is not in the annotation analysis (deleted or ignored)`);
|
|
23
|
+
const names = Object.keys(features);
|
|
24
|
+
if (names.length === 0)
|
|
25
|
+
return everything(`"${file}" has no feature in its annotations: every product has it`);
|
|
26
|
+
names.forEach((name) => touched.add(name));
|
|
27
|
+
}
|
|
28
|
+
if (touched.size === 0)
|
|
29
|
+
return { selected: [], touchedFeatures: [], all: false, reason: 'no file of the SPL changed that products depend on' };
|
|
30
|
+
const overlap = (product) => product.features.filter((name) => touched.has(name)).length;
|
|
31
|
+
const hit = products.filter((product) => overlap(product) > 0).sort((a, b) => overlap(b) - overlap(a) || a.name.localeCompare(b.name));
|
|
32
|
+
const selected = [...hit];
|
|
33
|
+
const rest = products.filter((product) => !hit.includes(product)).sort((a, b) => a.features.length - b.features.length || a.name.localeCompare(b.name));
|
|
34
|
+
while (selected.length < baseline && rest.length > 0)
|
|
35
|
+
selected.push(rest.shift());
|
|
36
|
+
return {
|
|
37
|
+
selected: selected.slice(0, max).map(({ name }) => name),
|
|
38
|
+
touchedFeatures: [...touched].sort(),
|
|
39
|
+
all: false,
|
|
40
|
+
reason: `touches ${[...touched].sort().join(', ')}`
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AAC,CAAA;IACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IACvJ,OAAO,QAAQ,CAAC,MAAM,GAAG,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAG,CAAC,CAAA;IAElF,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QACxD,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE;QACpC,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KACpD,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { PLATFORM_PATHS } from '../constants.js'\n\nexport interface SelectableProduct {\n readonly name: string\n readonly features: readonly string[]\n}\n\nexport interface ProductSelectionResult {\n /** The names of the products to rebuild, the ones that share more of the touched features first. */\n readonly selected: string[]\n /** The features the change touches; empty when `all` is `true`. */\n readonly touchedFeatures: string[]\n /** Everything is selected: the change reaches every product (the platform files, code with no feature in it, a deleted file...). */\n readonly all: boolean\n readonly reason: string\n}\n\nconst normalize = (file: string): string => file.split('\\\\').join('/').replace(/^\\.\\//, '')\n\n/**\n * Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of\n * them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the\n * analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so\n * `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.\n */\nexport const selectProducts = ({\n changedFiles,\n featuresByFile,\n products,\n max = Infinity,\n baseline = 1\n}: {\n /** Paths from the root of the SPL repository. */\n changedFiles: readonly string[]\n /** `analyzeAnnotations`, of the head of the change. */\n featuresByFile: Record<string, Record<string, number>>\n products: readonly SelectableProduct[]\n max?: number\n baseline?: number\n}): ProductSelectionResult => {\n const codePrefix = `${PLATFORM_PATHS.code.replace(/\\/$/, '')}/`\n const everything = (reason: string): ProductSelectionResult =>\n ({ selected: products.slice(0, max).map(({ name }) => name), touchedFeatures: [], all: true, reason })\n\n const touched = new Set<string>()\n for (const raw of changedFiles) {\n const file = normalize(raw)\n if (!file.startsWith(codePrefix)) {\n if (file === 'README.md' || file.startsWith('docs/') || file.startsWith('.gitlab-ci') || file.startsWith('ci/')) continue\n return everything(`\"${file}\" is part of the platform of the SPL`)\n }\n const features = featuresByFile[file.slice(codePrefix.length)]\n if (features === undefined) return everything(`\"${file}\" is not in the annotation analysis (deleted or ignored)`)\n const names = Object.keys(features)\n if (names.length === 0) return everything(`\"${file}\" has no feature in its annotations: every product has it`)\n names.forEach((name) => touched.add(name))\n }\n\n if (touched.size === 0) return { selected: [], touchedFeatures: [], all: false, reason: 'no file of the SPL changed that products depend on' }\n\n const overlap = (product: SelectableProduct): number => product.features.filter((name) => touched.has(name)).length\n const hit = products.filter((product) => overlap(product) > 0).sort((a, b) => overlap(b) - overlap(a) || a.name.localeCompare(b.name))\n const selected = [...hit]\n const rest = products.filter((product) => !hit.includes(product)).sort((a, b) => a.features.length - b.features.length || a.name.localeCompare(b.name))\n while (selected.length < baseline && rest.length > 0) selected.push(rest.shift()!)\n\n return {\n selected: selected.slice(0, max).map(({ name }) => name),\n touchedFeatures: [...touched].sort(),\n all: false,\n reason: `touches ${[...touched].sort().join(', ')}`\n }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../feature-model/uvl.js';
|
|
2
|
+
export interface SelectionProblem {
|
|
3
|
+
readonly feature?: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ProductSelection {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly features: readonly string[] | Readonly<Record<string, boolean>>;
|
|
9
|
+
}
|
|
10
|
+
export interface ProductSelectionReport {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly problems: SelectionProblem[];
|
|
13
|
+
}
|
|
14
|
+
/** The features a selection comes to once what the model implies is added: the root, the ancestors, what is mandatory, what the constraints need. */
|
|
15
|
+
export declare const completeSelection: ({ tree, features }: {
|
|
16
|
+
tree: FeatureModelTree;
|
|
17
|
+
features: ProductSelection["features"];
|
|
18
|
+
}) => Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a feature selection is a valid configuration of a feature model: every feature exists and, once what the model implies is added
|
|
21
|
+
* (`completeSelection`), the groups are respected and every cross-tree constraint holds. The rules flamapy applies, checked directly over
|
|
22
|
+
* the tree, so a pipeline can validate every real product in milliseconds and with no Python runtime.
|
|
23
|
+
*/
|
|
24
|
+
export declare const validateSelection: ({ tree, features }: {
|
|
25
|
+
tree: FeatureModelTree;
|
|
26
|
+
features: ProductSelection["features"];
|
|
27
|
+
}) => SelectionProblem[];
|
|
28
|
+
/** `validateSelection` over every product of an SPL, against the UVL of its feature model. */
|
|
29
|
+
export declare const validateProductSelections: ({ featureModel, products }: {
|
|
30
|
+
featureModel: string;
|
|
31
|
+
products: readonly ProductSelection[];
|
|
32
|
+
}) => ProductSelectionReport[];
|
|
33
|
+
/**
|
|
34
|
+
* The selection of a product without one of its features (and what hangs from it), for measuring what that feature is worth: the code that
|
|
35
|
+
* disappears is the code the feature brings. `undefined` when the model does not allow it (the feature is mandatory, or something that stays
|
|
36
|
+
* needs it), because that product cannot be derived.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ablateFeature: ({ tree, features, feature }: {
|
|
39
|
+
tree: FeatureModelTree;
|
|
40
|
+
features: ProductSelection["features"];
|
|
41
|
+
feature: string;
|
|
42
|
+
}) => string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A valid selection that has a feature, made of the least that has to come with it: what the model implies, and the first feature of every
|
|
45
|
+
* group that asks for a choice. Used to measure what a feature brings when no real product has it. `undefined` when no selection with it
|
|
46
|
+
* is valid (the constraints forbid it).
|
|
47
|
+
*/
|
|
48
|
+
export declare const activateFeature: ({ tree, features, feature }: {
|
|
49
|
+
tree: FeatureModelTree;
|
|
50
|
+
features: ProductSelection["features"];
|
|
51
|
+
feature: string;
|
|
52
|
+
}) => string[] | undefined;
|