Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: forward CI shards to related test invocations

[._.]/ Adam Eivy0d07de597985
diff --git a/scripts/run-ci-tests.js b/scripts/run-ci-tests.js
index 057bc9fe16..bea35592fa 100644
--- a/scripts/run-ci-tests.js
+++ b/scripts/run-ci-tests.js
@@ -113,7 +113,7 @@ export function relatedInputs(sourceFiles, selectedFiles) {
}
/**
- * Vitest selector flags for this runner's slice of a full suite. `CI_SHARD` is
+ * Vitest selector flags for this runner's slice of the selected suite. `CI_SHARD` is
* `<index>/<count>` from the job matrix (ci.yml). A single shard passes nothing,
* so the one-runner invocation stays identical to a local `npm run test:ci`.
*/
@@ -377,7 +377,7 @@ async function main() {
process.exitCode = await spawnNpm(
scope,
'test:ci:related',
- relatedInputs(sourceFiles, selectedFiles),
+ [...relatedInputs(sourceFiles, selectedFiles), ...shardArgs(process.env.CI_SHARD)],
'related and contract tests',
);
}
diff --git a/scripts/run-ci-tests.test.js b/scripts/run-ci-tests.test.js
index fd43bdec2b..1b772c7c4b 100644
--- a/scripts/run-ci-tests.test.js
+++ b/scripts/run-ci-tests.test.js
@@ -1,7 +1,7 @@
import { spawn, spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, utimesSync, writeFileSync } from 'fs';
import { tmpdir } from 'os';
-import { join } from 'path';
+import { delimiter, join } from 'path';
import { stripVTControlCharacters } from 'node:util';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -50,6 +50,32 @@ describe('shardArgs', () => {
});
});
+it('forwards the related matrix slice and all selectors through the real launcher', () => {
+ const fixture = mkdtempSync(join(tmpdir(), 'portos-related-shard-'));
+ try {
+ const npmScript = join(fixture, 'npm.js');
+ writeFileSync(npmScript, 'process.stdout.write(JSON.stringify(process.argv.slice(2)) + "\\n");');
+ writeFileSync(join(fixture, 'npm'), `#!${process.execPath}\n`
+ + 'process.stdout.write(JSON.stringify(process.argv.slice(2)) + "\\n");', { mode: 0o755 });
+ writeFileSync(join(fixture, 'npm.cmd'), `@"${process.execPath}" "${npmScript}" %*\r\n`);
+ const result = spawnSync(process.execPath, [join(import.meta.dirname, 'run-ci-tests.js'), 'server'], {
+ encoding: 'utf8', timeout: 30000,
+ env: { ...process.env, PATH: `${fixture}${delimiter}${process.env.PATH}`,
+ CI_TEST_MODE: 'related', CI_SHARD: '2/3',
+ CI_TEST_SOURCES: JSON.stringify(['server/lib/example.js']),
+ CI_TEST_FILES: JSON.stringify(['server/lib/example.test.js', 'scripts/example.test.js']),
+ GITHUB_ENV: '', GITHUB_STEP_SUMMARY: '' },
+ });
+ expect(result.error).toBeUndefined();
+ expect(result.status, result.stderr).toBe(0);
+ const args = JSON.parse(result.stdout.split('\n').find(line => line.startsWith('["run"')));
+ expect(args.slice(0, 9)).toEqual(['run', 'test:ci:related', '--prefix', 'server', '--',
+ './lib/example.js', './lib/example.test.js', '../scripts/example.test.js', '--shard=2/3']);
+ } finally {
+ rmSync(fixture, { recursive: true, force: true });
+ }
+});
+
describe('ci.yml shard wiring', () => {
const runners = Object.entries(workflowJobs(WORKFLOW)).filter(([, body]) => body.includes('run-ci-tests.js'));