Deploy from a WSL checkout, from boilerplate 1679e88

When the checkout lives under \\wsl.localhost, step 1 runs its tests in the
distro through deploy/test-commit.sh and db.ps1 push makes its snapshot
there, because the .venv is a Linux one. pipeline/context.py narrows by
sys.platform so mypy passes on Linux. See boilerplate docs/wsl.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-26 19:43:50 +02:00
1 parent 36860f0cfe
commit 515d2250fc
5 files changed
+52 -4

No files matched your search

+8 -1
View File
@@ -27,7 +27,14 @@ try {
# tree that is about to become production, with none of the working copy's
# uncommitted edits in the way. Worktrees have no .venv of their own, so the
# interpreter comes from the main checkout and the code from the worktree.
if (-not $NoTests) {
#
# A checkout inside WSL has a Linux .venv, so there the same steps run in
# the distro through deploy/test-commit.sh.
if (-not $NoTests -and $Wsl.Success) {
Write-Step "tests on $Source, in WSL $($Wsl.Groups[1].Value)"
wsl.exe -d $Wsl.Groups[1].Value --cd (ConvertTo-LinuxPath $root) -- sh deploy/test-commit.sh $commit
Assert-Ok 'tests'
} elseif (-not $NoTests) {
Write-Step "tests on $Source"
if (-not (Test-Path $Python)) {
throw "no interpreter at $Python - set PYTHON in deploy\release.env"
+10
View File
@@ -16,6 +16,16 @@ $ErrorActionPreference = 'Stop'
#: directory, so the scripts can be run from anywhere.
$root = Split-Path -Parent $PSScriptRoot
#: A checkout inside WSL, run from Windows as \\wsl.localhost\<distro>\... Its
#: .venv is a Linux one, so the steps that run Python hand that part to the
#: distro. $Wsl.Groups[1] is the distro; ConvertTo-LinuxPath turns a path under
#: the checkout into the distro's own. See docs/wsl.md.
$WslPattern = '^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(\\.*)$'
$Wsl = [regex]::Match($root, $WslPattern)
function ConvertTo-LinuxPath([string] $Path) {
[regex]::Match($Path, $WslPattern).Groups[2].Value -replace '\\', '/'
}
function Assert-Ok([string] $What) {
if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" }
}
+9 -1
View File
@@ -84,7 +84,15 @@ with tempfile.TemporaryDirectory() as work:
with plain.open("rb") as raw, gzip.open(target, "wb") as out:
shutil.copyfileobj(raw, out)
'@
& $Python -c $snapshot $LocalDb $snap; Assert-Ok 'snapshot'
# A checkout inside WSL has a Linux .venv, and SQLite cannot lock a WAL
# database through the \\wsl.localhost share, so the snapshot is taken in
# the distro. The script goes in on stdin, past both shells.
if ($Wsl.Success) {
$snapshot | wsl.exe -d $Wsl.Groups[1].Value --cd (ConvertTo-LinuxPath $root) --exec .venv/bin/python - (ConvertTo-LinuxPath $LocalDb) (ConvertTo-LinuxPath $snap)
} else {
& $Python -c $snapshot $LocalDb $snap
}
Assert-Ok 'snapshot'
' {0:N1} MB' -f ((Get-Item $snap).Length / 1MB) | Write-Host
try {
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Test one commit in a throwaway worktree, with the checkout's Linux .venv.
# 1-test-and-promote.ps1 runs this through wsl.exe when the checkout lives
# inside WSL, where the .venv has no Windows python.exe to call. The gates are
# the same as in that script; keep the two lists in step.
# Usage: sh deploy/test-commit.sh <commit> (from the checkout root)
set -eu
root=$(pwd)
python="$root/.venv/bin/python"
[ -x "$python" ] || { echo "no interpreter at $python - run uv sync" >&2; exit 1; }
base=$(mktemp -d /tmp/test-commit-XXXXXXXX)
tree="$base/tree"
trap 'git -C "$root" worktree remove --force "$tree" 2>/dev/null; rm -rf "$base"' EXIT
git worktree add --detach "$tree" "$1" >/dev/null
cd "$tree"
"$python" -m pytest -q
# "$python" -m ruff check .
# "$python" -m mypy --cache-dir "$root/.mypy_cache"
+7 -2
View File
@@ -19,6 +19,7 @@ import logging
import os
import signal
import subprocess
import sys
import tempfile
import time
from collections.abc import Callable, Sequence
@@ -168,8 +169,12 @@ def spawn(argv: Sequence[str], *, check: Callable[[], None] | None = None,
Started detached — its own process group, or Windows' equivalent — purely
so `kill_tree` has something to aim at.
"""
detach: dict[str, Any] = ({"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP}
if os.name == "nt" else {"start_new_session": True})
# An `if`, because mypy narrows `sys.platform` in statements only.
detach: dict[str, Any]
if sys.platform == "win32":
detach = {"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP}
else:
detach = {"start_new_session": True}
with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
popen.setdefault("stdout", out)
popen.setdefault("stderr", err)