Repository navigation
Expand file tree
/
Copy pathorder-wework-linux-e2e.test.mjs
More file actions
695 lines (675 loc) · 23.1 KB
/
Copy pathorder-wework-linux-e2e.test.mjs
File metadata and controls
695 lines (675 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
import assert from 'node:assert/strict'
import { execFileSync, spawnSync } from 'node:child_process'
import {
chmodSync,
mkdtempSync,
readFileSync,
rmSync,
statSync,
writeFileSync,
} from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import test from 'node:test'
import { expandDesktopCheckpoints } from '../../wework/e2e/desktop/checkpoints.mjs'
import {
LINUX_CORE_HISTORY_CHECKPOINT,
RESOURCE_EXCLUSIVE_CHECKPOINTS,
isResourceExclusiveCheckpoint,
runWithCheckpointResources,
} from '../../wework/e2e/desktop/checkpoint-scheduler.mjs'
import {
balanceLinuxCoreMatrix,
orderLinuxCheckpoints,
} from './order-wework-linux-e2e.mjs'
const root = new URL('../../', import.meta.url)
const measurements = JSON.parse(
readFileSync(
new URL('../ci/wework-linux-checkpoint-durations.json', import.meta.url),
'utf8',
),
)
function readYaml(path) {
return JSON.parse(
execFileSync(
'ruby',
[
'-ryaml',
'-rjson',
'-e',
'puts JSON.generate(YAML.load_file(ARGV[0]))',
path,
],
{ cwd: root, encoding: 'utf8' },
),
)
}
const workflow = readYaml('.github/workflows/wework-e2e.yml')
function classifiedMatrices(
paths,
script = '.github/scripts/classify-wework-desktop-e2e.sh',
) {
const directory = mkdtempSync(join(tmpdir(), 'wework-linux-order-'))
try {
const output = join(directory, 'github-output')
execFileSync('bash', [script, ...(paths ? [] : ['--all'])], {
cwd: root,
env: { ...process.env, GITHUB_OUTPUT: output },
input: paths ? `${paths.join('\n')}\n` : undefined,
})
return Object.fromEntries(
readFileSync(output, 'utf8')
.trim()
.split('\n')
.map((line) => {
const index = line.indexOf('=')
return [line.slice(0, index), line.slice(index + 1)]
}),
)
} finally {
rmSync(directory, { recursive: true, force: true })
}
}
const matrices = classifiedMatrices()
test('the Cloud workflow command accepts populated and empty classifier matrices', () => {
for (const original of [
JSON.parse(matrices.wework_desktop_cloud_e2e_matrix),
{ include: [] },
]) {
const output = execFileSync(
process.execPath,
['.github/scripts/order-wework-linux-e2e.mjs', '--balance-cloud'],
{
cwd: root,
encoding: 'utf8',
env: {
...process.env,
CORE_MATRIX: JSON.stringify(original),
CORE_RUNNER_SCALE: '1.5',
},
},
).trim()
assert.equal(output.startsWith('matrix='), true)
const balanced = JSON.parse(output.slice('matrix='.length))
const selected = (matrix) =>
matrix.include
.flatMap((entry) => expandDesktopCheckpoints(entry.segments.split(',')))
.sort()
assert.deepEqual(selected(balanced), selected(original))
assert(balanced.include.every((entry) => entry.segments.length > 0))
}
})
test('Linux balancing isolates history without changing coverage, runners or exclusive benchmarks', () => {
const original = JSON.parse(matrices.wework_desktop_core_e2e_matrix)
const snapshot = JSON.stringify(original)
const balanced = balanceLinuxCoreMatrix(original)
const cli = execFileSync(
process.execPath,
['.github/scripts/order-wework-linux-e2e.mjs', '--balance-core'],
{
cwd: root,
encoding: 'utf8',
env: { ...process.env, CORE_MATRIX: JSON.stringify(original) },
},
).trim()
assert.equal(cli.startsWith('matrix='), true)
assert.deepEqual(JSON.parse(cli.slice('matrix='.length)), balanced)
assert.equal(JSON.stringify(original), snapshot)
assert.deepEqual(
balanced.include.map((entry) => entry.id),
original.include.map((entry) => entry.id),
)
assert.equal(balanced.include.length, 10)
const expand = (matrix) =>
matrix.include
.flatMap((entry) => expandDesktopCheckpoints(entry.segments.split(',')))
.sort()
assert.deepEqual(expand(balanced), expand(original))
assert.equal(new Set(expand(balanced)).size, expand(original).length)
const historyShard = balanced.include
.find((entry) => entry.id === 'core-6')
.segments.split(',')
assert.deepEqual(historyShard, [LINUX_CORE_HISTORY_CHECKPOINT])
for (const [id, checkpoint] of [
['core-9', 'human-interactions-hidden'],
['core-10', 'collaboration-shared-core'],
]) {
assert.equal(balanced.include.find((entry) => entry.id === id).segments, checkpoint)
}
for (const checkpoint of ['python-runtime', 'plugin-development']) {
const shard = balanced.include.find((entry) => entry.segments.split(',').includes(checkpoint))
assert(!shard.segments.split(',').some((peer) =>
['collaboration-shared-core', 'collaboration-templates', 'collaboration-template-app-device-routing'].includes(peer),
))
}
const alone = {
include: original.include.filter((entry) => entry.id === 'core-6'),
}
assert.deepEqual(balanceLinuxCoreMatrix(alone), alone)
assert.deepEqual(balanceLinuxCoreMatrix({ include: [] }), { include: [] })
assert.deepEqual(balanceLinuxCoreMatrix(balanced), balanced)
const step = workflow.jobs.changes.steps.find(
(step) => step.id === 'linux-matrix',
)
assert.match(step.run, /order-wework-linux-e2e.mjs --balance-core/)
assert.equal(
workflow.jobs.changes.outputs.wework_desktop_core_e2e_matrix,
'${{ steps.linux-matrix.outputs.matrix }}',
)
const windows = workflow.jobs.changes.steps.find(
(step) => step.id === 'windows-matrix',
)
assert.equal(
windows.env.CORE_MATRIX,
'${{ steps.classify.outputs.wework_desktop_core_e2e_matrix }}',
)
})
test('Linux scheduling runs desktop smoke coverage and MinIO setup retains full suites', () => {
for (const path of [
'.github/ci/wework-linux-checkpoint-durations.json',
'.github/scripts/order-wework-linux-e2e.mjs',
'.github/scripts/order-wework-linux-e2e.test.mjs',
]) {
const outputs = classifiedMatrices([path])
assert.deepEqual(
JSON.parse(outputs.wework_desktop_core_e2e_matrix).include.map(({ segments }) => segments),
['release-package-startup,native-lifecycle'],
path,
)
assert.deepEqual(
JSON.parse(outputs.wework_desktop_cloud_e2e_matrix).include.map(({ segments }) => segments),
['plugin-runtime-route-refresh'],
path,
)
const result = classifiedMatrices(
[path],
'.github/scripts/classify-ci-changes.sh',
)
assert.equal(result.wework_e2e, 'true', path)
}
for (const path of [
'.github/actions/setup-minio-e2e/action.yml',
'.github/actions/build-minio-e2e/action.yml',
]) assert.deepEqual(classifiedMatrices([path]), matrices, path)
const helper = classifiedMatrices(['wework/e2e/desktop/modules/shared.mjs'])
const core = JSON.parse(helper.wework_desktop_core_e2e_matrix).include
assert.deepEqual(
core.flatMap(({ segments }) => segments.split(',')).sort(),
['device-artifact-declaration', 'embedded-browser', 'native-lifecycle'],
)
assert.deepEqual(
JSON.parse(helper.wework_desktop_cloud_e2e_matrix).include.map(({ segments }) => segments),
['plugin-runtime-route-refresh'],
)
})
function completionSeconds(checkpoints, seconds) {
const workers = Array(measurements.workers).fill(0)
let exclusiveSeconds = 0
for (const checkpoint of checkpoints) {
assert.ok(seconds[checkpoint] > 0, checkpoint)
if (isResourceExclusiveCheckpoint(checkpoint, true)) {
exclusiveSeconds += seconds[checkpoint]
continue
}
const index = workers.indexOf(Math.min(...workers))
workers[index] += seconds[checkpoint]
}
return exclusiveSeconds + Math.max(...workers)
}
test('assigns parallel work to other runners when history already takes most of the budget', async () => {
const checkpoints = [
'codex-native-catalog',
'collaboration-personal-issues',
'embedded-browser',
'task-board-association',
'stand-in-cloud',
'temporary-chat',
'task-attachments',
'window-lifecycle',
'permission-modes',
'core-task-flow',
'workspace-attachments',
'conversation-state',
'codex-invalid-launch-cwd',
'plugin-development',
'harness-app-lifecycle',
'harness-app-models',
'tray-lifecycle',
]
const history = LINUX_CORE_HISTORY_CHECKPOINT
const matrix = {
include: [
{ id: 'core-1', segments: checkpoints.slice(0, -1).join(',') },
{ id: 'core-2', segments: checkpoints.at(-1) },
{ id: 'core-6', segments: history },
{ id: 'core-9', segments: 'human-interactions-hidden' },
{ id: 'core-10', segments: 'collaboration-shared-core' },
],
}
const seconds = Object.fromEntries(
[...checkpoints, history].map((checkpoint) => [checkpoint, checkpoint === history ? 475 : 100]),
)
const balanced = balanceLinuxCoreMatrix(matrix, seconds)
const tail = balanced.include
.find((entry) => entry.id === 'core-6')
.segments.split(',')
assert.deepEqual(tail, [history])
const peak = (value) =>
Math.max(
...value.include
.slice(0, 3)
.map((entry) =>
completionSeconds(
orderLinuxCheckpoints(entry.segments.split(','), 'core', seconds),
seconds,
),
),
)
assert.equal(peak(balanced), seconds[history])
for (const id of ['core-9', 'core-10'])
assert.deepEqual(
balanced.include.find((entry) => entry.id === id),
matrix.include.find((entry) => entry.id === id),
)
const events = []
await runWithCheckpointResources({
// Prove isolation even when the CLI order is not already history-first.
checkpoints: [checkpoints[0], history],
workerCount: 4,
resourceFor: () => [],
exclusiveFor: (checkpoint) =>
isResourceExclusiveCheckpoint(checkpoint, true),
run: async (checkpoint) => {
events.push(['start', checkpoint])
await new Promise((resolve) => setImmediate(resolve))
events.push(['end', checkpoint])
},
})
assert.deepEqual(events.slice(0, 2), [
['start', history],
['end', history],
])
assert.equal(events.length, 4)
assert(!isResourceExclusiveCheckpoint(history))
for (const checkpoint of RESOURCE_EXCLUSIVE_CHECKPOINTS) {
assert(isResourceExclusiveCheckpoint(checkpoint))
assert(isResourceExclusiveCheckpoint(checkpoint, true))
}
})
test('balancing includes exclusive startup checkpoints before the four-worker queue', () => {
const seconds = {
'plugin-uninstall-lost-response': 60,
'release-package-startup': 100,
'collaboration-issue-task-discovery': 80,
'codex-native-catalog': 80,
'collaboration-personal-issues': 20,
'embedded-browser': 60,
'task-board-association': 100,
'stand-in-cloud': 80,
'temporary-chat': 80,
'task-attachments': 100,
'window-lifecycle': 20,
'permission-modes': 20,
'running-conversation-history': 300,
}
const matrix = {
include: [
{ id: 'core-1', segments: Object.keys(seconds).slice(0, 11).join(',') },
{ id: 'core-2', segments: 'permission-modes' },
{ id: 'core-6', segments: 'running-conversation-history' },
],
}
const balanced = balanceLinuxCoreMatrix(matrix, seconds)
const peak = Math.max(
...balanced.include
.filter((entry) => entry.id !== 'core-6')
.map((entry) =>
completionSeconds(
orderLinuxCheckpoints(entry.segments.split(','), 'core', seconds),
seconds,
),
),
)
assert.equal(peak, 220)
assert.deepEqual(
balanced.include.map((entry) => entry.id),
matrix.include.map((entry) => entry.id),
)
assert.deepEqual(
balanced.include.flatMap((entry) => entry.segments.split(',')).sort(),
Object.keys(seconds).sort(),
)
})
test('balancing distributes the four-worker tail across existing Core runners', () => {
const matrix = {
include: [
{
id: 'core-1',
segments:
'plugin-development,harness-app-lifecycle,harness-app-models,temporary-chat,core-task-flow',
},
{ id: 'core-2', segments: 'codex-native-catalog' },
{ id: 'core-6', segments: 'running-conversation-history' },
],
}
const seconds = Object.fromEntries(
expandDesktopCheckpoints(
matrix.include.flatMap((entry) => entry.segments.split(',')),
).map((name) => [name, name === 'codex-native-catalog' ? 10 : 100]),
)
const balanced = balanceLinuxCoreMatrix(matrix, seconds)
const maximum = (selection) =>
Math.max(
...selection.include
.filter((entry) => entry.id !== 'core-6')
.map((entry) =>
completionSeconds(
orderLinuxCheckpoints(entry.segments.split(','), 'core', seconds),
seconds,
),
),
)
assert.equal(maximum(matrix), 200)
assert.equal(maximum(balanced), 100)
assert.deepEqual(
balanced.include.map((entry) => entry.id),
matrix.include.map((entry) => entry.id),
)
assert.deepEqual(
balanced.include
.flatMap((entry) => expandDesktopCheckpoints(entry.segments.split(',')))
.sort(),
matrix.include
.flatMap((entry) => expandDesktopCheckpoints(entry.segments.split(',')))
.sort(),
)
assert.deepEqual(balanceLinuxCoreMatrix(balanced, seconds), balanced)
})
test('ordering preserves every selected checkpoint in its existing shard and runner budget', () => {
for (const [scope, count] of [
['core', 10],
['cloud', 8],
]) {
const matrix = JSON.parse(matrices[`wework_desktop_${scope}_e2e_matrix`])
assert.equal(matrix.include.length, count)
for (const shard of matrix.include) {
const segments = shard.segments.split(',')
const original = expandDesktopCheckpoints(segments)
const ordered = orderLinuxCheckpoints(segments, scope)
assert.deepEqual([...ordered].sort(), [...original].sort(), shard.id)
assert.equal(new Set(ordered).size, original.length, shard.id)
assert.deepEqual(orderLinuxCheckpoints(segments, scope), ordered)
assert.deepEqual(
segments,
shard.segments.split(','),
'Do not mutate the classifier matrix',
)
}
const job = workflow.jobs[`wework-desktop-${scope}-e2e`]
const run = job.steps.find(
(step) =>
step.name ===
(scope === 'core'
? 'Run Wework desktop Core shard E2E'
: 'Run Wework desktop Cloud E2E checkpoints'),
)
assert.equal(run.env.WEWORK_E2E_PARALLEL_CHECKPOINTS, '4')
assert.match(
run.run,
/WEWORK_E2E_SEGMENTS="\$\(node \.github\/scripts\/order-wework-linux-e2e\.mjs\)"/,
)
assert.match(run.run, /--parallel-segments "\$WEWORK_E2E_SEGMENTS"/)
assert.equal(
job.strategy.matrix,
'${{ fromJSON(needs.changes.outputs.wework_desktop_' +
scope +
'_e2e_matrix) }}',
)
assert.equal(job.strategy['max-parallel'], scope === 'core' ? 17 : 15)
}
const windows = workflow.jobs['wework-desktop-windows-core-e2e']
assert.ok(!JSON.stringify(windows).includes('order-wework-linux-e2e'))
})
test('successful Linux timing replay prioritizes measured tails after new coverage with four workers', () => {
for (const [scope, id, longest] of [
['core', 'core-6', 'running-conversation-history'],
['cloud', 'cloud-3', 'plugin-write-coordination'],
]) {
const matrix = JSON.parse(matrices[`wework_desktop_${scope}_e2e_matrix`])
const shard = matrix.include.find((entry) => entry.id === id)
assert.ok(shard, id)
const segments = shard.segments.split(',')
const ordered = orderLinuxCheckpoints(segments, scope)
const expanded = expandDesktopCheckpoints(segments)
const seconds = measurements.scopes[scope]
const unmeasured = expanded.filter(
(checkpoint) => seconds[checkpoint] === undefined,
)
const measured = expanded.filter(
(checkpoint) => seconds[checkpoint] !== undefined,
)
assert.deepEqual(ordered.slice(0, unmeasured.length), unmeasured)
assert.deepEqual([...ordered].sort(), [...expanded].sort())
const measuredOrder = ordered.slice(unmeasured.length)
assert.equal(measuredOrder[0], longest)
// Historical timing evidence cannot assign a cost to new, unmeasured coverage.
const originalSeconds = completionSeconds(measured, seconds)
const orderedSeconds = completionSeconds(measuredOrder, seconds)
if (originalSeconds === seconds[longest]) {
// Pruned workloads can already reach the longest task's physical lower bound.
assert.equal(orderedSeconds, seconds[longest], id)
} else {
assert.ok(
orderedSeconds < originalSeconds,
`${id}: ${orderedSeconds} < ${originalSeconds}`,
)
}
}
})
test('unmeasured and equal-duration checkpoints retain stable priority without dropping new coverage', () => {
const selected = [
'runtime-task-queue',
'running-conversation-history',
'task-board-association',
'cloud-model-recovery',
]
assert.deepEqual(orderLinuxCheckpoints(selected, 'core', {}), selected)
assert.deepEqual(
orderLinuxCheckpoints(selected, 'core', {
'runtime-task-queue': 20,
'running-conversation-history': 480,
'cloud-model-recovery': 20,
}),
[
'task-board-association',
'running-conversation-history',
'runtime-task-queue',
'cloud-model-recovery',
],
)
assert.deepEqual(orderLinuxCheckpoints([], 'core'), [])
assert.throws(
() => orderLinuxCheckpoints(selected, 'windows'),
/Unknown Linux E2E scope/,
)
assert.throws(
() => orderLinuxCheckpoints(['missing-checkpoint'], 'core'),
/Unknown desktop E2E checkpoint/,
)
assert.throws(
() => orderLinuxCheckpoints(selected, 'core', { 'cloud-model-recovery': 0 }),
/Invalid Linux E2E duration/,
)
})
test('the CI command expands selected groups and fails on invalid input', () => {
const selected = ['stand-in-profile', 'running-conversation-history']
const env = {
...process.env,
WEWORK_E2E_PARALLEL_SCOPE: 'core',
WEWORK_E2E_SEGMENTS: selected.join(','),
}
const result = spawnSync(
process.execPath,
['.github/scripts/order-wework-linux-e2e.mjs'],
{ cwd: root, env, encoding: 'utf8' },
)
assert.equal(result.status, 0, result.stderr)
assert.deepEqual(
result.stdout.trim().split(','),
orderLinuxCheckpoints(selected, 'core'),
)
const invalid = spawnSync(
process.execPath,
['.github/scripts/order-wework-linux-e2e.mjs'],
{ cwd: root, env: { ...env, WEWORK_E2E_SEGMENTS: '' }, encoding: 'utf8' },
)
assert.notEqual(invalid.status, 0)
})
test('MinIO setup uses the shared artifact binary and fails closed when it is missing or unusable', () => {
const action = readYaml('.github/actions/setup-minio-e2e/action.yml')
const steps = action.runs.steps
assert.equal(
steps.length,
2,
'No runner-local Go compiler or dependency cache setup',
)
assert.match(steps[0].uses, /^actions\/download-artifact@/)
const directory = mkdtempSync(join(tmpdir(), 'wework-minio-artifact-'))
try {
const binary = join(directory, 'minio')
const output = join(directory, 'github-env')
const env = {
...process.env,
WEWORK_E2E_MINIO_BIN: binary,
GITHUB_ENV: output,
}
const setup = (values) =>
spawnSync('bash', ['-e', '-o', 'pipefail', '-c', steps[1].run], {
env: values,
encoding: 'utf8',
})
assert.notEqual(setup({ ...env, WEWORK_E2E_MINIO_BIN: '' }).status, 0)
assert.notEqual(setup(env).status, 0)
writeFileSync(binary, '#!/bin/sh\nexit 1\n')
chmodSync(binary, 0o755)
assert.notEqual(setup(env).status, 0)
writeFileSync(binary, '#!/bin/sh\n[ "$1" = "--version" ]\n')
chmodSync(binary, 0o644)
const enabled = setup(env)
assert.equal(enabled.status, 0, enabled.stderr)
assert.equal(
statSync(binary).mode & 0o777,
0o755,
'Artifact downloads must restore execute permissions',
)
assert.equal(
readFileSync(output, 'utf8'),
`WEWORK_E2E_MINIO_BIN=${binary}\n`,
)
} finally {
rmSync(directory, { recursive: true, force: true })
}
const build = readFileSync(
new URL('../actions/build-minio-e2e/action.yml', import.meta.url),
'utf8',
)
assert.match(build, /go-version: "1\.25\.9"/)
assert.match(
build,
/go install github\.com\/minio\/minio@9e49d5e7a648f00e26f2246f4dc28e6b07f8c84a/,
)
})
test('one existing producer builds MinIO for exactly the consumers that need it without GHCR writes', () => {
const producers = Object.entries(workflow.jobs).flatMap(([job, value]) =>
value.steps
.filter((step) => step.uses === './.github/actions/build-minio-e2e')
.map((step) => ({ job, step })),
)
assert.equal(producers.length, 1)
assert.equal(producers[0].job, 'build-wework-desktop-core-e2e')
const required = []
for (const scope of ['core', 'cloud']) {
const consumer = workflow.jobs[`wework-desktop-${scope}-e2e`]
const setup = consumer.steps.find(
(step) => step.uses === './.github/actions/setup-minio-e2e',
)
assert.ok(setup)
assert.ok(consumer.needs.includes(producers[0].job))
for (const match of setup.if.matchAll(
/contains\(matrix.segments, '([^']+)'\)/g,
)) {
required.push({ scope, segment: match[1] })
}
}
assert.equal(required.length, 7)
assert.ok(
required.some(
({ scope, segment }) =>
scope === 'cloud' && segment === 'plugin-package-integrity-recovery',
),
)
const evaluate = new Function(
'needs',
'contains',
`return ${producers[0].step.if}`,
)
for (const selection of [
...required,
{ scope: 'core', segment: 'task-attachments' },
null,
]) {
const outputs = Object.fromEntries(
['core', 'cloud'].map((scope) => [
`wework_desktop_${scope}_e2e_matrix`,
JSON.stringify({
include:
selection?.scope === scope ? [{ segments: selection.segment }] : [],
}),
]),
)
assert.equal(
evaluate({ changes: { outputs } }, (source, value) =>
source.includes(value),
),
required.includes(selection),
)
}
const build = readYaml('.github/actions/build-minio-e2e/action.yml').runs
.steps
assert.ok(build.every((step) => !step.uses?.startsWith('docker/')))
assert.equal(
build.find((step) => step.name === 'Set up Go for real object storage')
.with['go-version'],
'1.25.9',
)
const upload = build.find((step) =>
step.uses?.startsWith('actions/upload-artifact@'),
)
const download = readYaml('.github/actions/setup-minio-e2e/action.yml').runs
.steps[0]
assert.equal(upload.with.name, download.with.name)
assert.equal(upload.with['if-no-files-found'], 'error')
assert.equal(upload.with.path, '${{ runner.temp }}/wework-minio/bin/minio')
assert.equal(download.with.path, '${{ runner.temp }}/wework-minio/bin')
})
test('timing evidence and scheduling regression tests are bound to CI', () => {
assert.match(
measurements.run,
/^https:\/\/github.com\/wecode-ai\/Wegent\/actions\/runs\/\d+$/,
)
assert.match(measurements.headSha, /^[a-f0-9]{40}$/)
assert.equal(measurements.workers, 4)
for (const seconds of Object.values(measurements.scopes).flatMap((scope) =>
Object.values(scope),
)) {
assert.ok(Number.isFinite(seconds) && seconds > 0)
}
const lint = readFileSync(
new URL('../workflows/lint.yml', import.meta.url),
'utf8',
)
assert.match(
lint,
/node --test .*\.github\/scripts\/order-wework-linux-e2e\.test\.mjs/,
)
})