You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "ZenAlexa (via GitHub)" <gi...@apache.org> on 2026/09/02 18:17:54 UTC

[PR] ci: select desktop e2e specs through source reachability [maka]

ZenAlexa opened a new pull request, #4583:
URL: https://github.com/apache/maka/pull/4583

   ## Summary
   
   - Derive each Desktop E2E spec's transitive repository source closure with the existing esbuild resolver.
   - Pass the selected workspace-relative spec paths to Playwright through a quoted Bash array.
   - Run one daily full CI execution for Electron process boundaries, generated sources, and separately bundled entry points.
   - Use Playwright's list reporter to expose individual test durations in every run.
   
   The workflow exits before Xvfb allocation when the changed files reach zero specs. Selection-authority files and full plans run all 36 spec files.
   
   Fixes #4478
   
   ## Measured effect
   
   A replay over the latest 300 first-parent commits found 169 E2E-triggering changes. Test invocations fell from 17,914 to 7,583, a 57.67% reduction. The selection histogram was 57 zero-spec changes, 30 single-spec changes, 10 two-spec changes, one three-spec change, one seven-spec change, and 70 full plans. The scheduled escape run adds one 106-test execution per day.
   
   ## Verification
   
   - Node 24 focused planner, workflow, selector, and Windows closure suites: 82/82 passed
   - Full Desktop E2E: 102 passed, 4 skipped, 6.2 minutes
   - Selected `e2e/sidebar-geometry.spec.ts`: 2/2 passed
   - `npm run format:check`
   - `npm run lint`
   - `npm run build`
   - `npm run typecheck`
   - `npx knip --workspace apps/desktop`
   - `npx knip --workspace packages/ui`
   - `npm run check:asf-headers`
   - `npm run check:release`: 191/191 passed
   - `actionlint .github/workflows/ci.yml`
   - `git diff --check`
   
   The repository-wide `npm test` run reached macOS environment failures in unmodified Runtime sandbox, Runtime Host fixture, and Desktop shell-env suites.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] ci: select desktop e2e specs through source reachability [maka]

Posted by "ZenAlexa (via GitHub)" <gi...@apache.org>.
ZenAlexa commented on PR #4583:
URL: https://github.com/apache/maka/pull/4583#issuecomment-5520751116

   `e2311350` implements #4478 by selecting Desktop e2e specs from each spec's transitive source closure. Full and selection-authority changes continue to select every spec, and a nightly full run preserves broad coverage. The [CI](https://github.com/apache/maka/actions/runs/33666332147) and [Release Windows check](https://github.com/apache/maka/actions/runs/33666331924) suites are ready for approval; approving them will exercise the current head.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] ci: select desktop e2e specs through source reachability [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #4583:
URL: https://github.com/apache/maka/pull/4583#discussion_r3927055965


##########
scripts/desktop-e2e-test-selection.mjs:
##########
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { readdirSync } from 'node:fs';
+import { dirname, relative, resolve, sep } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+import { changedFilesBetween, planTests } from './ci-test-plan.mjs';
+import { collectWorkspaceSourceClosure } from './workspace-source-closure.mjs';
+
+const scriptPath = fileURLToPath(import.meta.url);
+const defaultRepoRoot = dirname(dirname(scriptPath));
+const desktopE2eRoot = 'apps/desktop/e2e';
+
+const SELECTION_AUTHORITY_FILES = new Set([
+  'apps/desktop/e2e/playwright.config.ts',
+  'scripts/desktop-e2e-test-selection.mjs',
+  'scripts/workspace-source-closure.mjs',
+]);
+
+function normalizePath(path) {
+  return path.split(sep).join('/').replace(/^\.\//u, '');
+}
+
+export function listDesktopE2eSpecs(repoRoot = defaultRepoRoot) {
+  const root = resolve(repoRoot, desktopE2eRoot);
+  return readdirSync(root, { recursive: true })
+    .filter((path) => path.endsWith('.spec.ts'))
+    .map((path) => normalizePath(relative(repoRoot, resolve(root, path))))
+    .sort();
+}
+
+export async function collectDesktopE2eSpecClosures(specs, repoRoot = defaultRepoRoot) {
+  const closures = new Map();
+  for (const spec of specs) {
+    closures.set(spec, new Set(await collectWorkspaceSourceClosure([spec], repoRoot)));
+  }
+  return closures;
+}
+
+export async function selectDesktopE2eSpecs(changedFiles, options = {}) {
+  const repoRoot = options.repoRoot ?? defaultRepoRoot;
+  const files = [...new Set(changedFiles.map(normalizePath).filter(Boolean))];
+  const specs = options.specs ?? listDesktopE2eSpecs(repoRoot);
+  const plan = planTests(files, { repoRoot, forceFull: options.forceFull });
+  if (!plan.e2e) return [];
+  if (plan.full || files.some((path) => SELECTION_AUTHORITY_FILES.has(path))) return specs;
+
+  const closures = options.closures ?? (await collectDesktopE2eSpecClosures(specs, repoRoot));
+  return specs.filter((spec) => files.some((path) => closures.get(spec)?.has(path)));

Review Comment:
   P1: This is the whole selection, and the relation it uses is wrong for e2e. A spec imports `./fixtures` and then launches a built Electron app, so the app under test never appears in the spec's static closure. Measured at this head against the files that make the planner set `e2e=true`: `apps/desktop/src/main` 1 of 190 files reach any spec, `src/renderer` 29 of 493, `src/preload` 1 of 16, `src/shared` 1 of 8. Replaying the last 60 first-parent commits, 11 of the 39 e2e-triggering merges select zero specs, including `e1e108a79`, which rewrote `src/renderer/settings/settings-surface.tsx` while `settings.spec.ts` and `settings-row-focus-ring.spec.ts` drive that exact surface. The gate goes green with nothing run and the nightly catches it after merge. The smallest correct fix (adding the desktop main/preload/renderer entry points to every spec's closure) also removes essentially all of the reduction, which is the signal that static import reachability cannot select e2e specs. Selecti
 on needs coverage declared per spec or sampled from an instrumented run.



##########
scripts/desktop-e2e-test-selection.test.mjs:
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import {
+  collectDesktopE2eSpecClosures,
+  listDesktopE2eSpecs,
+  selectDesktopE2eSpecs,
+} from './desktop-e2e-test-selection.mjs';
+
+const specs = ['apps/desktop/e2e/alpha.spec.ts', 'apps/desktop/e2e/beta.spec.ts'];
+const closures = new Map([
+  [specs[0], new Set([specs[0], 'apps/desktop/e2e/fixtures.ts', 'apps/desktop/src/main/a.ts'])],
+  [specs[1], new Set([specs[1], 'apps/desktop/e2e/fixtures.ts', 'apps/desktop/src/main/b.ts'])],
+]);
+
+test('selection follows the exact source closure of each spec', async () => {
+  assert.deepEqual(
+    await selectDesktopE2eSpecs(['apps/desktop/src/main/a.ts'], { specs, closures }),
+    [specs[0]],
+  );
+  assert.deepEqual(
+    await selectDesktopE2eSpecs(['apps/desktop/e2e/fixtures.ts'], { specs, closures }),
+    specs,
+  );
+  assert.deepEqual(
+    await selectDesktopE2eSpecs(['apps/desktop/src/main/unreached.ts'], { specs, closures }),
+    [],
+  );
+});
+
+test('full plans and selection authorities run every spec', async () => {
+  for (const path of [
+    'package-lock.json',
+    'apps/desktop/e2e/playwright.config.ts',
+    'scripts/desktop-e2e-test-selection.mjs',
+    'scripts/workspace-source-closure.mjs',
+  ]) {
+    assert.deepEqual(await selectDesktopE2eSpecs([path], { specs, closures }), specs, path);
+  }
+});
+
+test('non-Electron changes select no Desktop spec', async () => {
+  assert.deepEqual(
+    await selectDesktopE2eSpecs(['packages/runtime/src/runtime.ts'], { specs, closures }),
+    [],
+  );
+});
+
+test('current spec closures select every repository script they import', async () => {
+  const currentSpecs = listDesktopE2eSpecs();
+  const currentClosures = await collectDesktopE2eSpecClosures(currentSpecs);
+
+  assert.ok(currentSpecs.length > 0);
+  for (const spec of currentSpecs) {
+    assert.ok(currentClosures.get(spec)?.has(spec), spec);
+    assert.ok(currentClosures.get(spec)?.has('apps/desktop/e2e/fixtures.ts'), spec);

Review Comment:
   P2: The suite does not test the scenario the PR is for. Three of the four tests use the hand-written `closures` fixture and only prove the filter; this one uses real closures but asserts only `scripts/` reachability and that every spec closure contains `fixtures.ts`. Nothing asserts anything about `apps/desktop/src/**`, which is where the selection actually fails. Add an assertion that every product source file under `apps/desktop/src` selects at least one spec. It fails today, and that failure is the evidence the design needs.



##########
scripts/workspace-source-closure.mjs:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { existsSync, readFileSync } from 'node:fs';
+import { extname, join, relative, resolve, sep } from 'node:path';
+import { build } from 'esbuild';
+
+const defaultRepoRoot = resolve(import.meta.dirname, '..');
+const sourceExtensions = ['.ts', '.tsx', '.mts', '.cts', '.js', '.mjs', '.cjs', '.json'];
+
+/**
+ * Repository sources reachable transitively from `entryPoints`. Workspace
+ * package exports resolve to `src`; external dependencies stay outside the
+ * graph. Callers derive test ownership and path filters from the same imports
+ * the source consumes.
+ *
+ * This closure covers static imports. Spawned processes and generated or
+ * separately bundled entry points need caller-owned escape coverage.

Review Comment:
   P3: The original comment on this function argued why static imports alone were complete for the Windows filter: `root-authority.test.ts` forks a fixture, `worker-entry.ts` is bundled rather than imported, and both are free of `win32`. Generalizing replaced that with "caller-owned escape coverage", and the Windows call site does not restate it, so the argument is now nowhere. Move it back above `windowsPackageSourceEntrypoints`.



##########
scripts/desktop-e2e-test-selection.mjs:
##########
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { readdirSync } from 'node:fs';
+import { dirname, relative, resolve, sep } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+import { changedFilesBetween, planTests } from './ci-test-plan.mjs';
+import { collectWorkspaceSourceClosure } from './workspace-source-closure.mjs';
+
+const scriptPath = fileURLToPath(import.meta.url);
+const defaultRepoRoot = dirname(dirname(scriptPath));
+const desktopE2eRoot = 'apps/desktop/e2e';
+
+const SELECTION_AUTHORITY_FILES = new Set([
+  'apps/desktop/e2e/playwright.config.ts',
+  'scripts/desktop-e2e-test-selection.mjs',
+  'scripts/workspace-source-closure.mjs',
+]);
+
+function normalizePath(path) {
+  return path.split(sep).join('/').replace(/^\.\//u, '');
+}
+
+export function listDesktopE2eSpecs(repoRoot = defaultRepoRoot) {
+  const root = resolve(repoRoot, desktopE2eRoot);
+  return readdirSync(root, { recursive: true })
+    .filter((path) => path.endsWith('.spec.ts'))
+    .map((path) => normalizePath(relative(repoRoot, resolve(root, path))))
+    .sort();
+}
+
+export async function collectDesktopE2eSpecClosures(specs, repoRoot = defaultRepoRoot) {
+  const closures = new Map();
+  for (const spec of specs) {
+    closures.set(spec, new Set(await collectWorkspaceSourceClosure([spec], repoRoot)));
+  }
+  return closures;
+}
+
+export async function selectDesktopE2eSpecs(changedFiles, options = {}) {
+  const repoRoot = options.repoRoot ?? defaultRepoRoot;
+  const files = [...new Set(changedFiles.map(normalizePath).filter(Boolean))];
+  const specs = options.specs ?? listDesktopE2eSpecs(repoRoot);
+  const plan = planTests(files, { repoRoot, forceFull: options.forceFull });
+  if (!plan.e2e) return [];

Review Comment:
   P3: Redundant with the caller. The `Desktop e2e` step is already gated on `steps.plan.outputs.e2e` and already branches on `steps.plan.outputs.full`, so `plan.e2e`, `plan.full` and the second `changedFilesBetween` here recompute a decision the same job made one step earlier. Let the selector take changed files and nothing else.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] ci: select desktop e2e specs through source reachability [maka]

Posted by "ZenAlexa (via GitHub)" <gi...@apache.org>.
ZenAlexa closed pull request #4583: ci: select desktop e2e specs through source reachability
URL: https://github.com/apache/maka/pull/4583


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org