@test-station/core 0.2.16 → 0.2.17
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/package.json +7 -7
- package/src/github-actions-env.js +41 -0
- package/src/report.js +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@test-station/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
".": "./src/index.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@test-station/adapter-jest": "0.2.
|
|
13
|
-
"@test-station/adapter-node-test": "0.2.
|
|
14
|
-
"@test-station/adapter-playwright": "0.2.
|
|
15
|
-
"@test-station/adapter-shell": "0.2.
|
|
16
|
-
"@test-station/adapter-vitest": "0.2.
|
|
17
|
-
"@test-station/plugin-source-analysis": "0.2.
|
|
12
|
+
"@test-station/adapter-jest": "0.2.17",
|
|
13
|
+
"@test-station/adapter-node-test": "0.2.17",
|
|
14
|
+
"@test-station/adapter-playwright": "0.2.17",
|
|
15
|
+
"@test-station/adapter-shell": "0.2.17",
|
|
16
|
+
"@test-station/adapter-vitest": "0.2.17",
|
|
17
|
+
"@test-station/plugin-source-analysis": "0.2.17"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "node ../../scripts/check-package.mjs ./src/index.js",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const SECRETISH_ENV_NAME = /(TOKEN|SECRET|PASSWORD|PRIVATE|ACCESS_KEY|SESSION_KEY|AUTHORIZATION|CREDENTIAL)/i;
|
|
2
|
+
|
|
3
|
+
export function captureGitHubDefaultEnvironment(env = process.env) {
|
|
4
|
+
if (!env || typeof env !== 'object') {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const entries = Object.entries(env)
|
|
9
|
+
.filter(([name]) => isGitHubDefaultEnvironmentName(name) && !isSecretLikeEnvironmentName(name))
|
|
10
|
+
.map(([name, value]) => [name, normalizeEnvironmentValue(value)])
|
|
11
|
+
.filter(([, value]) => value !== null)
|
|
12
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
13
|
+
|
|
14
|
+
return Object.fromEntries(entries);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isGitHubDefaultEnvironmentName(name) {
|
|
18
|
+
return name === 'CI'
|
|
19
|
+
|| name.startsWith('GITHUB_')
|
|
20
|
+
|| name.startsWith('RUNNER_');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isSecretLikeEnvironmentName(name) {
|
|
24
|
+
return SECRETISH_ENV_NAME.test(name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeEnvironmentValue(value) {
|
|
28
|
+
if (value == null) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
37
|
+
return String(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
package/src/report.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { mergeCoverageSummaries, normalizeCoverageSummary } from './coverage.js';
|
|
3
|
+
import { captureGitHubDefaultEnvironment } from './github-actions-env.js';
|
|
3
4
|
import { collectCoverageAttribution, lookupOwner, evaluateCoverageThresholds } from './policy.js';
|
|
4
5
|
|
|
5
6
|
export function createSummary(values = {}) {
|
|
@@ -91,6 +92,7 @@ export function normalizeSuiteResult(rawResult, suite, packageName) {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export function buildReportFromSuiteResults(context, suiteResults, durationMs) {
|
|
95
|
+
const ciMetadata = buildCiMetadata();
|
|
94
96
|
const packageMap = new Map();
|
|
95
97
|
const packageCatalog = Array.isArray(context?.packageCatalog) ? context.packageCatalog : [];
|
|
96
98
|
|
|
@@ -197,6 +199,7 @@ export function buildReportFromSuiteResults(context, suiteResults, durationMs) {
|
|
|
197
199
|
projectName: context.project.name,
|
|
198
200
|
projectRootDir: context.project.rootDir,
|
|
199
201
|
outputDir: context.project.outputDir,
|
|
202
|
+
...(ciMetadata ? { ci: ciMetadata } : {}),
|
|
200
203
|
render: {
|
|
201
204
|
defaultView: context.config?.render?.defaultView || 'module',
|
|
202
205
|
includeDetailedAnalysisToggle: context.config?.render?.includeDetailedAnalysisToggle !== false,
|
|
@@ -205,6 +208,18 @@ export function buildReportFromSuiteResults(context, suiteResults, durationMs) {
|
|
|
205
208
|
};
|
|
206
209
|
}
|
|
207
210
|
|
|
211
|
+
function buildCiMetadata(env = process.env) {
|
|
212
|
+
const environment = captureGitHubDefaultEnvironment(env);
|
|
213
|
+
if (Object.keys(environment).length === 0) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
provider: 'github-actions',
|
|
219
|
+
environment,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
208
223
|
function buildModulesFromPackages(packages, coverageFiles, policy) {
|
|
209
224
|
const moduleMap = new Map();
|
|
210
225
|
|