Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ jobs:
with:
node-version: '22'
# The ls guard is not decoration: node --test treats a pattern that matches no file as zero
# tests and exits 0 (measured on Node 24.22), so without it this step would go green if the
# script tests ever disappeared.
- run: ls .github/scripts/*.test.mjs > /dev/null && node --test tests/*.test.mjs .github/scripts/*.test.mjs manager/compose-planner/compose-command-planner.test.js
# tests and exits 0 (measured on Node 24.22 and 22.23.5), so every input is listed before the
# run. A rename or a move of any of the three now fails this step instead of passing with no
# tests at all.
- run: |
ls tests/*.test.mjs .github/scripts/*.test.mjs manager/compose-planner/compose-command-planner.test.js > /dev/null
node --test tests/*.test.mjs .github/scripts/*.test.mjs manager/compose-planner/compose-command-planner.test.js

management:
name: Management API · Python ${{ matrix.python }}
Expand Down
25 changes: 21 additions & 4 deletions tests/ci_test_list.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@ import test from 'node:test';

const workflow = readFileSync(new URL('../.github/workflows/tests.yml', import.meta.url), 'utf8');

test('CI runs all web tests, the script tests and the compose planner in one test invocation', () => {
assert.match(
workflow,
/^ {6}- run: ls \.github\/scripts\/\*\.test\.mjs > \/dev\/null && node --test tests\/\*\.test\.mjs \.github\/scripts\/\*\.test\.mjs manager\/compose-planner\/compose-command-planner\.test\.js$/m,
test('CI lists every node --test input before running it', () => {
// node --test exits 0 when a pattern matches no file, so a renamed or moved suite would
// otherwise turn this step green with zero tests. The two lines must list exactly the same
// inputs: an input missing from the guard is unguarded, and an input missing from the run line
// is coverage that silently stopped running.
const block = workflow.match(/^ {6}- run: \|\n((?: {10}.*\n)+)/m);
assert.ok(block, 'the frontend test step must be a block scalar');
const lines = block[1].split('\n').filter(Boolean);
assert.ok(lines.length >= 2, 'the block must hold an ls guard and a node --test line');
const guardIndex = lines.findIndex((line) => /^\s*ls\s/.test(line));
const runIndex = lines.findIndex((line) => /\bnode --test\b/.test(line));
assert.ok(guardIndex !== -1, 'the block must guard its inputs with ls');
assert.ok(runIndex !== -1, 'the block must run node --test');
assert.ok(guardIndex < runIndex, 'the ls guard must come before node --test');
const guardArgs = lines[guardIndex].replace(/^\s*ls\s+/, '').replace(/\s*>\s*\/dev\/null$/, '').trim().split(/\s+/);
const runArgs = lines[runIndex].replace(/^\s*node --test\s+/, '').trim().split(/\s+/);
assert.ok(runArgs.length > 0);
assert.deepEqual(
[...guardArgs].sort(),
[...runArgs].sort(),
'the ls guard must list exactly the inputs on the node --test line',
);
});

Expand Down
Loading