Skip to content
Draft
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,24 @@ jobs:
fi
grep -Fxq "120s|5|-C $HOME install|token=set" "$log"

# Another machine's reachability is not this machine's configuration
# state: a devices sync that fails only because a node is unreachable is
# recorded as pending, so the hourly convergence keeps reporting the
# real result.
- name: Validate the devices sync failure classification
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$converge = Get-Content -LiteralPath ./platforms/windows-11/converge.ps1 -Raw
if (-not $converge.Contains("Add-Step 'devices-sync' 'pending'")) {
throw 'the devices sync step must record an unreachable node as pending.'
}
if (-not $converge.Contains('unavailable or rejected')) {
throw 'the devices sync step must recognise the reachability failure.'
}

- name: Validate global lock adoption
run: |
set -euo pipefail
Expand Down
14 changes: 12 additions & 2 deletions platforms/windows-11/converge.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,30 @@ function Sync-Devices {
$previousPath = $env:PATH
$env:PATH = (Join-Path $env:LOCALAPPDATA 'mise\shims') + ';' + $env:PATH
$code = 0
$devicesOut = @()
try {
Push-Location $DotfilesDir
try {
& $bunPath $devicesScript sync *>> $script:LogFile
$devicesOut = @(& $bunPath $devicesScript sync *>&1 | ForEach-Object { [string]$_ })
$code = $LASTEXITCODE
} finally {
Pop-Location
}
} finally {
$env:PATH = $previousPath
}
$devicesOut | ForEach-Object { Write-Log $_ }
if ($code -eq 0) {
Add-Step 'devices-sync' 'ok' 'devices sync converged'
} else {
}
elseif (($devicesOut -join "`n") -match 'unavailable or rejected') {
# Another machine's reachability is not this machine's configuration
# state: the local definitions were applied and only the unreachable
# nodes stay pending. Failing the whole convergence for a machine that
# happens to be offline hides the real result (rebuildup/pc-setup#289).
Add-Step 'devices-sync' 'pending' ('some devices are unreachable or rejected; the local definitions are applied and the unreachable nodes stay pending; see ' + $script:LogFile)
}
else {
Add-Step 'devices-sync' 'error' ('devices sync exited ' + $code + '; see ' + $script:LogFile)
}
}
Expand Down
9 changes: 9 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ PY

grep -Fq 'bash scripts/apply-platform.sh' mise.toml

printf 'Checking the devices sync failure classification...\n'
# Another machine's reachability is not this machine's configuration state. A
# devices sync that fails only because a node is unreachable is recorded as
# pending, so the hourly convergence keeps reporting the real result
# (rebuildup/pc-setup#289).
grep -Fq "unavailable or rejected" scripts/converge.sh
grep -Fq "record devices-sync pending" scripts/converge.sh
grep -Fq "Add-Step 'devices-sync' 'pending'" platforms/windows-11/converge.ps1

printf 'Checking macOS Kanata service contract...\n'
python3 - <<'PY'
import plistlib
Expand Down
15 changes: 13 additions & 2 deletions scripts/converge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,22 @@ sync_devices() {
fi

local rc=0
if (cd "$dotfiles_dir" && PATH="$HOME/.local/share/mise/shims:$PATH" bun "$devices_script" sync </dev/null >>"$log_file" 2>&1); then
local devices_output=""
if devices_output="$(cd "$dotfiles_dir" && PATH="$HOME/.local/share/mise/shims:$PATH" bun "$devices_script" sync </dev/null 2>&1)"; then
printf '%s\n' "$devices_output" >>"$log_file"
record devices-sync ok "devices sync converged"
else
rc=$?
record devices-sync error "devices sync exited $rc; see $log_file"
printf '%s\n' "$devices_output" >>"$log_file"
# Another machine's reachability is not this machine's configuration state:
# the local definitions were applied and only the unreachable nodes stay
# pending. Failing the whole convergence for a machine that happens to be
# offline hides the real result (rebuildup/pc-setup#289).
if printf '%s' "$devices_output" | grep -Fq 'unavailable or rejected'; then
record devices-sync pending "some devices are unreachable or rejected; the local definitions are applied and the unreachable nodes stay pending; see $log_file"
else
record devices-sync error "devices sync exited $rc; see $log_file"
fi
fi
}

Expand Down