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
60 changes: 51 additions & 9 deletions .github/scripts/compute-ci-gate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ import * as NodeChildProcess from "node:child_process";
import * as NodeFS from "node:fs";
import * as NodeURL from "node:url";

export function needsComputeQualification(paths) {
export function computeQualificationSuites(paths) {
// Only narrow inputs whose consumer is known. Shared runtime code (including
// ManagedPython*.ts imported by PythonComputeRuntime) still selects both.
const kernelOnly = new Set([
"apps/server/src/scient/compute/PythonKernel.integration.test.ts",
"apps/server/src/scient/compute/PythonComputeService.integration.test.ts",
"apps/server/src/scient/compute/FreshCompute.integration.test.ts",
]);
const managedOnly = new Set([
"apps/server/src/scient/compute/ManagedPythonProduct.live.test.ts",
"apps/server/src/scient/compute/ComputeRecipe.live.test.ts",
"apps/server/src/scient/compute/managed-python/pyproject.toml",
"apps/server/src/scient/compute/managed-python/uv.lock",
]);
const exact = new Set([
".github/workflows/ci.yml",
".github/workflows/scient-compute-python-kernel.yml",
".github/scripts/compute-ci-gate.mjs",
".github/scripts/compute-ci-gate.test.mjs",
"scripts/compute-ci-workflows.test.ts",
"apps/server/src/atomicWrite.ts",
"apps/server/src/atomicWrite.test.ts",
"apps/server/scripts/compute-recipes.ts",
Expand All @@ -16,6 +30,9 @@ export function needsComputeQualification(paths) {
"package.json",
"apps/server/package.json",
"apps/server/vite.config.ts",
"vite.config.ts",
"apps/server/src/config.ts",
"apps/server/src/serverSettings.ts",
]);
const prefixes = [
"apps/server/src/scient/compute/",
Expand All @@ -24,10 +41,31 @@ export function needsComputeQualification(paths) {
"apps/server/src/localEndpoints/",
"packages/scient-compute/",
"packages/contracts/src/scientCompute",
"packages/scient-execution/",
"packages/scient-project-init/",
"packages/scient-provider-runtime/",
"packages/shared/src/hostProcess",
"apps/server/src/workspace/",
"apps/server/src/testUtils/",
];
return paths.some(
(path) => exact.has(path) || prefixes.some((prefix) => path.startsWith(prefix)),
);
let realKernel = false;
let managedPython = false;
for (const path of paths) {
if (kernelOnly.has(path) || path.startsWith("apps/server/src/preview/PortScanner")) {
realKernel = true;
} else if (managedOnly.has(path)) {
managedPython = true;
} else if (exact.has(path) || prefixes.some((prefix) => path.startsWith(prefix))) {
realKernel = true;
managedPython = true;
}
}
return { realKernel, managedPython };
}

export function needsComputeQualification(paths) {
const suites = computeQualificationSuites(paths);
return suites.realKernel || suites.managedPython;
}

export function testGatePasses({ workspace, detection, changed, native }) {
Expand Down Expand Up @@ -55,18 +93,22 @@ function detectChanges() {
maxBuffer: 32 * 1024 * 1024,
},
).split("\0");
return needsComputeQualification(paths);
return computeQualificationSuites(paths);
} catch {
console.warn("Could not establish the changed paths; running Compute qualification.");
return true;
return { realKernel: true, managedPython: true };
}
}

if (process.argv[1] && import.meta.url === NodeURL.pathToFileURL(process.argv[1]).href) {
if (process.argv[2] === "detect") {
const changed = detectChanges();
NodeFS.appendFileSync(process.env.GITHUB_OUTPUT, `changed=${changed}\n`);
console.log(`Compute qualification required: ${changed}`);
const suites = detectChanges();
const changed = suites.realKernel || suites.managedPython;
NodeFS.appendFileSync(
process.env.GITHUB_OUTPUT,
`changed=${changed}\nreal_kernel=${suites.realKernel}\nmanaged_python=${suites.managedPython}\n`,
);
console.log("Compute qualification:", suites);
} else if (process.argv[2] === "check") {
const results = {
workspace: process.env.WORKSPACE_RESULT,
Expand Down
128 changes: 121 additions & 7 deletions .github/scripts/compute-ci-gate.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,81 @@ import * as NodeOS from "node:os";
import * as NodePath from "node:path";
import * as NodeURL from "node:url";
import * as NodeTest from "node:test";
import { needsComputeQualification, testGatePasses } from "./compute-ci-gate.mjs";
import {
computeQualificationSuites,
needsComputeQualification,
testGatePasses,
} from "./compute-ci-gate.mjs";

const neither = { realKernel: false, managedPython: false };
const kernel = { realKernel: true, managedPython: false };
const managed = { realKernel: false, managedPython: true };
const both = { realKernel: true, managedPython: true };

NodeTest.test("known suite-specific inputs select only their consumer", () => {
for (const path of [
"apps/server/src/preview/PortScanner.ts",
"apps/server/src/preview/PortScanner.test.ts",
"apps/server/src/preview/PortScannerPythonCompute.integration.test.ts",
"apps/server/src/scient/compute/PythonKernel.integration.test.ts",
"apps/server/src/scient/compute/PythonComputeService.integration.test.ts",
"apps/server/src/scient/compute/FreshCompute.integration.test.ts",
])
NodeAssert.deepEqual(computeQualificationSuites([path]), kernel, path);
for (const path of [
"apps/server/src/scient/compute/ManagedPythonProduct.live.test.ts",
"apps/server/src/scient/compute/ComputeRecipe.live.test.ts",
"apps/server/src/scient/compute/managed-python/pyproject.toml",
"apps/server/src/scient/compute/managed-python/uv.lock",
])
NodeAssert.deepEqual(computeQualificationSuites([path]), managed, path);
});

NodeTest.test("shared runtime, setup and uncertain dependencies retain both suites", () => {
for (const path of [
"apps/server/src/scient/compute/ComputeSessionService.ts",
"apps/server/src/scient/compute/ManagedPythonEnvironment.ts",
"apps/server/src/scient/compute/ManagedPythonProvisioner.ts",
"apps/server/src/scient/compute/ComputeRecipeSource.ts",
"apps/server/src/scient/compute/managed-python/bundled-recipes.json",
"apps/server/src/scient/compute/NewRuntimeDependency.ts",
"apps/server/src/scient/compute/bridge/scient_compute_bridge.py",
"apps/server/src/scient/execution/LocalOwnedProcess.ts",
"apps/server/src/atomicWrite.ts",
"apps/server/src/config.ts",
"apps/server/src/serverSettings.ts",
"apps/server/src/workspace/WorkspacePaths.ts",
"apps/server/src/testUtils/gitConfig.setup.ts",
"packages/scient-execution/src/index.ts",
"packages/scient-project-init/src/index.ts",
"packages/scient-provider-runtime/src/index.ts",
"packages/shared/src/hostProcess.ts",
"vite.config.ts",
"pnpm-lock.yaml",
"apps/server/scripts/compute-recipes.ts",
".github/workflows/ci.yml",
])
NodeAssert.deepEqual(computeQualificationSuites([path]), both, path);
});

NodeTest.test("selection is a union: adding files never removes required coverage", () => {
const paths = [
"README.md",
"apps/server/src/preview/PortScanner.ts",
"apps/server/src/scient/compute/managed-python/uv.lock",
"apps/server/src/scient/compute/PythonComputeRuntime.ts",
];
for (const first of paths)
for (const second of paths) {
const a = computeQualificationSuites([first]);
const b = computeQualificationSuites([second]);
NodeAssert.deepEqual(computeQualificationSuites([first, second]), {
realKernel: a.realKernel || b.realKernel,
managedPython: a.managedPython || b.managedPython,
});
}
NodeAssert.deepEqual(computeQualificationSuites([]), neither);
});

NodeTest.test(
"native inputs, lifecycle dependencies and the gate itself trigger qualification",
Expand Down Expand Up @@ -77,7 +151,12 @@ NodeTest.test("detector handles PRs, pushes, deletions/renames and unresolved co
},
stdio: "pipe",
});
return NodeFS.readFileSync(outputPath, "utf8").trim();
return Object.fromEntries(
NodeFS.readFileSync(outputPath, "utf8")
.trim()
.split("\n")
.map((line) => line.split("=")),
);
};
try {
git("init", "--quiet");
Expand All @@ -88,18 +167,53 @@ NodeTest.test("detector handles PRs, pushes, deletions/renames and unresolved co
git("add", "apps");
git("-c", "core.hooksPath=/dev/null", "commit", "--quiet", "-m", "baseline");
const base = git("rev-parse", "HEAD");
NodeAssert.equal(detect({ before: base }, base), "changed=false");
NodeAssert.deepEqual(detect({ before: base }, base), {
changed: "false",
real_kernel: "false",
managed_python: "false",
});
NodeFS.renameSync(
NodePath.join(directory, "apps/server/src/atomicWrite.ts"),
NodePath.join(directory, "moved.txt"),
);
git("add", "apps", "moved.txt");
git("-c", "core.hooksPath=/dev/null", "commit", "--quiet", "-m", "move out of scope");
const head = git("rev-parse", "HEAD");
NodeAssert.equal(detect({ pull_request: { base: { sha: base } } }, head), "changed=true");
NodeAssert.equal(detect({ before: base }, head), "changed=true");
NodeAssert.equal(detect({ before: "0".repeat(40) }, head), "changed=true");
NodeAssert.equal(detect({}, head), "changed=true");
const all = { changed: "true", real_kernel: "true", managed_python: "true" };
NodeAssert.deepEqual(detect({ pull_request: { base: { sha: base } } }, head), all);
NodeAssert.deepEqual(detect({ before: base }, head), all);
NodeAssert.deepEqual(detect({ before: "0".repeat(40) }, head), all);
NodeAssert.deepEqual(detect({}, head), all);
// A normal PR and a post-merge push select the same relevant suites.
NodeFS.mkdirSync(NodePath.join(directory, "apps/server/src/preview"), { recursive: true });
NodeFS.writeFileSync(
NodePath.join(directory, "apps/server/src/preview/PortScanner.ts"),
"fixture\n",
);
git("add", "apps");
git("-c", "core.hooksPath=/dev/null", "commit", "--quiet", "-m", "scanner change");
const scannerHead = git("rev-parse", "HEAD");
const scanner = { changed: "true", real_kernel: "true", managed_python: "false" };
NodeAssert.deepEqual(detect({ before: head }, scannerHead), scanner);
NodeAssert.deepEqual(detect({ pull_request: { base: { sha: head } } }, scannerHead), scanner);
NodeFS.mkdirSync(NodePath.join(directory, "apps/server/src/scient/compute/managed-python"), {
recursive: true,
});
NodeFS.writeFileSync(
NodePath.join(directory, "apps/server/src/scient/compute/managed-python/uv.lock"),
"fixture\n",
);
git("add", "apps");
git("-c", "core.hooksPath=/dev/null", "commit", "--quiet", "-m", "managed recipe change");
const recipeHead = git("rev-parse", "HEAD");
const recipe = { changed: "true", real_kernel: "false", managed_python: "true" };
NodeAssert.deepEqual(detect({ before: scannerHead }, recipeHead), recipe);
NodeAssert.deepEqual(
detect({ pull_request: { base: { sha: scannerHead } } }, recipeHead),
recipe,
);
// Both changes in the same PR must retain both suites.
NodeAssert.deepEqual(detect({ pull_request: { base: { sha: head } } }, recipeHead), all);
} finally {
NodeFS.rmSync(directory, { recursive: true, force: true });
}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ jobs:
timeout-minutes: 5
outputs:
changed: ${{ steps.detect.outputs.changed }}
real_kernel: ${{ steps.detect.outputs.real_kernel }}
managed_python: ${{ steps.detect.outputs.managed_python }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -146,6 +148,9 @@ jobs:
needs: compute_changes
if: ${{ !cancelled() && needs.compute_changes.outputs.changed != 'false' }}
uses: ./.github/workflows/scient-compute-python-kernel.yml
with:
real_kernel: ${{ needs.compute_changes.outputs.real_kernel != 'false' }}
managed_python: ${{ needs.compute_changes.outputs.managed_python != 'false' }}

# Keep the already-required check name. Native failures must block it, while
# unrelated PRs may skip native qualification only after a successful diff.
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/scient-compute-python-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ name: Scient Compute Python Kernel

on:
workflow_call:
inputs:
real_kernel:
type: boolean
default: true
managed_python:
type: boolean
default: true
workflow_dispatch:
inputs:
real_kernel:
description: Run the real-kernel OS and Python-version matrix
type: boolean
default: true
managed_python:
description: Provision and qualify managed Python toolkits
type: boolean
default: true

permissions:
contents: read
Expand All @@ -24,6 +40,7 @@ concurrency:

jobs:
managed_python:
if: ${{ inputs.managed_python }}
name: Managed Python toolkits / ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
Expand Down Expand Up @@ -68,6 +85,7 @@ jobs:
run: vp test run src/scient/compute/ManagedPythonProduct.live.test.ts src/scient/compute/ComputeRecipe.live.test.ts --maxWorkers=1

real_kernel:
if: ${{ inputs.real_kernel }}
name: Real kernel / ${{ matrix.runner }} / Python ${{ matrix.python }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
Expand Down
23 changes: 18 additions & 5 deletions docs/operations/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,24 @@ revision or working diff and reuse that evidence while the candidate is unchange
can invalidate a result, rerun the affected check; broad shared-runtime, orchestration, packaging,
or test-harness changes normally need wider requalification.
See [ci.yml](../../.github/workflows/ci.yml) for hosted checks.
The required `Test` check includes the native Compute matrix when its inputs
change, including process ownership, atomic persistence, contracts and dependency
locks. Unrelated changes skip that matrix; an unresolved diff runs it. The matrix
also remains manually dispatchable. This uses the existing required check, without
requiring a separate branch-protection setting for path-dependent jobs.
The required `Test` check includes applicable native Compute suites. The selector
in `.github/scripts/compute-ci-gate.mjs` distinguishes these inputs:

- Preview-scanner changes and the real-kernel integration test files run the
Linux/macOS/Windows real-kernel matrix, without provisioning managed toolkits.
- Managed live-test files and the managed `pyproject.toml`/`uv.lock` fixtures run
managed Python qualification, without the system-Python matrix.
- Shared runtime, process ownership, persistence, workspace dependencies, Compute
contracts and test infrastructure run both. `ManagedPython*.ts` is shared too:
the existing-Python runtime imports it even when not provisioning an environment.
- Unrelated UI/docs changes run neither. Mixed changes take the union; uncertain
diffs and JavaScript dependency lockfile changes retain both suites.

Both suites remain enabled by default for reusable callers and manual dispatch;
manual dispatch can also select either suite. Relevant pushes to main retain
post-merge verification of the integrated tree. No cross-revision success cache or
dependency-lock graph is used to skip checks. This uses the existing required
`Test` check without separate branch-protection settings for conditional jobs.
The [manual Windows lane](../../.github/workflows/windows-tests.yml) is available for focused
Windows investigation while that suite is not a required gate.

Expand Down
Loading
Loading