@dcaldeira/tooling 0.1.0 → 0.2.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 +34 -34
- package/checks/a11y.mjs +206 -206
- package/checks/architecture.mjs +137 -137
- package/checks/audit.mjs +121 -121
- package/checks/bundle.mjs +126 -126
- package/checks/dependencies.mjs +277 -277
- package/checks/duplication.mjs +135 -0
- package/checks/lint-scss.mjs +363 -349
- package/checks/package.mjs +30 -30
- package/checks/playwright-summary.mjs +53 -53
- package/checks/sass.mjs +67 -67
- package/checks/scan-secrets.mjs +58 -58
- package/checks/shared.mjs +86 -86
- package/checks/translations.mjs +55 -55
- package/checks/visual-compare.mjs +148 -148
- package/checks/visual-report-html.mjs +470 -470
- package/checks/visual-report.mjs +13 -13
- package/config.schema.json +977 -927
- package/configs/eslint.mjs +27 -27
- package/configs/knip.json +11 -11
- package/configs/playwright.mjs +15 -15
- package/configs/vitest.mjs +16 -16
- package/package.json +105 -105
- package/release/finalize.mjs +65 -65
- package/release/github.mjs +64 -64
- package/release/prepare.mjs +30 -30
- package/runner/browsers.mjs +73 -73
- package/runner/cache.mjs +121 -121
- package/runner/ci-plan.mjs +54 -54
- package/runner/cli.mjs +250 -248
- package/runner/config.mjs +148 -148
- package/runner/docs-install.mjs +93 -93
- package/runner/execute.mjs +298 -286
- package/runner/generate.mjs +122 -122
- package/runner/git.mjs +122 -122
- package/runner/graph.mjs +250 -243
- package/runner/insights.mjs +313 -313
- package/runner/provision.mjs +53 -53
- package/runner/repo-standard.mjs +104 -0
- package/runner/report.mjs +35 -35
- package/runner/serve-static.mjs +76 -76
- package/runner/setup.mjs +241 -237
- package/runner/summary.mjs +112 -112
- package/runner/watch.mjs +82 -82
- package/templates/ci.yml +25 -25
- package/templates/dependabot-merge.yml +13 -13
- package/templates/dependabot.yml +26 -26
- package/templates/pre-push +13 -13
- package/templates/release.yml +23 -23
package/runner/summary.mjs
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
|
|
5
|
-
const text = (value) =>
|
|
6
|
-
String(value ?? '')
|
|
7
|
-
.replace(/[\r\n]+/g, ' ')
|
|
8
|
-
.replaceAll('&', '&')
|
|
9
|
-
.replaceAll('<', '<')
|
|
10
|
-
.replaceAll('>', '>')
|
|
11
|
-
.replaceAll('|', '|')
|
|
12
|
-
.replaceAll('`', '`')
|
|
13
|
-
.replace(/([\[\]()*_!\\])/g, '\\$1')
|
|
14
|
-
.slice(0, 600);
|
|
15
|
-
const seconds = (value) => `${((value ?? 0) / 1000).toFixed(2)}s`;
|
|
16
|
-
|
|
17
|
-
export function markdownSummary(report, { artifactURL } = {}) {
|
|
18
|
-
const lines = [
|
|
19
|
-
`## Validation ${report.complete ? 'passed' : 'incomplete or failed'}`,
|
|
20
|
-
'',
|
|
21
|
-
`Profile: **${text(report.profile)}** · Scope: ${report.groups.map(text).join(', ')} · Duration: ${seconds(report.wallMilliseconds)}`,
|
|
22
|
-
`Selected checks: **${report.results.length}** · Cache hits: **${report.results.filter((check) => check.cached).length}**`,
|
|
23
|
-
'',
|
|
24
|
-
];
|
|
25
|
-
if (report.affectedWorkspaces?.length)
|
|
26
|
-
lines.push(`Affected workspaces: ${report.affectedWorkspaces.map(text).join(', ')}`, '');
|
|
27
|
-
lines.push('| Check | Result | Reused | Time | Details |', '| --- | --- | --- | --- | --- |');
|
|
28
|
-
for (const check of report.results)
|
|
29
|
-
lines.push(
|
|
30
|
-
`| ${text(check.id)} | ${text(check.status)} | ${check.cached ? 'yes' : 'no'} | ${seconds(check.milliseconds)} | ${text(check.reason)} |`,
|
|
31
|
-
);
|
|
32
|
-
const metrics = report.metrics ?? {};
|
|
33
|
-
if (metrics.bundle)
|
|
34
|
-
lines.push(
|
|
35
|
-
'',
|
|
36
|
-
`Initial JavaScript: **${Number(metrics.bundle.initialKB).toFixed(1)} KB gzip**${report.performance?.bundleDeltaKB == null ? '' : ` (${report.performance.bundleDeltaKB >= 0 ? '+' : ''}${report.performance.bundleDeltaKB.toFixed(1)} KB against the previous comparable run)`}.`,
|
|
37
|
-
);
|
|
38
|
-
if (metrics.coverage)
|
|
39
|
-
lines.push(
|
|
40
|
-
'',
|
|
41
|
-
`Coverage: ${Object.entries(metrics.coverage)
|
|
42
|
-
.map(([key, value]) => `${text(key)} **${value.toFixed(1)}%**`)
|
|
43
|
-
.join(' · ')}.`,
|
|
44
|
-
);
|
|
45
|
-
if (metrics.browser)
|
|
46
|
-
lines.push(
|
|
47
|
-
'',
|
|
48
|
-
`Browser tests: ${metrics.browser.passed} passed · ${metrics.browser.failed} failed · ${metrics.browser.flaky} flaky · ${metrics.browser.skipped} skipped.`,
|
|
49
|
-
);
|
|
50
|
-
if (metrics.a11y)
|
|
51
|
-
lines.push(
|
|
52
|
-
'',
|
|
53
|
-
`Accessibility: ${metrics.a11y.pages} rendered pages · ${metrics.a11y.violations} blocking violations · ${metrics.a11y.errors} scan errors.`,
|
|
54
|
-
);
|
|
55
|
-
if (metrics.architecture)
|
|
56
|
-
lines.push(
|
|
57
|
-
'',
|
|
58
|
-
`Architecture: ${metrics.architecture.files} source files · ${metrics.architecture.issues} violations.`,
|
|
59
|
-
);
|
|
60
|
-
if (metrics.dependencies)
|
|
61
|
-
lines.push(
|
|
62
|
-
'',
|
|
63
|
-
`Dependencies: ${metrics.dependencies.packages} manifests · ${metrics.dependencies.issues} errors · ${metrics.dependencies.duplicates} duplicate-version notices.`,
|
|
64
|
-
);
|
|
65
|
-
if (report.performance?.previousMs !== null && report.performance?.previousMs !== undefined)
|
|
66
|
-
lines.push(
|
|
67
|
-
'',
|
|
68
|
-
`Previous comparable median: ${seconds(report.performance.previousMs)}. Current change: ${report.performance.deltaMs >= 0 ? '+' : ''}${seconds(report.performance.deltaMs)}.`,
|
|
69
|
-
);
|
|
70
|
-
for (const regression of report.performance?.regressions ?? [])
|
|
71
|
-
lines.push(
|
|
72
|
-
'',
|
|
73
|
-
`Slower check: **${text(regression.id)}**, ${seconds(regression.currentMs)} against ${seconds(regression.previousMs)} median.`,
|
|
74
|
-
);
|
|
75
|
-
if (metrics.slowTests?.length) {
|
|
76
|
-
lines.push('', '### Slowest reported tests', '', '| Test | Time |', '| --- | --- |');
|
|
77
|
-
for (const test of metrics.slowTests.slice(0, 10))
|
|
78
|
-
lines.push(`| ${text(test.name)} | ${seconds(test.milliseconds)} |`);
|
|
79
|
-
}
|
|
80
|
-
const visual = report.results.filter(
|
|
81
|
-
(check) =>
|
|
82
|
-
(check.kind ?? check.id) === 'visual' && !['excluded', 'unavailable'].includes(check.status),
|
|
83
|
-
);
|
|
84
|
-
if (visual.length)
|
|
85
|
-
lines.push(
|
|
86
|
-
'',
|
|
87
|
-
`Visual results: ${visual.map((check) => `${text(check.id)} (${text(check.status)})`).join(', ')}. Expected, actual and diff images are in the browser reports.`,
|
|
88
|
-
);
|
|
89
|
-
if (artifactURL) {
|
|
90
|
-
const url = new URL(artifactURL);
|
|
91
|
-
if (!['https:', 'http:'].includes(url.protocol))
|
|
92
|
-
throw new Error('Artifact URL must use HTTP or HTTPS');
|
|
93
|
-
lines.push('', `[Download validation reports and visual differences](<${url.href}>)`);
|
|
94
|
-
}
|
|
95
|
-
lines.push('', `Commit: ${text(report.commit)} · Tooling: ${text(report.version)}`, '');
|
|
96
|
-
return lines.join('\n');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
100
|
-
const directory = process.argv[2] ?? '.tooling/report';
|
|
101
|
-
const path = join(directory, 'summary.json');
|
|
102
|
-
const markdown = existsSync(path)
|
|
103
|
-
? markdownSummary(JSON.parse(readFileSync(path, 'utf8')), {
|
|
104
|
-
artifactURL: process.env.TOOLING_ARTIFACT_URL,
|
|
105
|
-
})
|
|
106
|
-
: process.env.TOOLING_EMPTY_PLAN === 'true'
|
|
107
|
-
? '## Validation passed\n\nNo checks apply to this change. Installation and validation were skipped.\n'
|
|
108
|
-
: '## Validation stopped before a report was produced\n\nSee the failed workflow step for the prerequisite or planning error.\n';
|
|
109
|
-
if (existsSync(directory)) writeFileSync(join(directory, 'summary.md'), markdown);
|
|
110
|
-
if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, markdown);
|
|
111
|
-
else console.log(markdown);
|
|
112
|
-
}
|
|
1
|
+
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const text = (value) =>
|
|
6
|
+
String(value ?? '')
|
|
7
|
+
.replace(/[\r\n]+/g, ' ')
|
|
8
|
+
.replaceAll('&', '&')
|
|
9
|
+
.replaceAll('<', '<')
|
|
10
|
+
.replaceAll('>', '>')
|
|
11
|
+
.replaceAll('|', '|')
|
|
12
|
+
.replaceAll('`', '`')
|
|
13
|
+
.replace(/([\[\]()*_!\\])/g, '\\$1')
|
|
14
|
+
.slice(0, 600);
|
|
15
|
+
const seconds = (value) => `${((value ?? 0) / 1000).toFixed(2)}s`;
|
|
16
|
+
|
|
17
|
+
export function markdownSummary(report, { artifactURL } = {}) {
|
|
18
|
+
const lines = [
|
|
19
|
+
`## Validation ${report.complete ? 'passed' : 'incomplete or failed'}`,
|
|
20
|
+
'',
|
|
21
|
+
`Profile: **${text(report.profile)}** · Scope: ${report.groups.map(text).join(', ')} · Duration: ${seconds(report.wallMilliseconds)}`,
|
|
22
|
+
`Selected checks: **${report.results.length}** · Cache hits: **${report.results.filter((check) => check.cached).length}**`,
|
|
23
|
+
'',
|
|
24
|
+
];
|
|
25
|
+
if (report.affectedWorkspaces?.length)
|
|
26
|
+
lines.push(`Affected workspaces: ${report.affectedWorkspaces.map(text).join(', ')}`, '');
|
|
27
|
+
lines.push('| Check | Result | Reused | Time | Details |', '| --- | --- | --- | --- | --- |');
|
|
28
|
+
for (const check of report.results)
|
|
29
|
+
lines.push(
|
|
30
|
+
`| ${text(check.id)} | ${text(check.status)} | ${check.cached ? 'yes' : 'no'} | ${seconds(check.milliseconds)} | ${text(check.reason)} |`,
|
|
31
|
+
);
|
|
32
|
+
const metrics = report.metrics ?? {};
|
|
33
|
+
if (metrics.bundle)
|
|
34
|
+
lines.push(
|
|
35
|
+
'',
|
|
36
|
+
`Initial JavaScript: **${Number(metrics.bundle.initialKB).toFixed(1)} KB gzip**${report.performance?.bundleDeltaKB == null ? '' : ` (${report.performance.bundleDeltaKB >= 0 ? '+' : ''}${report.performance.bundleDeltaKB.toFixed(1)} KB against the previous comparable run)`}.`,
|
|
37
|
+
);
|
|
38
|
+
if (metrics.coverage)
|
|
39
|
+
lines.push(
|
|
40
|
+
'',
|
|
41
|
+
`Coverage: ${Object.entries(metrics.coverage)
|
|
42
|
+
.map(([key, value]) => `${text(key)} **${value.toFixed(1)}%**`)
|
|
43
|
+
.join(' · ')}.`,
|
|
44
|
+
);
|
|
45
|
+
if (metrics.browser)
|
|
46
|
+
lines.push(
|
|
47
|
+
'',
|
|
48
|
+
`Browser tests: ${metrics.browser.passed} passed · ${metrics.browser.failed} failed · ${metrics.browser.flaky} flaky · ${metrics.browser.skipped} skipped.`,
|
|
49
|
+
);
|
|
50
|
+
if (metrics.a11y)
|
|
51
|
+
lines.push(
|
|
52
|
+
'',
|
|
53
|
+
`Accessibility: ${metrics.a11y.pages} rendered pages · ${metrics.a11y.violations} blocking violations · ${metrics.a11y.errors} scan errors.`,
|
|
54
|
+
);
|
|
55
|
+
if (metrics.architecture)
|
|
56
|
+
lines.push(
|
|
57
|
+
'',
|
|
58
|
+
`Architecture: ${metrics.architecture.files} source files · ${metrics.architecture.issues} violations.`,
|
|
59
|
+
);
|
|
60
|
+
if (metrics.dependencies)
|
|
61
|
+
lines.push(
|
|
62
|
+
'',
|
|
63
|
+
`Dependencies: ${metrics.dependencies.packages} manifests · ${metrics.dependencies.issues} errors · ${metrics.dependencies.duplicates} duplicate-version notices.`,
|
|
64
|
+
);
|
|
65
|
+
if (report.performance?.previousMs !== null && report.performance?.previousMs !== undefined)
|
|
66
|
+
lines.push(
|
|
67
|
+
'',
|
|
68
|
+
`Previous comparable median: ${seconds(report.performance.previousMs)}. Current change: ${report.performance.deltaMs >= 0 ? '+' : ''}${seconds(report.performance.deltaMs)}.`,
|
|
69
|
+
);
|
|
70
|
+
for (const regression of report.performance?.regressions ?? [])
|
|
71
|
+
lines.push(
|
|
72
|
+
'',
|
|
73
|
+
`Slower check: **${text(regression.id)}**, ${seconds(regression.currentMs)} against ${seconds(regression.previousMs)} median.`,
|
|
74
|
+
);
|
|
75
|
+
if (metrics.slowTests?.length) {
|
|
76
|
+
lines.push('', '### Slowest reported tests', '', '| Test | Time |', '| --- | --- |');
|
|
77
|
+
for (const test of metrics.slowTests.slice(0, 10))
|
|
78
|
+
lines.push(`| ${text(test.name)} | ${seconds(test.milliseconds)} |`);
|
|
79
|
+
}
|
|
80
|
+
const visual = report.results.filter(
|
|
81
|
+
(check) =>
|
|
82
|
+
(check.kind ?? check.id) === 'visual' && !['excluded', 'unavailable'].includes(check.status),
|
|
83
|
+
);
|
|
84
|
+
if (visual.length)
|
|
85
|
+
lines.push(
|
|
86
|
+
'',
|
|
87
|
+
`Visual results: ${visual.map((check) => `${text(check.id)} (${text(check.status)})`).join(', ')}. Expected, actual and diff images are in the browser reports.`,
|
|
88
|
+
);
|
|
89
|
+
if (artifactURL) {
|
|
90
|
+
const url = new URL(artifactURL);
|
|
91
|
+
if (!['https:', 'http:'].includes(url.protocol))
|
|
92
|
+
throw new Error('Artifact URL must use HTTP or HTTPS');
|
|
93
|
+
lines.push('', `[Download validation reports and visual differences](<${url.href}>)`);
|
|
94
|
+
}
|
|
95
|
+
lines.push('', `Commit: ${text(report.commit)} · Tooling: ${text(report.version)}`, '');
|
|
96
|
+
return lines.join('\n');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
100
|
+
const directory = process.argv[2] ?? '.tooling/report';
|
|
101
|
+
const path = join(directory, 'summary.json');
|
|
102
|
+
const markdown = existsSync(path)
|
|
103
|
+
? markdownSummary(JSON.parse(readFileSync(path, 'utf8')), {
|
|
104
|
+
artifactURL: process.env.TOOLING_ARTIFACT_URL,
|
|
105
|
+
})
|
|
106
|
+
: process.env.TOOLING_EMPTY_PLAN === 'true'
|
|
107
|
+
? '## Validation passed\n\nNo checks apply to this change. Installation and validation were skipped.\n'
|
|
108
|
+
: '## Validation stopped before a report was produced\n\nSee the failed workflow step for the prerequisite or planning error.\n';
|
|
109
|
+
if (existsSync(directory)) writeFileSync(join(directory, 'summary.md'), markdown);
|
|
110
|
+
if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, markdown);
|
|
111
|
+
else console.log(markdown);
|
|
112
|
+
}
|
package/runner/watch.mjs
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { watch } from 'node:fs';
|
|
2
|
-
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import { relative, resolve } from 'node:path';
|
|
4
|
-
|
|
5
|
-
export function relevantChanges(root, files, inputs = []) {
|
|
6
|
-
const declared = new Set(
|
|
7
|
-
inputs.map((file) => relative(root, resolve(root, file)).replaceAll('\\', '/')),
|
|
8
|
-
);
|
|
9
|
-
const candidates = [...new Set(files.map((file) => file.replaceAll('\\', '/')))].filter(
|
|
10
|
-
(file) => {
|
|
11
|
-
if (declared.has(file)) return true;
|
|
12
|
-
if (file.startsWith('.git/')) return file === '.git/HEAD' || file.startsWith('.git/refs/');
|
|
13
|
-
return !file.split('/').some((part) => ['node_modules', '.tooling'].includes(part));
|
|
14
|
-
},
|
|
15
|
-
);
|
|
16
|
-
if (!candidates.length) return [];
|
|
17
|
-
let ignored = '';
|
|
18
|
-
try {
|
|
19
|
-
ignored = execFileSync('git', ['check-ignore', '-z', '--stdin'], {
|
|
20
|
-
cwd: root,
|
|
21
|
-
input: candidates.join('\0') + '\0',
|
|
22
|
-
encoding: 'utf8',
|
|
23
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
24
|
-
});
|
|
25
|
-
} catch (error) {
|
|
26
|
-
if (error.status !== 1) throw error;
|
|
27
|
-
ignored = error.stdout ?? '';
|
|
28
|
-
}
|
|
29
|
-
const excluded = new Set(ignored.split('\0'));
|
|
30
|
-
return candidates.filter(
|
|
31
|
-
(file) => declared.has(file) || file.startsWith('.git/') || !excluded.has(file),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Only validate after filesystem events; snapshots remain authoritative inside each validation.
|
|
36
|
-
export function watchChanges(root, run, { inputs = () => [], signal, debounce = 350 } = {}) {
|
|
37
|
-
return new Promise((resolveDone, reject) => {
|
|
38
|
-
let timer,
|
|
39
|
-
active,
|
|
40
|
-
closed = false;
|
|
41
|
-
const pending = new Set();
|
|
42
|
-
const finish = (error) => {
|
|
43
|
-
if (closed) return;
|
|
44
|
-
closed = true;
|
|
45
|
-
clearTimeout(timer);
|
|
46
|
-
watcher.close();
|
|
47
|
-
signal?.removeEventListener('abort', abort);
|
|
48
|
-
Promise.resolve(active).then(() => (error ? reject(error) : resolveDone()), reject);
|
|
49
|
-
};
|
|
50
|
-
const schedule = () => {
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
if (!closed) timer = setTimeout(drain, debounce);
|
|
53
|
-
};
|
|
54
|
-
const drain = async () => {
|
|
55
|
-
if (closed || active) return;
|
|
56
|
-
try {
|
|
57
|
-
const files = [...pending];
|
|
58
|
-
pending.clear();
|
|
59
|
-
if (!files.includes('*') && !relevantChanges(root, files, inputs()).length) return;
|
|
60
|
-
active = Promise.resolve().then(run);
|
|
61
|
-
await active;
|
|
62
|
-
} catch (error) {
|
|
63
|
-
finish(error);
|
|
64
|
-
} finally {
|
|
65
|
-
active = undefined;
|
|
66
|
-
if (pending.size) schedule();
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const watcher = watch(root, { recursive: true }, (_event, filename) => {
|
|
70
|
-
pending.add(filename?.toString() ?? '*');
|
|
71
|
-
schedule();
|
|
72
|
-
});
|
|
73
|
-
watcher.on('error', finish);
|
|
74
|
-
const abort = () => finish();
|
|
75
|
-
signal?.addEventListener('abort', abort, { once: true });
|
|
76
|
-
if (signal?.aborted) finish();
|
|
77
|
-
else {
|
|
78
|
-
pending.add('*');
|
|
79
|
-
schedule();
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
1
|
+
import { watch } from 'node:fs';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { relative, resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
export function relevantChanges(root, files, inputs = []) {
|
|
6
|
+
const declared = new Set(
|
|
7
|
+
inputs.map((file) => relative(root, resolve(root, file)).replaceAll('\\', '/')),
|
|
8
|
+
);
|
|
9
|
+
const candidates = [...new Set(files.map((file) => file.replaceAll('\\', '/')))].filter(
|
|
10
|
+
(file) => {
|
|
11
|
+
if (declared.has(file)) return true;
|
|
12
|
+
if (file.startsWith('.git/')) return file === '.git/HEAD' || file.startsWith('.git/refs/');
|
|
13
|
+
return !file.split('/').some((part) => ['node_modules', '.tooling'].includes(part));
|
|
14
|
+
},
|
|
15
|
+
);
|
|
16
|
+
if (!candidates.length) return [];
|
|
17
|
+
let ignored = '';
|
|
18
|
+
try {
|
|
19
|
+
ignored = execFileSync('git', ['check-ignore', '-z', '--stdin'], {
|
|
20
|
+
cwd: root,
|
|
21
|
+
input: candidates.join('\0') + '\0',
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error.status !== 1) throw error;
|
|
27
|
+
ignored = error.stdout ?? '';
|
|
28
|
+
}
|
|
29
|
+
const excluded = new Set(ignored.split('\0'));
|
|
30
|
+
return candidates.filter(
|
|
31
|
+
(file) => declared.has(file) || file.startsWith('.git/') || !excluded.has(file),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Only validate after filesystem events; snapshots remain authoritative inside each validation.
|
|
36
|
+
export function watchChanges(root, run, { inputs = () => [], signal, debounce = 350 } = {}) {
|
|
37
|
+
return new Promise((resolveDone, reject) => {
|
|
38
|
+
let timer,
|
|
39
|
+
active,
|
|
40
|
+
closed = false;
|
|
41
|
+
const pending = new Set();
|
|
42
|
+
const finish = (error) => {
|
|
43
|
+
if (closed) return;
|
|
44
|
+
closed = true;
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
watcher.close();
|
|
47
|
+
signal?.removeEventListener('abort', abort);
|
|
48
|
+
Promise.resolve(active).then(() => (error ? reject(error) : resolveDone()), reject);
|
|
49
|
+
};
|
|
50
|
+
const schedule = () => {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
if (!closed) timer = setTimeout(drain, debounce);
|
|
53
|
+
};
|
|
54
|
+
const drain = async () => {
|
|
55
|
+
if (closed || active) return;
|
|
56
|
+
try {
|
|
57
|
+
const files = [...pending];
|
|
58
|
+
pending.clear();
|
|
59
|
+
if (!files.includes('*') && !relevantChanges(root, files, inputs()).length) return;
|
|
60
|
+
active = Promise.resolve().then(run);
|
|
61
|
+
await active;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
finish(error);
|
|
64
|
+
} finally {
|
|
65
|
+
active = undefined;
|
|
66
|
+
if (pending.size) schedule();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const watcher = watch(root, { recursive: true }, (_event, filename) => {
|
|
70
|
+
pending.add(filename?.toString() ?? '*');
|
|
71
|
+
schedule();
|
|
72
|
+
});
|
|
73
|
+
watcher.on('error', finish);
|
|
74
|
+
const abort = () => finish();
|
|
75
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
76
|
+
if (signal?.aborted) finish();
|
|
77
|
+
else {
|
|
78
|
+
pending.add('*');
|
|
79
|
+
schedule();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
package/templates/ci.yml
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
types: [opened, synchronize, reopened, ready_for_review, edited]
|
|
5
|
-
schedule:
|
|
6
|
-
- cron: '0 8 * * 1'
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
inputs:
|
|
9
|
-
pull-request-number:
|
|
10
|
-
description: Release PR to route after trusted generation
|
|
11
|
-
type: string
|
|
12
|
-
default: ''
|
|
13
|
-
permissions:
|
|
14
|
-
contents: read
|
|
15
|
-
pull-requests: read
|
|
16
|
-
actions: read
|
|
17
|
-
concurrency:
|
|
18
|
-
group: ci-${{ github.event.pull_request.number || inputs.pull-request-number || github.ref }}
|
|
19
|
-
cancel-in-progress: true
|
|
20
|
-
jobs:
|
|
21
|
-
CI:
|
|
22
|
-
uses: DuarteCaldeira/tooling/.github/workflows/ci.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
23
|
-
with:
|
|
24
|
-
tooling-sha: REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
25
|
-
pull-request-number: ${{ inputs.pull-request-number || '' }}
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, reopened, ready_for_review, edited]
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: '0 8 * * 1'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
pull-request-number:
|
|
10
|
+
description: Release PR to route after trusted generation
|
|
11
|
+
type: string
|
|
12
|
+
default: ''
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pull-requests: read
|
|
16
|
+
actions: read
|
|
17
|
+
concurrency:
|
|
18
|
+
group: ci-${{ github.event.pull_request.number || inputs.pull-request-number || github.ref }}
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
jobs:
|
|
21
|
+
CI:
|
|
22
|
+
uses: DuarteCaldeira/tooling/.github/workflows/ci.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
23
|
+
with:
|
|
24
|
+
tooling-sha: REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
25
|
+
pull-request-number: ${{ inputs.pull-request-number || '' }}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
name: Dependabot merge
|
|
2
|
-
on:
|
|
3
|
-
workflow_run:
|
|
4
|
-
workflows: [CI]
|
|
5
|
-
types: [completed]
|
|
6
|
-
permissions:
|
|
7
|
-
contents: write
|
|
8
|
-
pull-requests: write
|
|
9
|
-
actions: read
|
|
10
|
-
checks: read
|
|
11
|
-
jobs:
|
|
12
|
-
merge:
|
|
13
|
-
uses: DuarteCaldeira/tooling/.github/workflows/dependabot-merge.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
1
|
+
name: Dependabot merge
|
|
2
|
+
on:
|
|
3
|
+
workflow_run:
|
|
4
|
+
workflows: [CI]
|
|
5
|
+
types: [completed]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
pull-requests: write
|
|
9
|
+
actions: read
|
|
10
|
+
checks: read
|
|
11
|
+
jobs:
|
|
12
|
+
merge:
|
|
13
|
+
uses: DuarteCaldeira/tooling/.github/workflows/dependabot-merge.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
package/templates/dependabot.yml
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
multi-ecosystem-groups:
|
|
3
|
-
all-dependencies:
|
|
4
|
-
schedule:
|
|
5
|
-
interval: weekly
|
|
6
|
-
day: monday
|
|
7
|
-
updates:
|
|
8
|
-
- package-ecosystem: npm
|
|
9
|
-
directory: /
|
|
10
|
-
patterns: ['*']
|
|
11
|
-
multi-ecosystem-group: all-dependencies
|
|
12
|
-
ignore:
|
|
13
|
-
- dependency-name: eslint
|
|
14
|
-
update-types: [version-update:semver-major]
|
|
15
|
-
- dependency-name: '@eslint/js'
|
|
16
|
-
update-types: [version-update:semver-major]
|
|
17
|
-
- dependency-name: typescript
|
|
18
|
-
update-types: [version-update:semver-major]
|
|
19
|
-
groups:
|
|
20
|
-
security:
|
|
21
|
-
applies-to: security-updates
|
|
22
|
-
patterns: ['*']
|
|
23
|
-
- package-ecosystem: github-actions
|
|
24
|
-
directory: /
|
|
25
|
-
patterns: ['*']
|
|
26
|
-
multi-ecosystem-group: all-dependencies
|
|
1
|
+
version: 2
|
|
2
|
+
multi-ecosystem-groups:
|
|
3
|
+
all-dependencies:
|
|
4
|
+
schedule:
|
|
5
|
+
interval: weekly
|
|
6
|
+
day: monday
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: npm
|
|
9
|
+
directory: /
|
|
10
|
+
patterns: ['*']
|
|
11
|
+
multi-ecosystem-group: all-dependencies
|
|
12
|
+
ignore:
|
|
13
|
+
- dependency-name: eslint
|
|
14
|
+
update-types: [version-update:semver-major]
|
|
15
|
+
- dependency-name: '@eslint/js'
|
|
16
|
+
update-types: [version-update:semver-major]
|
|
17
|
+
- dependency-name: typescript
|
|
18
|
+
update-types: [version-update:semver-major]
|
|
19
|
+
groups:
|
|
20
|
+
security:
|
|
21
|
+
applies-to: security-updates
|
|
22
|
+
patterns: ['*']
|
|
23
|
+
- package-ecosystem: github-actions
|
|
24
|
+
directory: /
|
|
25
|
+
patterns: ['*']
|
|
26
|
+
multi-ecosystem-group: all-dependencies
|
package/templates/pre-push
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
set -eu
|
|
3
|
-
validate=0
|
|
4
|
-
while read -r local_ref local_sha remote_ref remote_sha; do
|
|
5
|
-
case "$local_sha" in 0000000000000000000000000000000000000000) continue ;; esac
|
|
6
|
-
if [ "$(git rev-parse "$local_sha^{commit}")" != "$(git rev-parse HEAD)" ]; then
|
|
7
|
-
echo "Push refused: validate this ref from its own checkout first." >&2
|
|
8
|
-
exit 1
|
|
9
|
-
fi
|
|
10
|
-
validate=1
|
|
11
|
-
done
|
|
12
|
-
[ "$validate" -eq 0 ] && exit 0
|
|
13
|
-
exec npm run check:push
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
validate=0
|
|
4
|
+
while read -r local_ref local_sha remote_ref remote_sha; do
|
|
5
|
+
case "$local_sha" in 0000000000000000000000000000000000000000) continue ;; esac
|
|
6
|
+
if [ "$(git rev-parse "$local_sha^{commit}")" != "$(git rev-parse HEAD)" ]; then
|
|
7
|
+
echo "Push refused: validate this ref from its own checkout first." >&2
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
validate=1
|
|
11
|
+
done
|
|
12
|
+
[ "$validate" -eq 0 ] && exit 0
|
|
13
|
+
exec npm run check:push
|
package/templates/release.yml
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
on:
|
|
3
|
-
workflow_dispatch:
|
|
4
|
-
inputs:
|
|
5
|
-
level:
|
|
6
|
-
type: choice
|
|
7
|
-
options: [patch, minor, major]
|
|
8
|
-
default: patch
|
|
9
|
-
permissions:
|
|
10
|
-
contents: write
|
|
11
|
-
pull-requests: write
|
|
12
|
-
actions: write
|
|
13
|
-
concurrency:
|
|
14
|
-
group: release
|
|
15
|
-
cancel-in-progress: false
|
|
16
|
-
jobs:
|
|
17
|
-
release:
|
|
18
|
-
uses: DuarteCaldeira/tooling/.github/workflows/release-validation.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
19
|
-
with:
|
|
20
|
-
tooling-sha: REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
21
|
-
level: ${{ inputs.level }}
|
|
22
|
-
secrets:
|
|
23
|
-
RELEASE_SIGNING_KEY: ${{ secrets.TOOLING_RELEASE_SIGNING_KEY }}
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
level:
|
|
6
|
+
type: choice
|
|
7
|
+
options: [patch, minor, major]
|
|
8
|
+
default: patch
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
actions: write
|
|
13
|
+
concurrency:
|
|
14
|
+
group: release
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
uses: DuarteCaldeira/tooling/.github/workflows/release-validation.yml@REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
19
|
+
with:
|
|
20
|
+
tooling-sha: REPLACE_WITH_TOOLING_COMMIT_SHA
|
|
21
|
+
level: ${{ inputs.level }}
|
|
22
|
+
secrets:
|
|
23
|
+
RELEASE_SIGNING_KEY: ${{ secrets.TOOLING_RELEASE_SIGNING_KEY }}
|