@operad-io/dev 0.1.1 → 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 +1 -1
- package/dev.schema.json +41 -28
- package/package.json +9 -6
- package/skills/setup/SKILL.md +57 -0
- package/src/access-grants.ts +59 -0
- package/src/actions.ts +70 -16
- package/src/announce.ts +128 -16
- package/src/chat.ts +512 -36
- package/src/check-host.ts +111 -0
- package/src/check-load.ts +67 -0
- package/src/check.ts +17 -12
- package/src/clock.ts +29 -0
- package/src/commands.ts +103 -34
- package/src/create-actions.ts +210 -0
- package/src/flaky.ts +45 -29
- package/src/flow-compiler.ts +155 -68
- package/src/followups.ts +20 -22
- package/src/gate.ts +192 -73
- package/src/git.ts +47 -0
- package/src/index.ts +46 -6
- package/src/integrate.ts +82 -42
- package/src/integration-queue.ts +23 -10
- package/src/lock.ts +101 -5
- package/src/mainclone.ts +3 -3
- package/src/model-error.ts +70 -0
- package/src/model.ts +48 -35
- package/src/notcode.ts +51 -15
- package/src/places.ts +2 -2
- package/src/prepare.ts +7 -2
- package/src/project-flows.ts +135 -4
- package/src/project-settings.ts +81 -0
- package/src/register-requests.ts +87 -0
- package/src/repository-key.ts +4 -0
- package/src/rerun.ts +23 -7
- package/src/retry.ts +2 -12
- package/src/rework.ts +8 -0
- package/src/schedule.ts +317 -86
- package/src/service.ts +116 -152
- package/src/settings.ts +305 -60
- package/src/standing.ts +23 -6
- package/src/step-edge.ts +22 -0
- package/src/steps.ts +469 -123
- package/src/throughput.ts +4 -21
- package/src/timeouts.ts +10 -2
- package/src/views.ts +147 -81
- package/src/waits.ts +59 -0
package/src/flaky.ts
CHANGED
|
@@ -15,8 +15,8 @@ import { isAbsolute, join, relative } from "node:path";
|
|
|
15
15
|
import type { ObjectStore, StoredObject } from "@operad-io/engine";
|
|
16
16
|
import { isRecord, messageOf, type SecretStore } from "@operad-io/engine";
|
|
17
17
|
import type { MachineLoad } from "@operad-io/engine/platform";
|
|
18
|
-
import type
|
|
19
|
-
import {
|
|
18
|
+
import { underLoad, type CheckLoad, type CheckLoadReading } from "./check-load.ts";
|
|
19
|
+
import { idOfKey, changeClock, isOpenTask, keyRepository, listAll, parseId, planData, planState, splitBrief, taskData, type PlanData, type RepositoryData } from "./model.ts";
|
|
20
20
|
import { anchoredPattern, shellQuote } from "./rerun.ts";
|
|
21
21
|
import type { FailedRerun } from "./settings.ts";
|
|
22
22
|
import { addConfirmedPlanLocked, addTaskLocked, withRepoLock } from "./service.ts";
|
|
@@ -70,7 +70,7 @@ export interface FlakyOccurrence {
|
|
|
70
70
|
* recorded and never counts toward a task: a rerun on a busy machine says
|
|
71
71
|
* little about the test.
|
|
72
72
|
*/
|
|
73
|
-
readonly load?:
|
|
73
|
+
readonly load?: CheckLoadReading | undefined;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/** The passes that count toward a task: the ones seen on an idle machine. */
|
|
@@ -83,23 +83,23 @@ export function flakyLoadLimitOf(configured: number | undefined, load: MachineLo
|
|
|
83
83
|
return configured ?? load.cores * 2;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/** True when a reading is above the limit. */
|
|
87
|
-
function overLimit(load:
|
|
88
|
-
return load.load1 > flakyLoadLimitOf(configured, load);
|
|
86
|
+
/** True when a reading is above the limit. An unknown reading is not busy. */
|
|
87
|
+
function overLimit(load: CheckLoadReading, configured: number | undefined): boolean {
|
|
88
|
+
return load.unknown !== true && load.load1 > flakyLoadLimitOf(configured, load);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/** The load readings a check handed over: the start and the end of each run. */
|
|
92
92
|
interface LoadInput {
|
|
93
|
-
readonly load?:
|
|
94
|
-
readonly startLoad?:
|
|
95
|
-
readonly endLoad?:
|
|
93
|
+
readonly load?: CheckLoadReading | undefined;
|
|
94
|
+
readonly startLoad?: CheckLoadReading | undefined;
|
|
95
|
+
readonly endLoad?: CheckLoadReading | undefined;
|
|
96
96
|
readonly loads?: readonly CheckLoad[] | undefined;
|
|
97
97
|
readonly loadLimit?: number | undefined;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/** The first reading above the limit, or undefined when the check ran idle. */
|
|
101
|
-
function busyLoad(input: LoadInput):
|
|
102
|
-
const readings:
|
|
101
|
+
function busyLoad(input: LoadInput): CheckLoadReading | undefined {
|
|
102
|
+
const readings: CheckLoadReading[] = [];
|
|
103
103
|
for (const run of input.loads ?? []) readings.push(run.start, run.end);
|
|
104
104
|
if (input.startLoad !== undefined) readings.push(input.startLoad);
|
|
105
105
|
if (input.endLoad !== undefined) readings.push(input.endLoad);
|
|
@@ -108,8 +108,8 @@ function busyLoad(input: LoadInput): MachineLoad | undefined {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/** The history and check-log line for a failure skipped as seen under load. */
|
|
111
|
-
function skippedNotice(name: string, load:
|
|
112
|
-
return `flaky test "${name}" skipped: seen
|
|
111
|
+
function skippedNotice(name: string, load: CheckLoadReading): string {
|
|
112
|
+
return `flaky test "${name}" skipped: seen ${underLoad(load)}`;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/** Adds the skip line to the check's own log; a log that cannot be written stays as it is. */
|
|
@@ -143,7 +143,14 @@ function occurrenceOf(value: unknown): FlakyOccurrence | undefined {
|
|
|
143
143
|
if (typeof task !== "string" || typeof at !== "number") return undefined;
|
|
144
144
|
return {
|
|
145
145
|
...(isRecord(load) && typeof load.load1 === "number" && typeof load.cores === "number"
|
|
146
|
-
? {
|
|
146
|
+
? {
|
|
147
|
+
load: {
|
|
148
|
+
load1: load.load1,
|
|
149
|
+
cores: load.cores,
|
|
150
|
+
...(typeof load.host === "string" ? { host: load.host } : {}),
|
|
151
|
+
...(load.unknown === true ? { unknown: true } : {}),
|
|
152
|
+
},
|
|
153
|
+
}
|
|
147
154
|
: {}),
|
|
148
155
|
task,
|
|
149
156
|
at,
|
|
@@ -178,7 +185,16 @@ function writableOf(record: FlakyRecord): Record<string, unknown> {
|
|
|
178
185
|
task: entry.task,
|
|
179
186
|
at: entry.at,
|
|
180
187
|
excerpt: entry.excerpt,
|
|
181
|
-
...(entry.load === undefined
|
|
188
|
+
...(entry.load === undefined
|
|
189
|
+
? {}
|
|
190
|
+
: {
|
|
191
|
+
load: {
|
|
192
|
+
load1: entry.load.load1,
|
|
193
|
+
cores: entry.load.cores,
|
|
194
|
+
...(entry.load.host === undefined ? {} : { host: entry.load.host }),
|
|
195
|
+
...(entry.load.unknown === true ? { unknown: true } : {}),
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
182
198
|
...(entry.file === undefined ? {} : { file: entry.file }),
|
|
183
199
|
...(entry.stress === undefined ? {} : { stress: entry.stress }),
|
|
184
200
|
...(entry.rule === undefined ? {} : { rule: entry.rule }),
|
|
@@ -353,7 +369,7 @@ async function newestConfirmedPlan(
|
|
|
353
369
|
for (const object of await listAll(store, "plan")) {
|
|
354
370
|
const plan = planData(object.data);
|
|
355
371
|
if (plan.repository !== repository || plan.status !== "confirmed") continue;
|
|
356
|
-
const number = parseId(
|
|
372
|
+
const number = parseId(idOfKey(object.id), "plan")?.number ?? -1;
|
|
357
373
|
if (best === undefined || number > best.number) best = { object, number };
|
|
358
374
|
}
|
|
359
375
|
return best?.object;
|
|
@@ -380,7 +396,7 @@ async function flakyPlanFor(
|
|
|
380
396
|
): Promise<{ readonly plan: StoredObject; readonly missing: string | undefined }> {
|
|
381
397
|
let missing: string | undefined;
|
|
382
398
|
if (configured !== undefined) {
|
|
383
|
-
const named = await store.get("plan", `${repository.name}/${
|
|
399
|
+
const named = await store.get("plan", `${repository.name}/${idOfKey(configured)}`);
|
|
384
400
|
if (named !== undefined) {
|
|
385
401
|
const data = planData(named.data);
|
|
386
402
|
if (data.repository === repository.name && !isEnded(data)) {
|
|
@@ -394,13 +410,13 @@ async function flakyPlanFor(
|
|
|
394
410
|
const data = planData(object.data);
|
|
395
411
|
return (
|
|
396
412
|
data.repository === repository.name &&
|
|
397
|
-
parseId(
|
|
413
|
+
parseId(idOfKey(object.id), "plan")?.slug === FLAKY_PLAN_SLUG &&
|
|
398
414
|
!isEnded(data)
|
|
399
415
|
);
|
|
400
416
|
})
|
|
401
417
|
.sort(
|
|
402
418
|
(x, y) =>
|
|
403
|
-
(parseId(
|
|
419
|
+
(parseId(idOfKey(y.id), "plan")?.number ?? -1) - (parseId(idOfKey(x.id), "plan")?.number ?? -1),
|
|
404
420
|
)[0];
|
|
405
421
|
if (own !== undefined) return { plan: own, missing };
|
|
406
422
|
const model = await newestConfirmedPlan(store, repository.name);
|
|
@@ -469,10 +485,10 @@ export interface FlakyInput {
|
|
|
469
485
|
/** The check log, which still holds the first run's output. */
|
|
470
486
|
readonly log: string | undefined;
|
|
471
487
|
/** One load reading for the check, when the caller has only that. */
|
|
472
|
-
readonly load?:
|
|
488
|
+
readonly load?: CheckLoadReading | undefined;
|
|
473
489
|
/** The load at the start and the end of the check, when it is one run. */
|
|
474
|
-
readonly startLoad?:
|
|
475
|
-
readonly endLoad?:
|
|
490
|
+
readonly startLoad?: CheckLoadReading | undefined;
|
|
491
|
+
readonly endLoad?: CheckLoadReading | undefined;
|
|
476
492
|
/** The load at the start and the end of each run of the check. */
|
|
477
493
|
readonly loads?: readonly CheckLoad[] | undefined;
|
|
478
494
|
/** `check.flakyLoadLimit`: the load above which a failure is not a flaky test. */
|
|
@@ -528,7 +544,7 @@ export async function trackFlakyTests(input: FlakyInput): Promise<string | undef
|
|
|
528
544
|
// the count restarts when that task ends, however few passes came before.
|
|
529
545
|
const existing = await namingTask(store, fresh.name, name);
|
|
530
546
|
if (existing !== undefined) {
|
|
531
|
-
record = { ...record, task:
|
|
547
|
+
record = { ...record, task: idOfKey(existing.id) };
|
|
532
548
|
await store.put(FLAKY_TYPE, key, writableOf(record), "dev:flaky-task");
|
|
533
549
|
}
|
|
534
550
|
}
|
|
@@ -579,7 +595,7 @@ async function propose(
|
|
|
579
595
|
await store.put(
|
|
580
596
|
FLAKY_TYPE,
|
|
581
597
|
key,
|
|
582
|
-
writableOf({ ...record, task:
|
|
598
|
+
writableOf({ ...record, task: idOfKey(existing.id) }),
|
|
583
599
|
"dev:flaky-task",
|
|
584
600
|
);
|
|
585
601
|
return undefined;
|
|
@@ -589,7 +605,7 @@ async function propose(
|
|
|
589
605
|
const fallback =
|
|
590
606
|
missing === undefined
|
|
591
607
|
? undefined
|
|
592
|
-
: `check.flakyPlan "${missing}" does not name an open plan of this repository; the task went into "${
|
|
608
|
+
: `check.flakyPlan "${missing}" does not name an open plan of this repository; the task went into "${idOfKey(plan.id)}"`;
|
|
593
609
|
try {
|
|
594
610
|
const task = await addTaskLocked(
|
|
595
611
|
store,
|
|
@@ -605,7 +621,7 @@ async function propose(
|
|
|
605
621
|
await store.put(
|
|
606
622
|
FLAKY_TYPE,
|
|
607
623
|
key,
|
|
608
|
-
writableOf({ ...record, task:
|
|
624
|
+
writableOf({ ...record, task: idOfKey(task.id) }),
|
|
609
625
|
"dev:flaky-task",
|
|
610
626
|
);
|
|
611
627
|
return fallback;
|
|
@@ -652,9 +668,9 @@ export interface FlakyReport {
|
|
|
652
668
|
readonly taskId: string;
|
|
653
669
|
readonly threshold: number;
|
|
654
670
|
readonly flakyPlan?: string | undefined;
|
|
655
|
-
readonly load?:
|
|
656
|
-
readonly startLoad?:
|
|
657
|
-
readonly endLoad?:
|
|
671
|
+
readonly load?: CheckLoadReading | undefined;
|
|
672
|
+
readonly startLoad?: CheckLoadReading | undefined;
|
|
673
|
+
readonly endLoad?: CheckLoadReading | undefined;
|
|
658
674
|
readonly loads?: readonly CheckLoad[] | undefined;
|
|
659
675
|
readonly loadLimit?: number | undefined;
|
|
660
676
|
readonly check: {
|