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