@kurvball/rehearse 1.11.0 → 1.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/dist/commands/compare.js +2 -2
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +27 -3
- package/dist/kinds/file/kind.d.ts +1 -0
- package/dist/kinds/file/kind.js +1 -0
- package/dist/scenarios/scenario.d.ts +2 -0
- package/dist/scenarios/scenario.js +1 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/schema/v1/common.schema.json +4 -0
- package/schema/v1/comparison.schema.json +1 -1
- package/schema/v1/file-scenario.schema.json +4 -0
package/dist/commands/compare.js
CHANGED
|
@@ -24,7 +24,7 @@ export function comparisonText(c) {
|
|
|
24
24
|
lines.push('', `${VERDICT_WORDS[verdict]}:`);
|
|
25
25
|
for (const s of these) {
|
|
26
26
|
const where = `${s.scenario.file}${s.scenario.line ? `:${s.scenario.line}` : ''}`;
|
|
27
|
-
lines.push(` ${s.scenario.name} (${where})${s.said === 'announced' && s.why ? ` — announced: ${s.why}` : s.said === 'edited' ? ' — its definition was edited' : ''}`);
|
|
27
|
+
lines.push(` ${s.scenario.name} (${where})${s.said === 'announced' && s.why ? ` — announced: ${s.why}` : s.said === 'edited' ? ' — its definition was edited' : s.verdict === 'unsaid' && s.edited ? ' — its definition was edited too, but it is a contract: announce what changed' : ''}`);
|
|
28
28
|
for (const d of s.differences.slice(0, 4))
|
|
29
29
|
lines.push(` ${d.path}: ${d.base} → ${d.head}${d.count > 1 ? ` (${d.count} places)` : ''}`);
|
|
30
30
|
if (s.differences.length > 4)
|
|
@@ -43,7 +43,7 @@ export function comparisonText(c) {
|
|
|
43
43
|
lines.push(` ${b.path} — in ${b.scenarios.length} scenario${b.scenarios.length === 1 ? '' : 's'}`);
|
|
44
44
|
}
|
|
45
45
|
if (c.gone.length)
|
|
46
|
-
lines.push('', 'gone from the head:', ...c.gone.map((g) => ` ${g.name} (${g.file})`));
|
|
46
|
+
lines.push('', 'gone from the head:', ...c.gone.map((g) => ` ${g.name} (${g.file})${g.contract ? ' — a contract: announce it if it was meant' : ''}`));
|
|
47
47
|
if (c.notRun.length)
|
|
48
48
|
lines.push('', 'not run:', ...c.notRun.map((n) => ` ${n.scenario.name} on the ${n.side} (${n.step}): ${n.says}`));
|
|
49
49
|
if (c.announcedUnchanged.length)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Failure } from '../kinds/index.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type Manifest } from '../manifest/index.ts';
|
|
3
3
|
import { type CheckoutInfo, type Observation } from '../run/index.ts';
|
|
4
4
|
import { type ScenarioRef } from '../scenarios/index.ts';
|
|
5
5
|
import type { Difference } from './diff.ts';
|
package/dist/compare/compare.js
CHANGED
|
@@ -5,6 +5,7 @@ import { affected } from '../affected/index.js';
|
|
|
5
5
|
import { RehearseError, errorText } from '../errors.js';
|
|
6
6
|
import { checkoutFor, infoOf, commitOf, gitOr, topOf } from '../git/index.js';
|
|
7
7
|
import { runnerOf } from '../kinds/index.js';
|
|
8
|
+
import { loadManifest } from '../manifest/index.js';
|
|
8
9
|
import { cached, cacheKeyOf, groupsOf, keep, runSideSharing, slotsFor, } from '../run/index.js';
|
|
9
10
|
import { readScenarios, refOf, globToRegExp, } from '../scenarios/index.js';
|
|
10
11
|
import { runningServices, stateDir } from '../services/index.js';
|
|
@@ -84,6 +85,17 @@ function bothSidesMayRunAtOnce(m, base, head) {
|
|
|
84
85
|
runningServices(m.dir).every((r) => onlyTheseTwo.has(path.resolve(r.checkout))));
|
|
85
86
|
}
|
|
86
87
|
const latestComparisonFile = (m, everyScenario) => path.join(stateDir(m.dir), 'compare', everyScenario ? 'latest.json' : 'latest-partial.json');
|
|
88
|
+
function setAsideChangedOnTheBase(m, base) {
|
|
89
|
+
const inTheRepository = path.relative(topOf(m.dir) ?? m.dir, m.file);
|
|
90
|
+
if (inTheRepository.startsWith('..') || path.isAbsolute(inTheRepository))
|
|
91
|
+
return false;
|
|
92
|
+
try {
|
|
93
|
+
return (JSON.stringify(loadManifest(path.join(base, inTheRepository)).setAside) !== JSON.stringify(m.setAside));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
87
99
|
export async function compare(m, o) {
|
|
88
100
|
const begun = Date.now();
|
|
89
101
|
const parallel = o.parallel ?? 1;
|
|
@@ -211,6 +223,7 @@ export async function compare(m, o) {
|
|
|
211
223
|
notRunOf('base', baseRun.notRun);
|
|
212
224
|
notRunOf('head', headRun.notRun);
|
|
213
225
|
const notRunIds = new Set(out.notRun.map((n) => n.scenario.id));
|
|
226
|
+
const rulesChanged = setAsideChangedOnTheBase(m, base.path);
|
|
214
227
|
const baseById = new Map(baseScenarios.map((s) => [s.id, s]));
|
|
215
228
|
const allBase = new Map(baseRead.scenarios.map((s) => [s.id, s]));
|
|
216
229
|
const standins = new Map();
|
|
@@ -239,9 +252,18 @@ export async function compare(m, o) {
|
|
|
239
252
|
},
|
|
240
253
|
];
|
|
241
254
|
const baseScenario = baseById.get(s.id) ?? allBase.get(s.id);
|
|
242
|
-
const
|
|
255
|
+
const aContract = s.contract === true || baseScenario?.contract === true;
|
|
256
|
+
const edited = (s.from === 'checkout' && baseScenario !== undefined && baseScenario.definition !== s.definition) ||
|
|
257
|
+
(aContract && rulesChanged);
|
|
243
258
|
const announcement = announcementFor(s.id, announced);
|
|
244
|
-
const said = announcement ? 'announced' : edited ? 'edited' : null;
|
|
259
|
+
const said = announcement ? 'announced' : edited && !aContract ? 'edited' : null;
|
|
260
|
+
if (aContract && edited && differences.length === 0)
|
|
261
|
+
differences.push({
|
|
262
|
+
path: rulesChanged ? 'set-aside rules in rehearse.yaml' : 'its definition',
|
|
263
|
+
base: 'as on the base',
|
|
264
|
+
head: 'edited',
|
|
265
|
+
count: 1,
|
|
266
|
+
});
|
|
245
267
|
const changed = differences.length > 0;
|
|
246
268
|
const failsOnHead = !h.ok;
|
|
247
269
|
const failsOnBase = b ? !b.ok : false;
|
|
@@ -269,6 +291,7 @@ export async function compare(m, o) {
|
|
|
269
291
|
out.counts.failsOnBoth += 1;
|
|
270
292
|
}
|
|
271
293
|
out.gone = baseScenarios.filter((s) => !headIds.has(s.id)).map(refOf);
|
|
294
|
+
const goneContractsUnsaid = out.gone.filter((g) => g.contract === true && !announcementFor(g.id, announced));
|
|
272
295
|
out.counts.gone = out.gone.length;
|
|
273
296
|
out.counts.notRun = new Set(out.notRun.map((n) => n.scenario.id)).size;
|
|
274
297
|
for (const a of announced) {
|
|
@@ -302,7 +325,8 @@ export async function compare(m, o) {
|
|
|
302
325
|
out.head.ok &&
|
|
303
326
|
out.counts.notRun === 0 &&
|
|
304
327
|
out.counts.fails === 0 &&
|
|
305
|
-
out.counts.unsaid === 0
|
|
328
|
+
out.counts.unsaid === 0 &&
|
|
329
|
+
goneContractsUnsaid.length === 0;
|
|
306
330
|
out.ms = Date.now() - begun;
|
|
307
331
|
mkdirSync(dir, { recursive: true });
|
|
308
332
|
writeFileSync(path.join(dir, 'comparison.json'), `${JSON.stringify(out, null, 2)}\n`);
|
package/dist/kinds/file/kind.js
CHANGED
|
@@ -14,6 +14,7 @@ export interface Scenario {
|
|
|
14
14
|
person: string | null;
|
|
15
15
|
service: string | null;
|
|
16
16
|
covers: string[];
|
|
17
|
+
contract?: boolean;
|
|
17
18
|
spec: unknown;
|
|
18
19
|
}
|
|
19
20
|
export interface Refused {
|
|
@@ -30,5 +31,6 @@ export interface ScenarioRef {
|
|
|
30
31
|
area: string;
|
|
31
32
|
from: 'checkout' | 'manifest';
|
|
32
33
|
definition: string;
|
|
34
|
+
contract?: true;
|
|
33
35
|
}
|
|
34
36
|
export declare const refOf: (s: Scenario) => ScenarioRef;
|
package/llms.txt
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
## Verdicts
|
|
31
31
|
|
|
32
|
-
- same: as on the base. said: changed and said so (announced, or its own definition edited; announced wins). unsaid: changed without saying so. new: not on the base. fails: fails on the head (failsOnBase: it fails on the base too, so not this change's doing).
|
|
32
|
+
- same: as on the base. said: changed and said so (announced, or its own definition edited, unless it is a file scenario with contract: true; announced wins). unsaid: changed without saying so. new: not on the base. fails: fails on the head (failsOnBase: it fails on the base too, so not this change's doing).
|
|
33
33
|
- Ids, times and opaque tokens are set aside before comparing; arrays keep their order unless a scenario says unordered; a comparison counts what it set aside.
|
|
34
34
|
- A change announces what it expects to change in .rehearse/announce.yaml beside rehearse.yaml (schema announce): changes: [{scenario: <id or glob>, why: <one line>}].
|
|
35
35
|
- The base's observations are cached by commit under .rehearse/cache, so each base commit runs once; scenarios that share services in a world are cached and run as a group; --fresh runs again.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurvball/rehearse",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Rehearse a change before it ships: bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head.",
|
|
5
5
|
"homepage": "https://rehearse.kurvball.ca/",
|
|
6
6
|
"repository": {
|
|
@@ -54,6 +54,10 @@
|
|
|
54
54
|
"definition": {
|
|
55
55
|
"description": "A hash of the scenario's parsed definition. It changes when the scenario itself is edited.",
|
|
56
56
|
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"contract": {
|
|
59
|
+
"description": "True for a file scenario marked contract: true. A contract gone from the head needs an announcement.",
|
|
60
|
+
"const": true
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
},
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"type": "boolean"
|
|
115
115
|
},
|
|
116
116
|
"said": {
|
|
117
|
-
"description": "announced when the change announced it (this wins, since it carries why), else edited when its own definition changed, else null.",
|
|
117
|
+
"description": "announced when the change announced it (this wins, since it carries why), else edited when its own definition changed (never for a contract, which only an announcement says), else null.",
|
|
118
118
|
"enum": ["announced", "edited", null]
|
|
119
119
|
},
|
|
120
120
|
"why": {
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"type": "string"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
"contract": {
|
|
37
|
+
"description": "A contract, such as a command's JSON: editing the scenario doesn't say its output changed on purpose, so a change still needs an announcement, such as a rehearse: line in a changeset.",
|
|
38
|
+
"type": "boolean"
|
|
39
|
+
},
|
|
36
40
|
"input": {
|
|
37
41
|
"description": "The input: a file beside this one, or a command that writes {{input}}.",
|
|
38
42
|
"type": "object",
|