@iobroker/repochecker 5.11.1 → 5.12.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 +124 -5
- package/index.js +4 -0
- package/lib/M0000_PackageJson.js +83 -2
- package/lib/M1000_IOPackageJson.js +39 -0
- package/lib/M3000_Testing.js +518 -13
- package/lib/M5000_Code.js +76 -4
- package/lib/M6000_Readme.js +19 -0
- package/lib/M8900__Dependabot.js +166 -0
- package/lib/config.js +23 -0
- package/lib/postprocessing.js +6 -3
- package/package.json +4 -4
package/lib/M3000_Testing.js
CHANGED
|
@@ -7,18 +7,109 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
const axios = require('axios');
|
|
11
|
+
const compareVersions = require('compare-versions');
|
|
10
12
|
const yaml = require('js-yaml');
|
|
11
13
|
const common = require('./common.js');
|
|
14
|
+
const config = require('./config.js');
|
|
12
15
|
|
|
13
16
|
const WORKFLOW_FILE = '/.github/workflows/test-and-release.yml';
|
|
14
17
|
const WORKFLOW_FILE_SHORT = 'test-and-release.yml';
|
|
15
18
|
|
|
19
|
+
function normalizeVersion(version) {
|
|
20
|
+
return typeof version === 'string' ? version.trim().replace(/^v/, '') : '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getVersionTagCandidates(version) {
|
|
24
|
+
const normalizedVersion = normalizeVersion(version);
|
|
25
|
+
if (!normalizedVersion) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
return [`v${normalizedVersion}`, normalizedVersion];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function findTagNameForVersion(tags, version) {
|
|
32
|
+
if (!Array.isArray(tags)) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
const candidates = getVersionTagCandidates(version);
|
|
36
|
+
const foundTag = tags.find(tag => tag && typeof tag.name === 'string' && candidates.includes(tag.name));
|
|
37
|
+
return foundTag ? foundTag.name : '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function formatRunLink(run) {
|
|
41
|
+
return `[run #${run.run_number}](${run.html_url})`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getNewestNpmVersion(npmPackageData) {
|
|
45
|
+
const versions = npmPackageData && npmPackageData.versions ? Object.keys(npmPackageData.versions) : [];
|
|
46
|
+
if (versions.length === 0) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
let newestVersion = '';
|
|
50
|
+
for (const version of versions) {
|
|
51
|
+
if (!newestVersion || compareVersions.compare(version, newestVersion, '>')) {
|
|
52
|
+
newestVersion = version;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return newestVersion;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findTagTriggeredRun(workflowRuns, version, taggedVersion) {
|
|
59
|
+
if (!Array.isArray(workflowRuns)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const branchCandidates = new Set([taggedVersion, ...getVersionTagCandidates(version)]);
|
|
63
|
+
return (
|
|
64
|
+
workflowRuns.find(
|
|
65
|
+
run => run.event === 'push' && run.head_branch && branchCandidates.has(run.head_branch) && run.html_url,
|
|
66
|
+
) || null
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function checkTagTriggeredRun(
|
|
71
|
+
context,
|
|
72
|
+
workflowRuns,
|
|
73
|
+
version,
|
|
74
|
+
taggedVersion,
|
|
75
|
+
errorCodeBase,
|
|
76
|
+
warningCodeBase,
|
|
77
|
+
sourceLabel,
|
|
78
|
+
) {
|
|
79
|
+
const tagRun = findTagTriggeredRun(workflowRuns, version, taggedVersion);
|
|
80
|
+
const workflowUrl = `${context.githubUrlOriginal}/actions/workflows/${WORKFLOW_FILE_SHORT}`;
|
|
81
|
+
if (!tagRun) {
|
|
82
|
+
context.warnings.push(
|
|
83
|
+
`[${warningCodeBase}] No workflow run for "${WORKFLOW_FILE_SHORT}" triggered by tag "${taggedVersion}" was found for ${sourceLabel}. ` +
|
|
84
|
+
`Please check workflow runs at [${workflowUrl}](${workflowUrl}).`,
|
|
85
|
+
);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (tagRun.conclusion === 'cancelled') {
|
|
90
|
+
context.warnings.push(
|
|
91
|
+
`[${warningCodeBase}] Workflow "${WORKFLOW_FILE_SHORT}" run triggered by tag "${taggedVersion}" for ${sourceLabel} was cancelled ${formatRunLink(tagRun)}.`,
|
|
92
|
+
);
|
|
93
|
+
} else if (tagRun.conclusion === 'failure') {
|
|
94
|
+
context.errors.push(
|
|
95
|
+
`[${errorCodeBase}] Workflow "${WORKFLOW_FILE_SHORT}" run triggered by tag "${taggedVersion}" for ${sourceLabel} failed ${formatRunLink(tagRun)}.`,
|
|
96
|
+
);
|
|
97
|
+
} else {
|
|
98
|
+
context.checks.push(
|
|
99
|
+
`Workflow "${WORKFLOW_FILE_SHORT}" run triggered by tag "${taggedVersion}" for ${sourceLabel} finished with conclusion "${tagRun.conclusion}" ${formatRunLink(tagRun)}.`,
|
|
100
|
+
);
|
|
101
|
+
common.info(
|
|
102
|
+
`Workflow "${WORKFLOW_FILE_SHORT}" run triggered by tag "${taggedVersion}" for ${sourceLabel} finished with conclusion "${tagRun.conclusion}" ${formatRunLink(tagRun)}.`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
16
107
|
/**
|
|
17
108
|
* Returns true if the given file path exists in the context's filesList,
|
|
18
109
|
* handling both the leading-slash (remote) and no-leading-slash (local) formats.
|
|
19
110
|
*
|
|
20
111
|
* @param {object} context - The checker context
|
|
21
|
-
* @param {string} filePath - File path with leading slash (e.g. '/.github/workflows/test-and-
|
|
112
|
+
* @param {string} filePath - File path with leading slash (e.g. '/.github/workflows/test-and-releachecse.yml')
|
|
22
113
|
* @returns {boolean} true if file is found in filesList
|
|
23
114
|
*/
|
|
24
115
|
function fileExistsInList(context, filePath) {
|
|
@@ -43,6 +134,39 @@ function jobHasStepWithAction(job, actionPrefix) {
|
|
|
43
134
|
return job.steps.some(step => typeof step.uses === 'string' && step.uses.startsWith(actionPrefix));
|
|
44
135
|
}
|
|
45
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Returns all action refs (part after "@", e.g. v1/main/sha) used by a job for the given action prefix.
|
|
139
|
+
*
|
|
140
|
+
* @param {object} job - A GitHub Actions job object
|
|
141
|
+
* @param {string} actionPrefix - The action name prefix to look for (e.g. 'ioBroker/testing-action-check@')
|
|
142
|
+
* @returns {string[]} Array of refs used for the action in this job
|
|
143
|
+
*/
|
|
144
|
+
function getJobActionRefs(job, actionPrefix) {
|
|
145
|
+
if (!job || !Array.isArray(job.steps)) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
return job.steps
|
|
149
|
+
.map(step => (typeof step.uses === 'string' ? step.uses : ''))
|
|
150
|
+
.filter(uses => uses.startsWith(actionPrefix))
|
|
151
|
+
.map(uses => uses.slice(actionPrefix.length).trim())
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Parses the major version from an action ref string.
|
|
157
|
+
* Supports values like "v1", "1", "v2.3.4". Returns null for non-numeric refs like branch names.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} ref - Action ref string
|
|
160
|
+
* @returns {number|null} Major version or null if not parseable
|
|
161
|
+
*/
|
|
162
|
+
function parseActionMajorVersion(ref) {
|
|
163
|
+
if (typeof ref !== 'string') {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const match = ref.trim().match(/^v?(\d+)/);
|
|
167
|
+
return match ? parseInt(match[1], 10) : null;
|
|
168
|
+
}
|
|
169
|
+
|
|
46
170
|
/**
|
|
47
171
|
* Returns true if the given job declares that it needs all of the specified jobs.
|
|
48
172
|
*
|
|
@@ -100,6 +224,86 @@ function jobDependsOn(jobs, startJobName, requiredJobName) {
|
|
|
100
224
|
return false;
|
|
101
225
|
}
|
|
102
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Parses the major version number from a node.js version string.
|
|
229
|
+
* Handles formats like '20', '20.x', '20.1.2', 'lts/*' (returns null for lts).
|
|
230
|
+
*
|
|
231
|
+
* @param {string|number} versionStr - The version string to parse
|
|
232
|
+
* @returns {number|null} The major version number, or null if not parseable
|
|
233
|
+
*/
|
|
234
|
+
function parseNodeMajor(versionStr) {
|
|
235
|
+
if (versionStr === undefined || versionStr === null) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const match = String(versionStr).match(/^(\d+)/);
|
|
239
|
+
return match ? parseInt(match[1], 10) : null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Returns the node.js major version number used in a non-matrix job,
|
|
244
|
+
* by scanning all steps for a 'node-version' in their 'with' parameters.
|
|
245
|
+
*
|
|
246
|
+
* @param {object} job - A GitHub Actions job object
|
|
247
|
+
* @returns {number|null} The major node.js version, or null if not found
|
|
248
|
+
*/
|
|
249
|
+
function getJobNodeMajorVersion(job) {
|
|
250
|
+
if (!job || !Array.isArray(job.steps)) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
for (const step of job.steps) {
|
|
254
|
+
if (typeof step.uses === 'string' && step.with) {
|
|
255
|
+
const nodeVersion = step.with['node-version'];
|
|
256
|
+
if (nodeVersion !== undefined && nodeVersion !== null) {
|
|
257
|
+
const major = parseNodeMajor(nodeVersion);
|
|
258
|
+
if (major !== null) {
|
|
259
|
+
return major;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Returns an array of major node.js version numbers from a job's strategy matrix
|
|
269
|
+
* (matrix.node-version or matrix.node).
|
|
270
|
+
*
|
|
271
|
+
* @param {object} job - A GitHub Actions job object
|
|
272
|
+
* @returns {number[]} Array of major version numbers found in the matrix
|
|
273
|
+
*/
|
|
274
|
+
function getMatrixNodeMajorVersions(job) {
|
|
275
|
+
if (!job || !job.strategy || !job.strategy.matrix) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
const matrix = job.strategy.matrix;
|
|
279
|
+
const nodeVersions = matrix['node-version'] || matrix.node;
|
|
280
|
+
if (!Array.isArray(nodeVersions)) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
return nodeVersions.map(v => parseNodeMajor(v)).filter(v => v !== null);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Returns an array of OS strings from a job's strategy matrix (matrix.os or matrix['runs-on']).
|
|
288
|
+
*
|
|
289
|
+
* @param {object} job - A GitHub Actions job object
|
|
290
|
+
* @returns {string[]} Array of OS strings found in the matrix
|
|
291
|
+
*/
|
|
292
|
+
function getMatrixOs(job) {
|
|
293
|
+
if (!job || !job.strategy || !job.strategy.matrix) {
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
const matrix = job.strategy.matrix;
|
|
297
|
+
const os = matrix.os || matrix['runs-on'];
|
|
298
|
+
if (!os) {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
if (!Array.isArray(os)) {
|
|
302
|
+
return typeof os === 'string' ? [os] : [];
|
|
303
|
+
}
|
|
304
|
+
return os;
|
|
305
|
+
}
|
|
306
|
+
|
|
103
307
|
async function checkTests(context) {
|
|
104
308
|
console.log('\n[E3000 - E3999] checking tests');
|
|
105
309
|
|
|
@@ -250,11 +454,156 @@ async function checkTests(context) {
|
|
|
250
454
|
context.checks.push('Workflow concurrency configuration is correct.');
|
|
251
455
|
}
|
|
252
456
|
|
|
457
|
+
// --- W3028 / E3028 / W3029 / W3030 / E3030 / E3031 / W3032 / E3032 / E3033 / W3034 / E3034 ---
|
|
458
|
+
try {
|
|
459
|
+
const workflowRunsResponse = await axios(
|
|
460
|
+
`${context.githubUrlApi}/actions/workflows/${WORKFLOW_FILE_SHORT}/runs?per_page=100`,
|
|
461
|
+
);
|
|
462
|
+
const workflowRuns = workflowRunsResponse.data && workflowRunsResponse.data.workflow_runs;
|
|
463
|
+
if (!Array.isArray(workflowRuns) || workflowRuns.length === 0) {
|
|
464
|
+
const workflowUrl = `${context.githubUrlOriginal}/actions/workflows/${WORKFLOW_FILE_SHORT}`;
|
|
465
|
+
context.warnings.push(
|
|
466
|
+
`[W3028] No workflow runs found for "${WORKFLOW_FILE_SHORT}". Please check [${workflowUrl}](${workflowUrl}).`,
|
|
467
|
+
);
|
|
468
|
+
} else {
|
|
469
|
+
const lastRun = workflowRuns[0];
|
|
470
|
+
if (lastRun.conclusion === 'cancelled') {
|
|
471
|
+
context.warnings.push(
|
|
472
|
+
`[W3028] Latest workflow run of "${WORKFLOW_FILE_SHORT}" was cancelled ${formatRunLink(lastRun)}.`,
|
|
473
|
+
);
|
|
474
|
+
} else if (lastRun.conclusion === 'failure') {
|
|
475
|
+
context.errors.push(
|
|
476
|
+
`[E3028] Latest workflow run of "${WORKFLOW_FILE_SHORT}" failed ${formatRunLink(lastRun)}.`,
|
|
477
|
+
);
|
|
478
|
+
} else {
|
|
479
|
+
context.checks.push(
|
|
480
|
+
`Latest workflow run of "${WORKFLOW_FILE_SHORT}" finished with conclusion "${lastRun.conclusion}" ${formatRunLink(lastRun)}.`,
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const tagsResponse = await axios(`${context.githubUrlApi}/tags?per_page=100`);
|
|
485
|
+
const tags = Array.isArray(tagsResponse.data) ? tagsResponse.data : [];
|
|
486
|
+
|
|
487
|
+
const currentRelease =
|
|
488
|
+
(context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.version) ||
|
|
489
|
+
(context.packageJson && context.packageJson.version) ||
|
|
490
|
+
'';
|
|
491
|
+
|
|
492
|
+
if (currentRelease) {
|
|
493
|
+
const currentReleaseTag = findTagNameForVersion(tags, currentRelease);
|
|
494
|
+
if (!currentReleaseTag) {
|
|
495
|
+
context.warnings.push(
|
|
496
|
+
`[W3029] Release ${currentRelease} from io-package.json/package.json has not yet been tagged. Tagging releases is required.`,
|
|
497
|
+
);
|
|
498
|
+
} else {
|
|
499
|
+
checkTagTriggeredRun(
|
|
500
|
+
context,
|
|
501
|
+
workflowRuns,
|
|
502
|
+
currentRelease,
|
|
503
|
+
currentReleaseTag,
|
|
504
|
+
'E3030',
|
|
505
|
+
'W3030',
|
|
506
|
+
`current release ${currentRelease}`,
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
try {
|
|
512
|
+
const adapterName = typeof context.adapterName === 'string' ? context.adapterName : '';
|
|
513
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(adapterName)) {
|
|
514
|
+
context.warnings.push(
|
|
515
|
+
`[W3035] Could not validate npm release information because adapter name "${adapterName}" is not in a valid npm package name format.`,
|
|
516
|
+
);
|
|
517
|
+
} else {
|
|
518
|
+
const npmPackageName = `iobroker.${adapterName}`;
|
|
519
|
+
const npmResponse = await axios(`https://registry.npmjs.org/${npmPackageName}`);
|
|
520
|
+
const npmPackageData = npmResponse.data || {};
|
|
521
|
+
const npmLatestRelease = npmPackageData['dist-tags'] && npmPackageData['dist-tags'].latest;
|
|
522
|
+
// if (npmLatestRelease) {
|
|
523
|
+
if (npmLatestRelease && npmLatestRelease !== currentRelease) {
|
|
524
|
+
const npmLatestTag = findTagNameForVersion(tags, npmLatestRelease);
|
|
525
|
+
if (!npmLatestTag) {
|
|
526
|
+
context.errors.push(
|
|
527
|
+
`[E3031] Release ${npmLatestRelease} tagged as "latest" at npm has not yet been tagged at GitHub. Tagging of releases is required.`,
|
|
528
|
+
);
|
|
529
|
+
} else {
|
|
530
|
+
checkTagTriggeredRun(
|
|
531
|
+
context,
|
|
532
|
+
workflowRuns,
|
|
533
|
+
npmLatestRelease,
|
|
534
|
+
npmLatestTag,
|
|
535
|
+
'E3032',
|
|
536
|
+
'W3032',
|
|
537
|
+
`npm latest release ${npmLatestRelease}`,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const newestNpmRelease = getNewestNpmVersion(npmPackageData);
|
|
543
|
+
if (newestNpmRelease && newestNpmRelease !== npmLatestRelease) {
|
|
544
|
+
const newestNpmTag = findTagNameForVersion(tags, newestNpmRelease);
|
|
545
|
+
if (!newestNpmTag) {
|
|
546
|
+
context.errors.push(
|
|
547
|
+
`[E3033] Newest npm release ${newestNpmRelease} has not yet been tagged at GitHub. Tagging of releases is required.`,
|
|
548
|
+
);
|
|
549
|
+
} else {
|
|
550
|
+
checkTagTriggeredRun(
|
|
551
|
+
context,
|
|
552
|
+
workflowRuns,
|
|
553
|
+
newestNpmRelease,
|
|
554
|
+
newestNpmTag,
|
|
555
|
+
'E3034',
|
|
556
|
+
'W3034',
|
|
557
|
+
`newest npm release ${newestNpmRelease}`,
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
} catch (e) {
|
|
563
|
+
context.warnings.push(
|
|
564
|
+
`[W3031] Could not retrieve npm release information for testing checks: ${e.message}`,
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
} catch (e) {
|
|
569
|
+
context.warnings.push(
|
|
570
|
+
`[W3028] Could not retrieve workflow run data for "${WORKFLOW_FILE_SHORT}": ${e.message}`,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
|
|
253
574
|
// skip detailled tests if adapter uses legacy testing
|
|
254
575
|
if (!hasLegacyTesting) {
|
|
255
576
|
// --- Check jobs ---
|
|
256
577
|
const jobs = workflow.jobs || {};
|
|
257
578
|
|
|
579
|
+
// Compute effective minimum and recommended node.js versions per non-matrix job.
|
|
580
|
+
// If the engines:node clause in package.json is higher than the config defaults, use that value.
|
|
581
|
+
const testingCfg = config.testingNodeJs;
|
|
582
|
+
let effectiveMinCheckAndLint = parseInt(testingCfg.minimumNodeVersionCheckAndLint, 10);
|
|
583
|
+
let effectiveRecCheckAndLint = parseInt(testingCfg.recommendedNodeVersionCheckAndLint, 10);
|
|
584
|
+
let effectiveMinDeploy = parseInt(testingCfg.minimumNodeVersionDeploy, 10);
|
|
585
|
+
let effectiveRecDeploy = parseInt(testingCfg.recommendedNodeVersionDeploy, 10);
|
|
586
|
+
const enginesNode = context.packageJson && context.packageJson.engines && context.packageJson.engines.node;
|
|
587
|
+
let enginesMajor = 0;
|
|
588
|
+
if (enginesNode) {
|
|
589
|
+
const enginesMatch = String(enginesNode).match(/(\d+)/);
|
|
590
|
+
if (enginesMatch) {
|
|
591
|
+
enginesMajor = parseInt(enginesMatch[1], 10);
|
|
592
|
+
if (enginesMajor > effectiveMinCheckAndLint) {
|
|
593
|
+
effectiveMinCheckAndLint = enginesMajor;
|
|
594
|
+
}
|
|
595
|
+
if (enginesMajor > effectiveRecCheckAndLint) {
|
|
596
|
+
effectiveRecCheckAndLint = enginesMajor;
|
|
597
|
+
}
|
|
598
|
+
if (enginesMajor > effectiveMinDeploy) {
|
|
599
|
+
effectiveMinDeploy = enginesMajor;
|
|
600
|
+
}
|
|
601
|
+
if (enginesMajor > effectiveRecDeploy) {
|
|
602
|
+
effectiveRecDeploy = enginesMajor;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
258
607
|
// E3010: check-and-lint job
|
|
259
608
|
if (!jobs['check-and-lint']) {
|
|
260
609
|
if (!context.cfg.onlyWWW) {
|
|
@@ -270,12 +619,49 @@ async function checkTests(context) {
|
|
|
270
619
|
context.checks.push('Job "check-and-lint" found.');
|
|
271
620
|
|
|
272
621
|
// W3013: check-and-lint must use ioBroker/testing-action-check@v1
|
|
273
|
-
|
|
622
|
+
const checkActionPrefix = 'ioBroker/testing-action-check@';
|
|
623
|
+
const requiredCheckActionVersion = testingCfg['ioBroker/testing-action-check'];
|
|
624
|
+
if (!jobHasStepWithAction(jobs['check-and-lint'], checkActionPrefix)) {
|
|
274
625
|
context.warnings.push(
|
|
275
|
-
`[W3013] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should contain a step using "ioBroker/testing-action-check
|
|
626
|
+
`[W3013] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should contain a step using "ioBroker/testing-action-check@${requiredCheckActionVersion}".`,
|
|
276
627
|
);
|
|
277
628
|
} else {
|
|
278
|
-
context.checks.push(
|
|
629
|
+
context.checks.push(
|
|
630
|
+
`Job "check-and-lint" uses "ioBroker/testing-action-check@${requiredCheckActionVersion}".`,
|
|
631
|
+
);
|
|
632
|
+
const requiredMajor = parseActionMajorVersion(requiredCheckActionVersion);
|
|
633
|
+
const usedRefs = getJobActionRefs(jobs['check-and-lint'], checkActionPrefix);
|
|
634
|
+
const lowerRefs = usedRefs.filter(ref => {
|
|
635
|
+
const major = parseActionMajorVersion(ref);
|
|
636
|
+
return requiredMajor !== null && major !== null && major < requiredMajor;
|
|
637
|
+
});
|
|
638
|
+
for (const lowerRef of lowerRefs) {
|
|
639
|
+
context.warnings.push(
|
|
640
|
+
`[W3028] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses "ioBroker/testing-action-check@${lowerRef}" ` +
|
|
641
|
+
`which is below the required version "${requiredCheckActionVersion}".`,
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// E3020 / S3021: check node.js version for check-and-lint job
|
|
647
|
+
const checkLintNodeVersion = getJobNodeMajorVersion(jobs['check-and-lint']);
|
|
648
|
+
if (checkLintNodeVersion !== null) {
|
|
649
|
+
if (checkLintNodeVersion < effectiveMinCheckAndLint) {
|
|
650
|
+
context.errors.push(
|
|
651
|
+
`[E3020] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses node.js ${checkLintNodeVersion} ` +
|
|
652
|
+
`which is below the minimum required version ${effectiveMinCheckAndLint}. ` +
|
|
653
|
+
`Please update to node.js ${effectiveRecCheckAndLint}.`,
|
|
654
|
+
);
|
|
655
|
+
} else if (checkLintNodeVersion < effectiveRecCheckAndLint) {
|
|
656
|
+
context.warnings.push(
|
|
657
|
+
`[S3021] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses node.js ${checkLintNodeVersion}. ` +
|
|
658
|
+
`Consider updating to the recommended version ${effectiveRecCheckAndLint}.`,
|
|
659
|
+
);
|
|
660
|
+
} else {
|
|
661
|
+
context.checks.push(
|
|
662
|
+
`Job "check-and-lint" uses node.js ${checkLintNodeVersion} (meets recommended version ${effectiveRecCheckAndLint}).`,
|
|
663
|
+
);
|
|
664
|
+
}
|
|
279
665
|
}
|
|
280
666
|
}
|
|
281
667
|
|
|
@@ -299,12 +685,94 @@ async function checkTests(context) {
|
|
|
299
685
|
}
|
|
300
686
|
|
|
301
687
|
// W3015: adapter-tests must use ioBroker/testing-action-adapter@v1
|
|
302
|
-
|
|
688
|
+
const adapterActionPrefix = 'ioBroker/testing-action-adapter@';
|
|
689
|
+
const requiredAdapterActionVersion = testingCfg['ioBroker/testing-action-adapter'];
|
|
690
|
+
if (!jobHasStepWithAction(jobs['adapter-tests'], adapterActionPrefix)) {
|
|
303
691
|
context.warnings.push(
|
|
304
|
-
`[W3015] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should contain a step using "ioBroker/testing-action-adapter
|
|
692
|
+
`[W3015] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should contain a step using "ioBroker/testing-action-adapter@${requiredAdapterActionVersion}".`,
|
|
305
693
|
);
|
|
306
694
|
} else {
|
|
307
|
-
context.checks.push(
|
|
695
|
+
context.checks.push(
|
|
696
|
+
`Job "adapter-tests" uses "ioBroker/testing-action-adapter@${requiredAdapterActionVersion}".`,
|
|
697
|
+
);
|
|
698
|
+
const requiredMajor = parseActionMajorVersion(requiredAdapterActionVersion);
|
|
699
|
+
const usedRefs = getJobActionRefs(jobs['adapter-tests'], adapterActionPrefix);
|
|
700
|
+
const lowerRefs = usedRefs.filter(ref => {
|
|
701
|
+
const major = parseActionMajorVersion(ref);
|
|
702
|
+
return requiredMajor !== null && major !== null && major < requiredMajor;
|
|
703
|
+
});
|
|
704
|
+
for (const lowerRef of lowerRefs) {
|
|
705
|
+
context.warnings.push(
|
|
706
|
+
`[W3029] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" uses "ioBroker/testing-action-adapter@${lowerRef}" ` +
|
|
707
|
+
`which is below the required version "${requiredAdapterActionVersion}".`,
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// W3024 / E3025 / W3026: check node.js version matrix for adapter-tests
|
|
713
|
+
const matrixNodeVersions = getMatrixNodeMajorVersions(jobs['adapter-tests']);
|
|
714
|
+
if (matrixNodeVersions.length > 0) {
|
|
715
|
+
// Remove versions lower than engines:node requirement from all version lists before checking.
|
|
716
|
+
const validVersionNums = testingCfg.validMatrixNodeVersions
|
|
717
|
+
.map(v => parseInt(v, 10))
|
|
718
|
+
.filter(v => v >= enginesMajor);
|
|
719
|
+
const requiredVersionNums = testingCfg.requiredMatrixNodeVersions
|
|
720
|
+
.map(v => parseInt(v, 10))
|
|
721
|
+
.filter(v => v >= enginesMajor);
|
|
722
|
+
const recommendedVersionNums = testingCfg.recommendedMatrixNodeVersions
|
|
723
|
+
.map(v => parseInt(v, 10))
|
|
724
|
+
.filter(v => v >= enginesMajor);
|
|
725
|
+
|
|
726
|
+
// W3024: warn about versions not in the valid list
|
|
727
|
+
const invalidVersions = matrixNodeVersions.filter(v => !validVersionNums.includes(v));
|
|
728
|
+
for (const v of invalidVersions) {
|
|
729
|
+
context.warnings.push(
|
|
730
|
+
`[W3024] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix uses node.js ${v} ` +
|
|
731
|
+
`which is not in the list of recommended testing versions (${testingCfg.validMatrixNodeVersions.join(', ')}).`,
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// E3025: error for missing required versions
|
|
736
|
+
const missingRequired = requiredVersionNums.filter(v => !matrixNodeVersions.includes(v));
|
|
737
|
+
for (const v of missingRequired) {
|
|
738
|
+
context.errors.push(
|
|
739
|
+
`[E3025] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix is missing required node.js version ${v}. ` +
|
|
740
|
+
`Tests with node.js ${v} are required.`,
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// W3026: warn about missing recommended versions (not already flagged as required)
|
|
745
|
+
const missingRecommended = recommendedVersionNums.filter(
|
|
746
|
+
v => !matrixNodeVersions.includes(v) && !requiredVersionNums.includes(v),
|
|
747
|
+
);
|
|
748
|
+
for (const v of missingRecommended) {
|
|
749
|
+
context.warnings.push(
|
|
750
|
+
`[W3026] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix is missing recommended node.js version ${v}. ` +
|
|
751
|
+
`Consider adding tests with node.js ${v}.`,
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (invalidVersions.length === 0 && missingRequired.length === 0 && missingRecommended.length === 0) {
|
|
756
|
+
context.checks.push(
|
|
757
|
+
`Job "adapter-tests" matrix node.js versions (${matrixNodeVersions.join(', ')}) are correctly configured.`,
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// W3027: check OS matrix for adapter-tests
|
|
763
|
+
const matrixOs = getMatrixOs(jobs['adapter-tests']);
|
|
764
|
+
if (matrixOs.length > 0) {
|
|
765
|
+
const missingOs = testingCfg.requiredOsMatrix.filter(os => !matrixOs.includes(os));
|
|
766
|
+
if (missingOs.length > 0) {
|
|
767
|
+
context.warnings.push(
|
|
768
|
+
`[W3027] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" OS matrix is missing: ${missingOs.join(', ')}. ` +
|
|
769
|
+
`Consider adding tests for all of: ${testingCfg.requiredOsMatrix.join(', ')}.`,
|
|
770
|
+
);
|
|
771
|
+
} else {
|
|
772
|
+
context.checks.push(
|
|
773
|
+
`Job "adapter-tests" OS matrix includes all required systems (${testingCfg.requiredOsMatrix.join(', ')}).`,
|
|
774
|
+
);
|
|
775
|
+
}
|
|
308
776
|
}
|
|
309
777
|
}
|
|
310
778
|
|
|
@@ -328,20 +796,36 @@ async function checkTests(context) {
|
|
|
328
796
|
}
|
|
329
797
|
|
|
330
798
|
// W3017: deploy must use ioBroker/testing-action-deploy@v1
|
|
331
|
-
|
|
799
|
+
const deployActionPrefix = 'ioBroker/testing-action-deploy@';
|
|
800
|
+
const requiredDeployActionVersion = testingCfg['ioBroker/testing-action-deploy'];
|
|
801
|
+
if (!jobHasStepWithAction(jobs['deploy'], deployActionPrefix)) {
|
|
332
802
|
context.warnings.push(
|
|
333
|
-
`[W3017] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" should contain a step using "ioBroker/testing-action-deploy
|
|
803
|
+
`[W3017] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" should contain a step using "ioBroker/testing-action-deploy@${requiredDeployActionVersion}".`,
|
|
334
804
|
);
|
|
335
805
|
} else {
|
|
336
|
-
context.checks.push(
|
|
806
|
+
context.checks.push(
|
|
807
|
+
`Job "deploy" uses "ioBroker/testing-action-deploy@${requiredDeployActionVersion}".`,
|
|
808
|
+
);
|
|
809
|
+
const requiredMajor = parseActionMajorVersion(requiredDeployActionVersion);
|
|
810
|
+
const usedRefs = getJobActionRefs(jobs['deploy'], deployActionPrefix);
|
|
811
|
+
const lowerRefs = usedRefs.filter(ref => {
|
|
812
|
+
const major = parseActionMajorVersion(ref);
|
|
813
|
+
return requiredMajor !== null && major !== null && major < requiredMajor;
|
|
814
|
+
});
|
|
815
|
+
for (const lowerRef of lowerRefs) {
|
|
816
|
+
context.warnings.push(
|
|
817
|
+
`[W3030] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses "ioBroker/testing-action-deploy@${lowerRef}" ` +
|
|
818
|
+
`which is below the required version "${requiredDeployActionVersion}".`,
|
|
819
|
+
);
|
|
820
|
+
}
|
|
337
821
|
|
|
338
|
-
//
|
|
822
|
+
// S3018: check trusted publishing permissions at job level
|
|
339
823
|
const permissions = jobs['deploy'].permissions;
|
|
340
824
|
const hasContentsWrite = permissions && permissions.contents === 'write';
|
|
341
825
|
const hasIdTokenWrite = permissions && permissions['id-token'] === 'write';
|
|
342
826
|
if (!hasContentsWrite || !hasIdTokenWrite) {
|
|
343
827
|
context.warnings.push(
|
|
344
|
-
`[
|
|
828
|
+
`[S3018] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" is missing required permissions "contents: write" and "id-token: write" at job level. ` +
|
|
345
829
|
`Trusted publishing will not work without them.`,
|
|
346
830
|
);
|
|
347
831
|
} else {
|
|
@@ -352,7 +836,7 @@ async function checkTests(context) {
|
|
|
352
836
|
|
|
353
837
|
// W3019: check that npm-token is not specified in the deploy action step
|
|
354
838
|
const deployStep = jobs['deploy'].steps.find(
|
|
355
|
-
step => typeof step.uses === 'string' && step.uses.startsWith(
|
|
839
|
+
step => typeof step.uses === 'string' && step.uses.startsWith(deployActionPrefix),
|
|
356
840
|
);
|
|
357
841
|
if (
|
|
358
842
|
deployStep &&
|
|
@@ -368,6 +852,27 @@ async function checkTests(context) {
|
|
|
368
852
|
context.checks.push('Job "deploy" step does not use "npm-token" (trusted publishing compatible).');
|
|
369
853
|
}
|
|
370
854
|
}
|
|
855
|
+
|
|
856
|
+
// E3022 / S3023: check node.js version for deploy job
|
|
857
|
+
const deployNodeVersion = getJobNodeMajorVersion(jobs['deploy']);
|
|
858
|
+
if (deployNodeVersion !== null) {
|
|
859
|
+
if (deployNodeVersion < effectiveMinDeploy) {
|
|
860
|
+
context.errors.push(
|
|
861
|
+
`[E3022] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses node.js ${deployNodeVersion} ` +
|
|
862
|
+
`which is below the minimum required version ${effectiveMinDeploy}. ` +
|
|
863
|
+
`Please update to node.js ${effectiveRecDeploy}.`,
|
|
864
|
+
);
|
|
865
|
+
} else if (deployNodeVersion < effectiveRecDeploy) {
|
|
866
|
+
context.warnings.push(
|
|
867
|
+
`[S3023] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses node.js ${deployNodeVersion}. ` +
|
|
868
|
+
`Consider updating to the recommended version ${effectiveRecDeploy}.`,
|
|
869
|
+
);
|
|
870
|
+
} else {
|
|
871
|
+
context.checks.push(
|
|
872
|
+
`Job "deploy" uses node.js ${deployNodeVersion} (meets recommended version ${effectiveRecDeploy}).`,
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
371
876
|
}
|
|
372
877
|
}
|
|
373
878
|
|