diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6709c8d9f46..27038159534 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,7 +173,7 @@ jobs: # backend and frontend variants that pull requests narrow celox to. - name: Check CI runtime dependency exclusions and test scopes if: needs.changes.result == 'success' && needs.changes.outputs.rust == 'true' && needs.changes.outputs.scripts != 'true' - run: node --test scripts/ci-changes.test.mjs scripts/ci-rust-scope.test.mjs + run: node --test scripts/ci-changes.test.mjs scripts/ci-rust-scope.test.mjs scripts/ci-lydite-changes.test.mjs rust-tests: name: Rust Tests @@ -198,10 +198,6 @@ jobs: - name: Install cocotb run: python -m pip install cocotb==2.1.0 - # Z3 5.1.0 is lydite's recorded compatibility-test version. - - name: Install Z3 for lydite solver tests - run: python -m pip install z3-solver==5.1.0 - - name: Install cargo-nextest uses: taiki-e/install-action@v2 with: @@ -213,12 +209,11 @@ jobs: # runs the binaries one after another. # A pull request builds and runs only the tests its changes can affect # (scripts/ci-rust-scope.mjs); merge groups and the daily run keep the - # whole workspace, so the tree that lands is still fully tested. + # Celox workspace. lydite.yml owns Lydite tests at its own cadence. - name: Run workspace tests with CI features if: needs.changes.outputs.rust_full != 'false' run: >- - Z3_BIN="$(command -v z3)" - cargo nextest run --locked --workspace --profile ci + cargo nextest run --locked --workspace --exclude 'lydite*' --profile ci --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus - name: Run the tests this pull request can affect @@ -233,14 +228,14 @@ jobs: args=() for package in $PACKAGES; do args+=(-p "$package"); done if [ -n "$FEATURES" ]; then args+=(--features "$FEATURES"); fi - Z3_BIN="$(command -v z3)" cargo nextest run --locked --profile ci \ + cargo nextest run --locked --profile ci \ --no-tests=pass "${args[@]}" -E "$FILTER" # nextest does not run documentation tests. - name: Run workspace documentation tests with CI features if: needs.changes.outputs.rust_full != 'false' run: >- - cargo test --locked --workspace --doc + cargo test --locked --workspace --exclude 'lydite*' --doc --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus - name: Run the documentation tests of the changed libraries diff --git a/.github/workflows/lydite.yml b/.github/workflows/lydite.yml index e3d0494f59d..13e3296ffad 100644 --- a/.github/workflows/lydite.yml +++ b/.github/workflows/lydite.yml @@ -2,36 +2,12 @@ name: lydite # Proof, editor, and pinned-Celox conformance gates imported from # https://github.com/tignear/hwverify. The workspace crates are also built, -# linted, and unit-tested by ci.yml; this workflow runs lydite's own gates. +# linted by ci.yml; this workflow owns Lydite tests and conformance gates. on: - # Queue drafts run editor/replay checks on combined changes. Ordinary PRs - # skip all jobs; the expensive Veryl proof gates run only weekly or manually. - push: - branches: [develop] - paths: - - "crates/lydite*/**" - - "lydite/**" - - ".github/workflows/lydite.yml" - # The proof-backed suite gate tests the in-tree frontend and suite. - - "crates/celox-test-suite*/**" - - "crates/celox-frontend-veryl/**" - - "crates/celox-frontend-core/**" - - "crates/celox-sir/**" - - "crates/celox-design/**" + # Select affected lanes on changes; run every lane weekly and on demand. pull_request: - paths: - - "crates/lydite*/**" - - "lydite/**" - - ".github/workflows/lydite.yml" - # The proof-backed suite gate tests the in-tree frontend and suite. - - "crates/celox-test-suite*/**" - - "crates/celox-frontend-veryl/**" - - "crates/celox-frontend-core/**" - - "crates/celox-sir/**" - - "crates/celox-design/**" - # Dependency, toolchain and other Celox updates are covered by ci.yml's - # lydite unit tests; run the full gates weekly to catch slower drift. + merge_group: schedule: - cron: "41 3 * * 1" workflow_dispatch: @@ -55,8 +31,64 @@ defaults: working-directory: lydite jobs: + changes: + runs-on: ubuntu-26.04 + outputs: + core: ${{ steps.scope.outputs.core }} + bridge: ${{ steps.scope.outputs.bridge }} + defaults: + run: + working-directory: . + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + - name: Select affected Lydite lanes + id: scope + env: + BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }} + RUSTUP_TOOLCHAIN: stable + run: node scripts/ci-lydite-changes.mjs "$BASE_SHA" "$HEAD_SHA" + + rust: + timeout-minutes: 30 + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.core == 'true' || needs.changes.outputs.bridge == 'true') + runs-on: ubuntu-26.04 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + submodules: recursive + - uses: ./.github/actions/setup-rust + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-python@v7 + with: + python-version: "3.12" + - name: Install recorded solver version + run: python -m pip install z3-solver==5.1.0 + - name: Test affected Lydite packages and documentation + env: + CORE: ${{ needs.changes.outputs.core }} + BRIDGE: ${{ needs.changes.outputs.bridge }} + DETECTION: ${{ needs.changes.result }} + run: | + args=() + if [ "$DETECTION" != success ] || [ "$CORE" = true ]; then + args+=(-p lydite -p lydite-ir -p lydite-solver -p lydite-syntax -p lydite-verify) + fi + if [ "$DETECTION" != success ] || [ "$BRIDGE" = true ]; then + args+=(-p lydite-celox) + fi + Z3_BIN="$(command -v z3)" + export Z3_BIN + cargo test --locked "${args[@]}" + documentation: - if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.core == 'true') runs-on: ubuntu-26.04 steps: - uses: actions/checkout@v7 @@ -66,7 +98,8 @@ jobs: run: python3 scripts/check_docs.py editor: - if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.core == 'true') runs-on: ubuntu-26.04 timeout-minutes: 20 steps: @@ -99,7 +132,8 @@ jobs: # celox-replay and veryl-proof use the in-tree Celox; the narrow veryl gate # checks lydite's own Veryl lowering against a pinned upstream corpus. celox-replay: - if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/') + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.bridge == 'true') runs-on: ubuntu-26.04 timeout-minutes: 30 steps: @@ -121,7 +155,8 @@ jobs: retention-days: 14 veryl-fv: - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.core == 'true') runs-on: ubuntu-26.04 timeout-minutes: 30 steps: @@ -147,7 +182,8 @@ jobs: retention-days: 14 veryl-proof-corpus: - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + needs: changes + if: always() && (needs.changes.result != 'success' || needs.changes.outputs.bridge == 'true') runs-on: ubuntu-26.04 # Cold builds plus the sequential proof/mutation gates can exceed one hour. timeout-minutes: 120 @@ -201,3 +237,27 @@ jobs: ${{ runner.temp }}/lemma-candidates/ if-no-files-found: error retention-days: 14 + + result: + name: Lydite checks + needs: [changes, rust, documentation, editor, celox-replay, veryl-fv, veryl-proof-corpus] + if: always() + runs-on: ubuntu-26.04 + defaults: + run: + working-directory: . + steps: + - name: Require every selected lane to pass + env: + NEEDS: ${{ toJSON(needs) }} + run: | + python3 - <<'PYCODE' + import json, os + needs = json.loads(os.environ["NEEDS"]) + assert needs["changes"]["result"] == "success", needs + assert all(needs["changes"]["outputs"].get(key) in ("true", "false") for key in ("core", "bridge")), needs + for job, lane in {"rust": None, "documentation": "core", "editor": "core", "celox-replay": "bridge", "veryl-fv": "core", "veryl-proof-corpus": "bridge"}.items(): + outputs = needs["changes"]["outputs"] + selected = outputs.get(lane) == "true" if lane else any(outputs.get(key) == "true" for key in ("core", "bridge")) + assert needs[job]["result"] == ("success" if selected else "skipped"), (job, needs[job]) + PYCODE diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2cee2e5ed9d..c17b52d7f05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,7 +114,7 @@ mixed Rust changes and unknown paths retain their existing coverage. Pull requests use `scripts/ci-changes.mjs` to select jobs and scope Rust tests by affected crates. Windows and ARM64 checks run in Mergify queue draft PRs, -legacy merge groups, and daily/manual full runs. Queue drafts run the full Rust +legacy merge groups, and daily/manual full runs. Queue drafts run the full Celox Rust workspace when Rust is affected. Mergify checks up to five batches concurrently across three queue rules. Parallel mode separates independent file scopes while retaining combined-tree validation for overlapping scopes: @@ -151,11 +151,8 @@ This does not prioritize jobs inside GitHub Actions or preempt occupied runners. See [Mergify priorities](https://docs.mergify.com/merge-queue/priority/) and [Mergify queue modes](https://docs.mergify.com/merge-queue/queue-modes/). -The separate lydite documentation, editor, and Celox replay checks run on queue -drafts rather than ordinary PRs; develop pushes, weekly runs, and manual dispatch -remain enabled. The expensive `veryl-fv` and `veryl-proof-corpus` jobs run only -weekly (Monday at 03:41 UTC / 12:41 JST) or on manual dispatch, never on queue -drafts or develop pushes. These separate lydite checks are not merge requirements. +Lydite tests use the independent change-selected and weekly cadence described +below, including on Mergify queue draft PRs. The `Queue validation` merge condition requires the selected checks in `ci.yml` to pass; ordinary PR checks cannot satisfy it. The `ci:full` label opts a PR into the same coverage on its next push. Unrelated paths may still skip jobs. @@ -198,20 +195,37 @@ Job selection: required check. Only explicitly unneeded producers may be skipped; failures and cancellations fail the check. +Lydite has its own test cadence (`scripts/ci-lydite-changes.mjs`): + +- Lydite sources and fixtures run its core and bridge lanes. The core lane owns + the proof-engine Rust tests, editor and standalone Veryl conformance. +- Celox changes run only the bridge lane when Cargo's dependency graph reaches + `lydite-celox`. This includes replay and proof-backed Veryl/symbolic corpus + gates, which use the in-tree exporter. Upstream private tests and Markdown + do not trigger consumer checks. NAPI/JS changes do not reach Lydite. +- Shared dependency/toolchain configuration and an unreadable diff or dependency + graph run both lanes. The graph includes optional, build and dev edges. +- Ordinary `ci.yml` tests exclude `lydite*`, including daily and release runs; + formatting/lint/build checks remain there. The dedicated workflow tests the + selected Lydite packages, including doctests, and installs its solver. +- `Lydite checks` accepts skipped lanes only when change detection explicitly + excludes them, and fails on selected-job failures or cancellations. Repository + branch protection must require this check to make it a merge gate. + The classifier selects CI jobs, not individual Rust tests. Selected Rust CI -still runs the full workspace suite with CI features, doctests, default-feature +still runs the Celox workspace suite with CI features, doctests, default-feature checks, ARM64 backend checks, and the explicit cocotb test. Local validation uses the finer behavior-based matrix above. | Cadence | Coverage | | --- | --- | -| Daily at 01:17 UTC (10:17 JST) | Full `ci.yml` on the default branch, with every change-classifier output enabled. Includes native/WASI NAPI, JS/browser tests, ARM64, script tests, and all ordinary workspace tests. | +| Daily at 01:17 UTC (10:17 JST) | Full `ci.yml` on the default branch, with every change-classifier output enabled. Includes native/WASI NAPI, JS/browser tests, ARM64, script tests, and all ordinary Celox workspace tests. | | Daily from `nightly.yml` at 02:43 UTC (11:43 JST) | Dispatch the same full CI on `develop`, with detection of its Veryl dependency lane. Queue nightly packages and the small pinned/HEAD Heliodor Linux boot compatibility checks. | | Daily at 01:47 UTC (10:47 JST) | `bench.yml` measures Rust, Verilator, and TypeScript on one host and publishes master history. Manual dispatch supports branch measurements. | | Daily at 02:17 UTC (11:17 JST) | `codspeed.yml` measures compile time on the default branch using CPU simulation. Execution failures and CodSpeed performance-check failures open or update a branch issue; the next healthy run closes it. Manual dispatch supports branch measurements. PRs, merge groups, and pushes do not run CodSpeed. | | Daily at 02:37 UTC (11:37 JST) | `heliodor-bench.yml` runs the complete master Linux suite on x86-64 and AArch64. Explicit manual selections retain focused suite runs and ARM64 profiling. PRs run only the benchmark tooling tests when those files change. | | Every full CI run | Run every shared Veryl and SystemVerilog case against both Verilator and Icarus, with locked Nix tools. Run the live adapter tests normally marked ignored because they need external tools. Preserve reports and per-case diagnostics as artifacts for 14 days, including on failure; matrix failures do not cancel the other comparisons. | -| Weekly Monday at 03:41 UTC (12:41 JST), or manual dispatch | All `lydite.yml` checks, including Veryl formal verification and proof/mutation corpus gates. The two Veryl jobs run only at this cadence; documentation, editor, and Celox replay checks also run on queue drafts and develop pushes with relevant changes. | +| Affected pull requests and merge groups; weekly Monday at 03:41 UTC (12:41 JST); on demand | `lydite.yml` owns Lydite Rust tests, proof, conformance, editor, and mutation gates. Unrelated changes skip these jobs. Weekly and manual runs enable all lanes. | | On demand | Dispatch `ci.yml` on the desired branch to run full CI and external comparisons, regardless of its diff. | | Pull requests that cut a release | A `master` pull request or legacy merge group whose diff changes `.release-please-manifest.json` (only the release pull request does there; syncing it into `develop` is not a release) runs full CI and the external comparisons. `Rust Test & NAPI Build` then requires the comparisons to pass, so a release cannot merge after only change-based checks. Daily and manual full runs do not gate on the comparisons; their failures reach the full CI issue below. A `master` pull request or legacy merge group whose diff cannot be determined is treated the same way. | diff --git a/scripts/ci-changes.mjs b/scripts/ci-changes.mjs index b0033cf280e..9200c7aaa87 100644 --- a/scripts/ci-changes.mjs +++ b/scripts/ci-changes.mjs @@ -288,14 +288,22 @@ if ( }); } -// Queue drafts, legacy merge groups, releases and daily runs keep -// the whole workspace. The scope helper remains available outside queue CI. +// Lydite tests are selected independently by lydite.yml, including its bridge. +export function celoxRustTestScope(files, packages) { + return rustTestScope( + files.filter((path) => !/^(?:\.\/)?(?:lydite\/|crates\/lydite(?:-|\/))/.test(path)), + packages.filter((pkg) => !/^lydite(?:-|$)/.test(pkg.name)), + ); +} + +// Queue drafts, merge groups, releases and daily runs keep the Celox +// workspace. Lydite tests run independently in lydite.yml. function rustScopeOutputs(files) { let scope = { full: true }; if (files !== null) { try { const root = fileURLToPath(new URL("../", import.meta.url)); - scope = rustTestScope(files, readWorkspace(root)); + scope = celoxRustTestScope(files, readWorkspace(root)); } catch (error) { console.warn(`Unable to scope the Rust tests: ${error.message}`); } diff --git a/scripts/ci-lydite-changes.mjs b/scripts/ci-lydite-changes.mjs new file mode 100644 index 00000000000..3ca350fab53 --- /dev/null +++ b/scripts/ci-lydite-changes.mjs @@ -0,0 +1,110 @@ +import { appendFileSync } from "node:fs"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { changedFilesBetween, readWorkspace } from "./ci-rust-scope.mjs"; + +export const isLydite = (name) => + name === "lydite" || name.startsWith("lydite-"); +const all = () => ({ core: true, bridge: true }); + +// Follow actual Cargo edges, including optional, build and dev dependencies. +// Celox consumes none of the proof engine; only lydite-celox consumes Celox. +export function lyditeScope(files, packages) { + if (files === null) return all(); + const byName = new Map(packages.map((pkg) => [pkg.name, pkg])); + const closure = (roots) => { + const seen = new Set(roots); + const queue = [...roots]; + while (queue.length) { + for (const dep of byName.get(queue.pop())?.dependencies ?? []) { + if (!seen.has(dep)) { + seen.add(dep); + queue.push(dep); + } + } + } + return seen; + }; + const core = closure( + packages + .filter((p) => isLydite(p.name) && p.name !== "lydite-celox") + .map((p) => p.name), + ); + const bridge = closure(["lydite-celox"]); + const result = { core: false, bridge: false }; + const owners = [...packages].sort((a, b) => b.dir.length - a.dir.length); + for (const raw of files) { + const path = raw.replace(/^\.\//, ""); + if ( + path.startsWith("lydite/") || + (path.startsWith("crates/lydite") && + !path.startsWith("crates/lydite-celox/")) + ) + return all(); + if ( + [ + "Cargo.toml", + "Cargo.lock", + "rust-toolchain.toml", + "flake.nix", + "flake.lock", + ".github/workflows/lydite.yml", + ".github/workflows/ci.yml", + ".config/nextest.toml", + ].includes(path) || + [ + ".cargo/", + ".github/actions/setup-rust/", + "scripts/ci-lydite-changes.", + "scripts/ci-rust-scope.", + "scripts/ci-changes.", + ].some((prefix) => path.startsWith(prefix)) + ) + return all(); + const owner = owners.find((pkg) => path.startsWith(`${pkg.dir}/`)); + if (owner) { + const inner = path.slice(owner.dir.length + 1); + // Consumer tests do not depend on an upstream crate's private tests/docs. + if ( + !isLydite(owner.name) && + (/^(tests|benches|examples)\//.test(inner) || inner.endsWith(".md")) + ) + continue; + result.core ||= core.has(owner.name); + result.bridge ||= bridge.has(owner.name); + } else if ( + ["crates/", "vendor/", "testdata/", "conformance/"].some((prefix) => + path.startsWith(prefix), + ) || + /Cargo\.(toml|lock)$/.test(path) + ) { + // Unmapped source or dependency changes cannot silently bypass checks. + return all(); + } + } + return result; +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + let scope = all(); + if ( + !["schedule", "workflow_dispatch"].includes(process.env.GITHUB_EVENT_NAME) + ) { + try { + scope = lyditeScope( + changedFilesBetween(process.argv[2] ?? "", process.argv[3] ?? ""), + readWorkspace(fileURLToPath(new URL("../", import.meta.url))), + ); + } catch (error) { + console.warn(`Unable to scope Lydite checks: ${error.message}`); + } + } + const output = Object.entries(scope) + .map(([key, value]) => `${key}=${value}`) + .join("\n"); + console.log(output); + if (process.env.GITHUB_OUTPUT) + appendFileSync(process.env.GITHUB_OUTPUT, `${output}\n`); +} diff --git a/scripts/ci-lydite-changes.test.mjs b/scripts/ci-lydite-changes.test.mjs new file mode 100644 index 00000000000..c1f54076dbb --- /dev/null +++ b/scripts/ci-lydite-changes.test.mjs @@ -0,0 +1,200 @@ +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; +import { lyditeScope, isLydite } from "./ci-lydite-changes.mjs"; +import { celoxRustTestScope } from "./ci-changes.mjs"; +import { readWorkspace } from "./ci-rust-scope.mjs"; +const root = fileURLToPath(new URL("../", import.meta.url)); +const packages = readWorkspace(root); +const scope = (...files) => lyditeScope(files, packages); +const both = { core: true, bridge: true }; +const neither = { core: false, bridge: false }; + +test("Lydite core changes and shared configuration run both lanes", () => { + for (const path of [ + "crates/lydite/src/main.rs", + "crates/lydite-ir/src/lib.rs", + "lydite/editor/server.py", + "Cargo.lock", + "Cargo.toml", + "rust-toolchain.toml", + "flake.lock", + ".github/workflows/lydite.yml", + "scripts/ci-lydite-changes.mjs", + "vendor/new/src/lib.rs", + "crates/new/src/lib.rs", + ]) + assert.deepEqual(scope(path), both, path); + assert.deepEqual(lyditeScope(null, packages), both); +}); + +test("Celox dependencies select the bridge, without rerunning the editor/core", () => { + for (const name of [ + "celox", + "celox-design", + "celox-frontend-veryl", + "celox-sir", + "celox-runtime", + "celox-test-suite", + "lydite-celox", + ]) + assert.deepEqual( + scope(`crates/${name}/src/lib.rs`), + { core: false, bridge: true }, + name, + ); +}); + +test("unrelated consumers and upstream private tests do not select Lydite", () => { + for (const path of [ + "crates/celox-napi/src/lib.rs", + "crates/celox/tests/counter.rs", + "crates/celox/README.md", + "packages/celox/src/index.ts", + "docs/guide.md", + "scripts/report-full-ci.mjs", + ]) + assert.deepEqual(scope(path), neither, path); + assert.deepEqual(scope(), neither); + assert.deepEqual( + scope("packages/celox/src/index.ts", "crates/lydite/src/main.rs"), + both, + ); +}); + +test("dependency selection follows new transitive edges automatically", () => { + const graph = [ + { name: "lydite", dir: "crates/lydite", dependencies: [] }, + { + name: "lydite-celox", + dir: "crates/lydite-celox", + dependencies: ["bridge-api"], + }, + { + name: "bridge-api", + dir: "crates/bridge-api", + dependencies: ["new-runtime"], + }, + { name: "new-runtime", dir: "crates/new-runtime", dependencies: [] }, + ]; + assert.deepEqual(lyditeScope(["crates/new-runtime/src/lib.rs"], graph), { + core: false, + bridge: true, + }); + graph[0].dependencies.push("new-runtime"); + assert.deepEqual(lyditeScope(["crates/new-runtime/src/lib.rs"], graph), both); +}); + +test("Celox packages do not consume the excluded Lydite packages", () => { + for (const pkg of packages.filter((p) => !isLydite(p.name))) { + assert.ok( + pkg.dependencies.every((dep) => !isLydite(dep)), + pkg.name, + ); + } +}); + +test("weekly, manual and unknown-diff invocations run every lane", () => { + for (const event of ["schedule", "workflow_dispatch", "merge_group"]) { + const output = execFileSync( + process.execPath, + ["scripts/ci-lydite-changes.mjs"], + { + cwd: root, + env: { ...process.env, GITHUB_EVENT_NAME: event, GITHUB_OUTPUT: "" }, + encoding: "utf8", + }, + ); + assert.match(output, /core=true\nbridge=true/); + } +}); + +test("workflows transfer Rust tests and gate each Lydite lane", () => { + const ci = readFileSync(`${root}.github/workflows/ci.yml`, "utf8"); + assert.match( + ci, + /cargo nextest run --locked --workspace --exclude 'lydite\*'/, + ); + assert.match( + ci, + /cargo test --locked --workspace --exclude 'lydite\*' --doc/, + ); + const workflow = readFileSync(`${root}.github/workflows/lydite.yml`, "utf8"); + assert.match( + workflow, + /pull_request:\n merge_group:\n schedule:\n - cron: "41 3 \* \* 1"/, + ); + for (const [job, lane] of [ + ["documentation", "core"], + ["editor", "core"], + ["veryl-fv", "core"], + ["celox-replay", "bridge"], + ["veryl-proof-corpus", "bridge"], + ]) { + assert.ok( + workflow.includes( + ` ${job}:\n needs: changes\n if: always() && (needs.changes.result != 'success' || needs.changes.outputs.${lane} == 'true')`, + ), + job, + ); + } + assert.match(workflow, /cargo test --locked "\$\{args\[@\]\}"/); + // Execute the actual required-check script for all selected/skipped combinations. + const script = workflow + .split(" python3 - <<'PYCODE'\n")[1] + .split(" PYCODE")[0] + .replace(/^ /gm, ""); + for (const core of [false, true]) + for (const bridge of [false, true]) { + const needs = { + changes: { + result: "success", + outputs: { core: String(core), bridge: String(bridge) }, + }, + }; + for (const [job, selected] of [ + ["rust", core || bridge], + ["documentation", core], + ["editor", core], + ["veryl-fv", core], + ["celox-replay", bridge], + ["veryl-proof-corpus", bridge], + ]) + needs[job] = { result: selected ? "success" : "skipped" }; + const run = () => + execFileSync("python3", ["-c", script], { + env: { ...process.env, NEEDS: JSON.stringify(needs) }, + stdio: "pipe", + }); + run(); + for (const job of Object.keys(needs)) { + const original = needs[job].result; + for (const status of [ + "failure", + "cancelled", + ...(original === "success" ? ["skipped"] : []), + ]) { + needs[job].result = status; + assert.throws(run, `${job}: ${status}`); + } + needs[job].result = original; + } + } +}); + +test("scoped Celox PR tests also exclude the bridge and Lydite fixtures", () => { + for (const path of [ + "crates/celox/src/lib.rs", + "crates/lydite/src/main.rs", + "lydite/examples/counter.lyd", + ]) { + const result = celoxRustTestScope([path], packages); + assert.equal(result.full, false); + assert.ok(result.packages.every((name) => !isLydite(name))); + assert.ok(result.libraries.every((name) => !isLydite(name))); + if (!path.startsWith("crates/celox/")) + assert.deepEqual(result.packages, []); + } +}); diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs index b525867236e..8d59674717b 100644 --- a/scripts/ci-workflow.test.mjs +++ b/scripts/ci-workflow.test.mjs @@ -221,7 +221,7 @@ test("Rust changes validate dependency exclusions even when script jobs are omit const lint = job("lint"); assert.match( lint, - /name: Check CI runtime dependency exclusions and test scopes\n if: .*outputs\.rust == 'true' && needs\.changes\.outputs\.scripts != 'true'\n run: node --test scripts\/ci-changes\.test\.mjs scripts\/ci-rust-scope\.test\.mjs/, + /name: Check CI runtime dependency exclusions and test scopes\n if: .*outputs\.rust == 'true' && needs\.changes\.outputs\.scripts != 'true'\n run: node --test scripts\/ci-changes\.test\.mjs scripts\/ci-rust-scope\.test\.mjs scripts\/ci-lydite-changes\.test\.mjs/, ); });