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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(ci): select client tests for shared script helpers (#13388)
[._.]/ Adam Eivy5313e49cd82c
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.jsindex 421f2dab8a..24394ba102 100644--- a/scripts/ci-test-plan.js+++ b/scripts/ci-test-plan.js@@ -1081,6 +1081,9 @@ function buildSuitePlan(changedFiles, {// Repository-derived browser dependencies; null means discovery failed and// a shared-source change must retain conservative full coverage.clientDependencies = [],+ // Client test → static shared dependencies; null conservatively retains that test.+ // Kept separate from production dependencies so fixtures never force a build.+ clientTestDependencies = {},// Includes literal deferred imports; null means discovery was inconclusive.dbDependencies = [],// Registered suite → reachable files; null retains that suite conservatively.@@ -1239,6 +1242,11 @@ function buildSuitePlan(changedFiles, {...fixtureTests,...structuralTestsFor(changed, trackedSet),...alwaysRun,+ ...Object.entries(clientTestDependencies)+ .filter(([test, dependencies]) => trackedSet.has(test) && runnerForTest(test) === 'client'+ && jsSources.some((source) => isSharedClientDependency(source)+ && (dependencies === null || dependencies.includes(source))))+ .map(([test]) => test),];for (const script of pythonSources) {@@ -1591,6 +1599,10 @@ function createDependencySnapshot(files, cwd) {return { readText, staticDependencies, testDependencies };}+function isSharedClientDependency(path) {+ return path.startsWith('server/lib/') || path.startsWith('scripts/lib/');+}+// Start from every browser source, including lazy-loaded pages, then follow// relative static imports and re-exports across directory boundaries. Unresolved// edges must widen CI rather than disappearing from a negative graph walk.@@ -1691,6 +1703,16 @@ export function collectPlanInputs({ baseSha, forceFull = false, changedFiles, cw? collectClientDependencies(dependencyFiles, snapshot): [];+ // Static imports and re-exports include test fixtures, unlike the production+ // projection. Keep uncertainty per test so one unresolved fixture cannot+ // widen every resolved consumer, and reuse this collection's source snapshot.+ const clientTestDependencies = collectedChangedFiles.some((path) => isSharedClientDependency(path)+ && isExecutable(path) && !isTestFile(path))+ ? Object.fromEntries(dependencyFiles.filter((path) => path.startsWith('client/src/')+ && isTestFile(path)).map((test) => [test,+ collectTestDependencies([test], snapshot.staticDependencies)?.filter(isSharedClientDependency) ?? null]))+ : {};+const hasRelatedServerSource = collectedChangedFiles.some((path) => isServerRunnerFile(path)&& MODULE_SOURCE_RE.test(path) && !isTestFile(path) && !isStructuralBarrel(path));const dbDependencies = hasRelatedServerSource@@ -1748,7 +1770,7 @@ export function collectPlanInputs({ baseSha, forceFull = false, changedFiles, cwconst dockerContainmentLiveInputs = forceFull ? null : collectDockerContainmentLiveInputs(cwd);return { changedFiles: collectedChangedFiles, trackedFiles: presentFiles, appDiff, pathContractTests,- clientDependencies, dbDependencies, browserDependencies, dependencyChanges, promptHistoryInputs, linuxContainmentInputs, supercolliderLiveInputs,+ clientDependencies, clientTestDependencies, dbDependencies, browserDependencies, dependencyChanges, promptHistoryInputs, linuxContainmentInputs, supercolliderLiveInputs,dockerContainmentLiveInputs, serverReach };}@@ -2020,7 +2042,7 @@ function main() {throw new Error('CI_CHANGED_FILES must be a JSON array of repository-relative path strings.');}const {- changedFiles, trackedFiles, appDiff, pathContractTests, clientDependencies, dbDependencies, browserDependencies,+ changedFiles, trackedFiles, appDiff, pathContractTests, clientDependencies, clientTestDependencies, dbDependencies, browserDependencies,dependencyChanges, promptHistoryInputs, linuxContainmentInputs, supercolliderLiveInputs, dockerContainmentLiveInputs, serverReach,} = collectPlanInputs({baseSha: base,@@ -2034,6 +2056,7 @@ function main() {appRouteOnly: isRouteOnlyAppDiff(appDiff),pathContractTests,clientDependencies,+ clientTestDependencies,dbDependencies,browserDependencies,dependencyChanges,diff --git a/scripts/ci-test-plan.test.js b/scripts/ci-test-plan.test.jsindex 3532e6527c..481105ef7a 100644--- a/scripts/ci-test-plan.test.js+++ b/scripts/ci-test-plan.test.js@@ -373,6 +373,45 @@ it('carries transitive browser re-exports through the planner CLI and fails clos}});+it('projects test-only shared re-exports and retains unresolved consumers without selecting a build', () => {+ const root = mkdtempSync(join(tmpdir(), 'portos-ci-client-test-deps-'));+ const planner = fileURLToPath(new URL('./ci-test-plan.js', import.meta.url));+ const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();+ const write = (path, source) => {+ mkdirSync(dirname(join(root, path)), { recursive: true });+ writeFileSync(join(root, path), source);+ };+ const leaf = 'scripts/lib/cleanupLeaf.js';+ const unused = 'scripts/lib/unconsumed.js';+ const consumer = 'client/src/test/lifecycle.test.js';+ const unrelated = 'client/src/test/unrelated.test.js';+ const plan = (source) => JSON.parse(execFileSync(process.execPath, [planner], {+ cwd: root, encoding: 'utf8',+ env: { ...process.env, CI_BASE_SHA: 'HEAD', CI_BASE_REF: 'main', CI_FORCE_FULL: 'false',+ CI_CHANGED_FILES: JSON.stringify([source]), GITHUB_OUTPUT: '', GITHUB_STEP_SUMMARY: '' },+ }));+ try {+ git('init', '-q');+ write(leaf, 'export const value = 1;\n');+ write(unused, 'export const unused = 1;\n');+ write('scripts/lib/cleanupBridge.js', "export { value } from './cleanupLeaf.js';\n");+ write('client/src/test/fixture.js', "export { value } from '../../../scripts/lib/cleanupBridge.js';\n");+ write(consumer, "import './fixture.js';\n");+ write(unrelated, 'export const unrelated = 1;\n');+ git('add', '--all');++ expect(plan(leaf)).toMatchObject({ full: false, build: false,+ client_mode: 'files', client_files: JSON.stringify([consumer]) });+ expect(plan(unused)).toMatchObject({ full: false, build: false, client_mode: 'skip' });++ write('client/src/test/fixture.js', "export { value } from './missing.js';\n");+ expect(plan(leaf)).toMatchObject({ full: false, build: false,+ client_mode: 'files', client_files: JSON.stringify([consumer]) });+ } finally {+ rmSync(root, { recursive: true, force: true });+ }+});+it('resolves local client imports of present untracked modules and still fails closed on missing ones', () => {const root = mkdtempSync(join(tmpdir(), 'portos-ci-untracked-deps-'));const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();diff --git a/scripts/run-ci-tests.test.js b/scripts/run-ci-tests.test.jsindex 0442f2fdb0..0e960a659f 100644--- a/scripts/run-ci-tests.test.js+++ b/scripts/run-ci-tests.test.js@@ -32,6 +32,7 @@ import { destroyGitSandbox, makeGitSandbox } from '../server/lib/gitTestRepo.js'import { readTestProcesses } from './lib/testOwnedProcesses.js';import { OWNER_FILE, STALE_ROOT_AGE_MS, sweepStaleRunRoots } from './lib/vitestStaleRunRoots.js';import { workflowJobs } from './lib/workflowJobs.js';+import { buildCiTestPlan, collectPlanInputs } from './ci-test-plan.js';// Synthetic crash/retry cases must not print a fabricated crash as a real// Actions annotation. Duration/summary tests retain real I/O.@@ -113,6 +114,41 @@ it('hands Vitest the selection as a file, sliced by the runner for the matrix sh}}, 150_000);+it('hands the real client fixture consumers to Vitest for a shared browser cleanup change', () => {+ const fixture = mkdtempSync(join(tmpdir(), 'portos-client-helper-selection-'));+ try {+ installFakeNpm(fixture, REPORTING_NPM);+ const source = 'scripts/lib/ownedBrowserCleanup.js';+ const inputs = collectPlanInputs({ baseSha: 'HEAD', changedFiles: [source], cwd: join(import.meta.dirname, '..') });+ const plan = buildCiTestPlan(inputs.changedFiles, inputs);+ expect(plan.full).toBe(false);+ expect(plan.build).toBe(false);+ expect(plan.server.mode).toBe('related');+ expect(plan.server.sources).toContain(source);+ expect(plan.browserFiles.length).toBeGreaterThan(0);+ expect(plan.client.mode).toBe('files');+ const result = spawnSync(process.execPath, [join(import.meta.dirname, 'run-ci-tests.js'), 'client'], {+ encoding: 'utf8', timeout: 120000,+ env: { ...process.env, PATH: `${fixture}${delimiter}${process.env.PATH}`,+ CI_TEST_MODE: plan.client.mode, CI_SHARD: '', PORTOS_TEST_MEMO: 'off',+ CI_TEST_SOURCES: JSON.stringify(plan.client.sources), CI_TEST_FILES: JSON.stringify(plan.client.files),+ PORTOS_PREGATE_GUARDS: '', GITHUB_ENV: '', GITHUB_STEP_SUMMARY: '' },+ });+ expect(result.error).toBeUndefined();+ expect(result.status, result.stderr).toBe(0);+ const { selection } = JSON.parse(result.stdout.split('\n').find(line => line.startsWith('{"args"')));+ expect(selection.include).toEqual(expect.arrayContaining([+ 'src/test/browserFixture.test.js',+ 'src/components/ThemeSwitcher.browser.test.js',+ 'src/components/goals/GoalsTreeView.browser.test.js',+ 'src/components/ui/OverflowMenu.browser.test.js',+ ]));+ expect(selection.include.sort()).toEqual(plan.client.files.map(file => toWorkspacePath('client', file)).sort());+ } finally {+ rmSync(fixture, { recursive: true, force: true });+ }+}, 150_000);+it('runs the db scope through the server workspace\'s test:db:ci script with the same selection file', () => {const fixture = mkdtempSync(join(tmpdir(), 'portos-db-scope-'));try {