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
111 changes: 12 additions & 99 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
scripts: ${{ steps.groups.outputs.scripts }}
macos_scripts: ${{ steps.groups.outputs.macos_scripts }}
dependencies: ${{ steps.groups.outputs.dependencies }}
platforms: ${{ steps.groups.outputs.platforms }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
Expand Down Expand Up @@ -121,30 +122,7 @@ jobs:
shell: powershell
env:
CACHE_STAMP: ${{ hashFiles('rust-toolchain.toml') }}-${{ env.CARGO_PROFILE_DEV_DEBUG }}
run: |
$targetDir = [System.IO.Path]::GetFullPath($env:CARGO_TARGET_DIR)
$stampFile = Join-Path $targetDir '.cache-stamp'
$maxBytes = 12GB
$reset = $false
if (Test-Path $targetDir) {
$current = if (Test-Path $stampFile) { (Get-Content -Raw $stampFile).Trim() } else { '' }
if ($current -ne $env:CACHE_STAMP) {
Write-Output 'Resetting Windows target cache (toolchain or profile stamp changed).'
$reset = $true
} else {
$bytes = (Get-ChildItem -LiteralPath $targetDir -Recurse -File -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum
if ($bytes -gt $maxBytes) {
Write-Output "Resetting Windows target cache ($([math]::Round($bytes / 1GB, 2)) GiB exceeded 12 GiB budget)."
$reset = $true
}
}
}
if ($reset) {
Remove-Item -LiteralPath $targetDir -Recurse -Force
}
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
Set-Content -LiteralPath $stampFile -Value $env:CACHE_STAMP -NoNewline
"CARGO_TARGET_DIR=$targetDir" >> $env:GITHUB_ENV
run: '& "$env:GITHUB_WORKSPACE\scripts\ci-windows-target.ps1"'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this body to scripts/ changes which PRs exercise it. The old location in ci.yml selected every check group; scripts/ci-windows-target.ps1 now matches only the scripts rule (scripts/ci-changes.mjs:51), so a PR that edits only this file runs the Linux scripts job and skips windows-cli. Fix: add classifier rules for the moved scripts, for example ['scripts','windows'] here, ['scripts','web'] for ci-web-check.ps1, and a windows_native selection for ci-windows-native-tools.ps1, or record the gap.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 54579d5.

- name: Verify native Windows CLI boundaries
run: cargo test --locked -p dim-cli --lib
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
Expand All @@ -163,30 +141,7 @@ jobs:
CMAKE_SHA256: 'd163cd3ab4959b0a53fa8988f2ddbd2e6c501658201e6a154386bad9dbe4f836'
NASM_VERSION: '2.16.03'
NASM_SHA256: '3ee4782247bcb874378d02f7eab4e294a84d3d15f3f6ee2de2f47a46aa7226e6'
run: |
$ProgressPreference = 'SilentlyContinue'
function Add-PortableTool {
param([string]$Name, [string]$Version, [string]$Sha256, [string]$Url, [string]$VersionFlag)
if (Get-Command $Name -ErrorAction SilentlyContinue) {
Write-Output "Using the $Name already on PATH"
return
}
$archive = Join-Path $env:RUNNER_TEMP "$Name-$Version.zip"
Invoke-WebRequest -Uri $Url -OutFile $archive -UseBasicParsing
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant()
if ($actual -ne $Sha256) { throw "$Name sha256 $actual does not match $Sha256" }
$directory = Join-Path $env:RUNNER_TEMP "dim-windows-native-$Name-$Version"
if (Test-Path $directory) { Remove-Item -LiteralPath $directory -Recurse -Force }
Expand-Archive -LiteralPath $archive -DestinationPath $directory -Force
$executable = Get-ChildItem -LiteralPath $directory -Recurse -File -Filter "$Name.exe" | Select-Object -First 1
if (-not $executable) { throw "$Name archive holds no $Name.exe" }
[System.IO.File]::AppendAllText($env:GITHUB_PATH, "$($executable.DirectoryName)`n")
& $executable.FullName $VersionFlag
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Output "Provisioned $Name $Version from $Url"
}
Add-PortableTool -Name 'cmake' -Version $env:CMAKE_VERSION -Sha256 $env:CMAKE_SHA256 -Url "https://github.com/Kitware/CMake/releases/download/v$env:CMAKE_VERSION/cmake-$env:CMAKE_VERSION-windows-x86_64.zip" -VersionFlag '--version'
Add-PortableTool -Name 'nasm' -Version $env:NASM_VERSION -Sha256 $env:NASM_SHA256 -Url "https://www.nasm.us/pub/nasm/releasebuilds/$env:NASM_VERSION/win64/nasm-$env:NASM_VERSION-win64.zip" -VersionFlag '-v'
run: '& "$env:GITHUB_WORKSPACE\scripts\ci-windows-native-tools.ps1"'
- name: Verify native Windows boundary flows
# Scheduled sweeps select every check group, so they run these flows too.
if: needs.changes.outputs.windows_native == 'true'
Expand All @@ -206,29 +161,7 @@ jobs:
node-version-file: .node-version
package-manager-cache: false
- name: Build and test the Web workspace
run: |
$declarations = 'web/src/auto-imports.d.ts', 'web/src/components.d.ts'
$original = @{}
foreach ($file in $declarations) {
$original[$file] = (Get-Content -Raw -Encoding UTF8 $file).Replace("`r`n", "`n")
}
$version = node -p "require('./npm/package.json').version"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$env:Path = "$env:WINDIR\System32;$env:Path"
node scripts/stage-web.mjs staging/release-web $version $env:GITHUB_SHA
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$notices = tar.exe -xOzf "staging/release-web/dimcode-web-$version.tar.gz" dimcode-web/web/THIRD-PARTY-NOTICES.txt
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
foreach ($package in 'vue', 'vue-router', 'pinia') {
$entry = $notices -cmatch "^${package}@"
if (-not $entry) { throw "Missing third-party notice for $package" }
Write-Output $entry
}
foreach ($file in $declarations) {
if ((Get-Content -Raw -Encoding UTF8 $file).Replace("`r`n", "`n") -cne $original[$file]) {
throw "Generated declaration changed: $file"
}
}
run: '& "$env:GITHUB_WORKSPACE\scripts\ci-web-check.ps1"'
- name: Test the Web workspace
run: npm.cmd test --prefix web
- name: Test the chat-ui package
Expand Down Expand Up @@ -272,7 +205,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(github.event_name == 'pull_request' && '["linux"]' || github.event_name == 'push' && '["macos"]' || '["linux","macos"]') }}
platform: ${{ fromJSON(needs.changes.outputs.platforms) }}
runs-on: ${{ matrix.platform == 'linux' && fromJSON('["self-hosted","linux","x64","dim-verify"]') || fromJSON('["self-hosted","macOS","ARM64"]') }}
timeout-minutes: 75
env:
Expand Down Expand Up @@ -323,40 +256,20 @@ jobs:
cargo build --locked -p xtask
fi
target/debug/xtask check
- name: Derive test concurrency
if: needs.changes.outputs.rust == 'true'
id: concurrency
shell: bash
run: node scripts/ci-test-concurrency.mjs >> "$GITHUB_OUTPUT"
- name: Run compiled workspace tests
if: needs.changes.outputs.rust == 'true'
shell: bash
env:
DIM_TEST_TIMEOUT_MS: "900000"
run: |
set -euo pipefail
if [[ "$RUNNER_OS" == Linux ]]; then
cpus=$(nproc)
# Runner hosts may share their physical cores between instances and
# report SMT siblings as CPUs; scale by the cores this job can use.
if command -v lscpu >/dev/null; then
cores=$(lscpu -p=Core,Socket | grep -v '^#' | sort -u | wc -l)
logical=$(lscpu -p=CPU | grep -vc '^#')
(( cores > 0 )) || cores=1
smt=$(( logical / cores ))
(( smt < 1 )) && smt=1
physical=$(( cpus / smt ))
else
physical=$cpus
fi
(( physical < 1 )) && physical=1
test_jobs=$(( physical / 3 ))
(( test_jobs < 3 )) && test_jobs=3
(( test_jobs > 8 )) && test_jobs=8
test_threads=$(( physical / 4 ))
(( test_threads < 2 )) && test_threads=2
(( test_threads > 6 )) && test_threads=6
else
test_jobs=3
test_threads=3
fi
echo "Workspace tests: DIM_TEST_JOBS=$test_jobs --test-threads=$test_threads"
DIM_TEST_JOBS="$test_jobs" node scripts/run-rust-test.mjs target/test-artifacts.jsonl --workspace "--test-threads=$test_threads"
echo "Workspace tests: DIM_TEST_JOBS=${{ steps.concurrency.outputs.jobs }} --test-threads=${{ steps.concurrency.outputs.threads }}"
DIM_TEST_JOBS='${{ steps.concurrency.outputs.jobs }}' node scripts/run-rust-test.mjs target/test-artifacts.jsonl --workspace "--test-threads=${{ steps.concurrency.outputs.threads }}"
cargo test --workspace --doc --locked ${{ needs.changes.outputs.eval == 'true' && '--features xtask/eval-tests' || '' }}
- name: Verify debug-only CLI tests
if: needs.changes.outputs.debug == 'true'
Expand Down
8 changes: 4 additions & 4 deletions docs/architecture/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ Per [ADR 026](../adr/026-verification-tiers-and-ci-governance.md) D4, synchronou
| `changes` (routing + ADR freeze) | L1 | Self-hosted | ≤ 1 min | 5 min | Shallow fetch (`depth=2`), Node only |
| `dependencies` (`cargo-deny`) | L1 | Self-hosted Windows x64 | ≤ 2 min | 15 min | `cargo install --jobs 2` on miss |
| `web` (stage + test + lint + build) | L1 / L2 | Self-hosted Windows x64 | ≤ 5 min | 15 min | Isolated npm workspace check |
| `windows-cli` (`dim-cli --lib`, native flows) | L3 | Self-hosted Windows x64 | `dim-cli --lib`: ≤ 1 min warm (≤ 4 min cold); native flows: not yet measured | 15 min | Per-runner target dir capped at 12 GiB |
| `windows-cli` (`dim-cli --lib`, native flows) | L3 | Self-hosted Windows x64 | `dim-cli --lib`: ≤ 1 min warm (≤ 4 min cold); native flows: 1.1–4.4 min across 25 runs, p90 pending | 15 min | Per-runner target dir capped at 12 GiB |
| `macos-native` (macOS Rust + packaging) | L3 | Self-hosted macOS ARM64 | ≤ 6 min | 30 min | `CARGO_BUILD_JOBS=4`, checkout `target/` |
| `verify (linux)` (build + clippy + tests) | L1 / L2 / L3 | Self-hosted Linux x64 (`dim-verify`) | ≤ 15 min target (steady state not yet measured at these settings) | 75 min | `CARGO_BUILD_JOBS=8`, `CARGO_PROFILE_DEV_DEBUG=0`, CPU-scaled `DIM_TEST_JOBS` / `--test-threads`, 15 min target cap |
| `verify (linux)` (build + clippy + tests) | L1 / L2 / L3 | Self-hosted Linux x64 (`dim-verify`) | ≤ 15 min target (four post-change runs 8m12s–14m18s; p90 pending) | 75 min | `CARGO_BUILD_JOBS=8`, `CARGO_PROFILE_DEV_DEBUG=0`, CPU-scaled `DIM_TEST_JOBS` / `--test-threads`, 15 min target cap |
| `code-layout` (native layout matrix) | L3 | Hosted Linux, macOS, Windows | Not yet recorded | 10 / 30 / 240 min per job | Hosted runners; `native-layout` runs on layout changes |

The `verify (linux)` row records a target rather than a measurement: no full green run exists at these settings yet. The last six full runs on the `dim-verify` pool before this change completed in 18m17s (44724315336), 21m18s (44722644428), 23m42s (44719273152), 21m29s (44718768375), 30m49s (44717853591) and 25m38s (44716244403). Record the new steady state once a full green run at these settings completes.
The `verify (linux)` row is measured from full runs on the `dim-verify` pool: 8m12s (45931687899), 11m24s (45932777661), 11m48s (45932038211) and 14m18s (45933158819), against 18m17s–30m49s in the six runs recorded before the CPU-scaled test settings (44724315336, 44722644428, 44719273152, 44718768375, 44717853591, 44716244403). p90 is not recorded yet; it needs ten green runs spanning both group selections.

Approaching or exceeding a steady-state budget is treated as a regression and resolved by narrowing path scope, optimizing slow tests, improving parallelism or demoting heavy cases to Retained — never by raising job or target timeouts alone. Any change that adds a required PR check or widens path selection must disclose its incremental wall-clock cost, added compile dependencies and target runner pool.

Expand All @@ -349,7 +349,7 @@ The root `./dev` entry performs incremental CLI/App Server builds without disabl

The [Web workspace](../design/web-workspace.md) frontend in `web/` is a separate artifact (`scripts/stage-web.mjs` builds it; the CLI finds the installed `dimcode-web` package or a `web/` directory beside the executable or in the product home, or `DIMCODE_WEB_ASSETS` names one), so building `dim-app-server` and `dimcode` needs neither Node nor npm. Only `cargo build --features embedded-web` compiles the frontend in; then `build.rs` runs `npm ci` and `npm run build` when that frontend changed, and a host without npm fails the build. Otherwise Node is only needed for packaging, packaging checks and TypeScript plugin execution/development. `.node-version` pins the Node version bundled into account-enabled releases. The `runtime/package-lock.json` fixes the rutis Node runtime and its transitive dependencies; `npm ci --ignore-scripts --prefix runtime` installs them for local bridge testing.

Pull requests run workspace verification on self-hosted Linux x64 runners labelled `dim-verify`, with eight Cargo build jobs. The job checks that bubblewrap can create the sandbox the confined tests use (a user namespace with a private `/proc`) before running them. The macOS ARM64 runners use four Cargo jobs for the native Rust checks on pull requests and for full workspace verification on `main`. Use `node scripts/test-macos-native.mjs --list` to inspect the Rust selection from the current Cargo targets, Rust platform guards and host-specific test fixtures. On an Apple Silicon Mac, run `node scripts/test-macos-native.mjs` to build those targets and check each selected name against its compiled test binary before execution. Tests marked for manual execution keep their normal ignore status. The [workflow guide](../release/README.md#github-workflows) describes path selection, native packaging checks and manual dispatch. The separate `windows-cli` job runs the `dim-cli` library tests on a self-hosted Windows x64 runner, where its fixture writes to the clipboard. When a pull request changes Windows storage, host-platform, named-pipe or worktree-removal paths, when a push to `main` changes a path that selects the job, and on scheduled sweeps and manual dispatch, the same job also builds and runs the Windows-only boundary flows (`file_storage_flow`'s Windows checks, `host_platform_windows_flow`, `named_pipe_flow` and `worktree_removal_flow`) in that directory; `node scripts/test-windows-native.mjs --list` prints the selection and a run checks every selected name against its compiled test binary. The job keeps its fifteen-minute hard timeout, and the first cold compile of the `dim-app-server` graph that the step adds may not fit it; no run has measured that yet and it cannot be reproduced locally. The layout workflow uses hosted `windows-2022` and `windows-11-arm` runners, with Python 3.13 and the pinned native MSVC Rust host toolchain provisioned explicitly. Release builds use GitHub-hosted VMs matching each target OS and CPU. See the [runner setup and release matrix](../release/README.md#runner-setup).
Pull requests run workspace verification on self-hosted Linux x64 runners labelled `dim-verify`, with eight Cargo build jobs. The job checks that bubblewrap can create the sandbox the confined tests use (a user namespace with a private `/proc`) before running them. The macOS ARM64 runners use four Cargo jobs for the native Rust checks on pull requests and for full workspace verification on `main`. Use `node scripts/test-macos-native.mjs --list` to inspect the Rust selection from the current Cargo targets, Rust platform guards and host-specific test fixtures. On an Apple Silicon Mac, run `node scripts/test-macos-native.mjs` to build those targets and check each selected name against its compiled test binary before execution. Tests marked for manual execution keep their normal ignore status. The [workflow guide](../release/README.md#github-workflows) describes path selection, native packaging checks and manual dispatch. The separate `windows-cli` job runs the `dim-cli` library tests on a self-hosted Windows x64 runner, where its fixture writes to the clipboard. When a pull request changes Windows storage, host-platform, named-pipe or worktree-removal paths, when a push to `main` changes a path that selects the job, and on scheduled sweeps and manual dispatch, the same job also builds and runs the Windows-only boundary flows (`file_storage_flow`'s Windows checks, `host_platform_windows_flow`, `named_pipe_flow` and `worktree_removal_flow`) in that directory; `node scripts/test-windows-native.mjs --list` prints the selection and a run checks every selected name against its compiled test binary. The job keeps its fifteen-minute hard timeout. Across 25 sampled runs the whole job took 2.2–6.8 minutes and the native-flows step 1.1–4.4 minutes, so the compile that the step adds fits the budget. The layout workflow uses hosted `windows-2022` and `windows-11-arm` runners, with Python 3.13 and the pinned native MSVC Rust host toolchain provisioned explicitly. Release builds use GitHub-hosted VMs matching each target OS and CPU. See the [runner setup and release matrix](../release/README.md#runner-setup).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The windows-cli row at docs/architecture/build.md:335 still says native flows: not yet measured, while this paragraph records 1.1 to 4.4 minutes across 25 runs. The budget table now contradicts the measurement it cites, so a reader cannot tell which is the recorded value. Fix: update the row to the measured range, for example native flows: 1.1 to 4.4 min across 25 runs; p90 pending, or state the intended budget and its basis.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 54579d5.


The macOS clipboard flows use private pasteboards and serialize access to the shared pasteboard server; other tests remain parallel.

Expand Down
14 changes: 13 additions & 1 deletion scripts/ci-changes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const rules=[
[/^scripts\/run-rust-test\.mjs$/,groups],
[/^scripts\/test-macos-native(?:\.test)?\.mjs$/,['rust','scripts']],
[/^scripts\/stage-web\.mjs$/,['scripts','web']],
[/^scripts\/ci-test-concurrency\.mjs$/,['rust','scripts']],
[/^scripts\/ci-web-check\.ps1$/,['scripts','web']],
[/^scripts\/ci-windows-target\.ps1$/,['scripts','windows']],
[/^scripts\/ci-windows-native-tools\.ps1$/,['scripts','windows','windows_native']],
[/^scripts\/(code-layout\/|code-layout-darwin\.test\.mjs$)/,['scripts','macos_scripts']],
[/^scripts\/(stage-release|pack-release|native-binary|store-formats|release\.test)\.mjs$/,['scripts','macos_scripts']],
[/^scripts\//,['scripts']],
Expand Down Expand Up @@ -77,6 +81,14 @@ const rules=[
[/^(crates|tests|vendor|runtime|npm)\//,['rust','node']],
];

// The platforms full verification runs on for an event: pull requests verify
// Linux, a `main` push verifies macOS, and a sweep or manual run covers both.
export function platforms(event) {
if (event === 'pull_request') return ['linux'];
if (event === 'push') return ['macos'];
return ['linux', 'macos'];
}

export function classify(files) {
const needed=new Set();
for (const file of files) {
Expand Down Expand Up @@ -120,5 +132,5 @@ if (import.meta.main) {
}
const lines=Object.entries(result).map(([group,value])=>`${group}=${value}`);
console.log(lines.join('\n'));
if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT,lines.join('\n')+'\n');
if(process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT,`${lines.join('\n')}\nplatforms=${JSON.stringify(platforms(process.env.GITHUB_EVENT_NAME))}\n`);
}
Loading