Skip to content

Commit bf41277

Browse files
committed
Fix CI failures for macOS and Windows platforms
Windows fixes: - Improve Python command detection (try python3, python, py) - Better Vim PATH handling with GITHUB_PATH for subsequent steps - Check common Vim installation paths as fallback - Enhanced error handling for LASTEXITCODE edge cases - Use detected commands (, ) consistently macOS fixes: - Install coreutils package for timeout command support - Add timeout fallback logic (timeout -> gtimeout -> no timeout) - Ensure Homebrew bin directory is in PATH via GITHUB_PATH - Verify Vim installation after brew install These changes ensure CI tests run successfully on all platforms.
1 parent e1b0baf commit bf41277

File tree

3 files changed

+142
-27
lines changed

3 files changed

+142
-27
lines changed

.github/workflows/test.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ jobs:
8080
run: |
8181
pip install ruff
8282
83-
- name: Install Vim
83+
- name: Install Vim and coreutils
8484
run: |
85-
brew install vim
85+
brew install vim coreutils
86+
# Ensure brew's bin directory is in PATH
87+
echo "$(brew --prefix)/bin" >> $GITHUB_PATH
88+
# Verify vim is available
89+
which vim
90+
vim --version
91+
# Verify timeout is available (from coreutils)
92+
which timeout || which gtimeout || echo "Warning: timeout command not found"
8693
8794
- name: Run Vader test suite
8895
run: |
@@ -134,7 +141,46 @@ jobs:
134141
choco install vim -y
135142
# Refresh PATH to make vim available
136143
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
137-
vim --version
144+
# Also add common Vim installation paths
145+
$env:Path += ";C:\Program Files (x86)\Vim\vim91\bin;C:\Program Files\Vim\vim91\bin;C:\tools\vim\vim91\bin"
146+
# Add to GITHUB_PATH for subsequent steps
147+
$vimPaths = @(
148+
"C:\Program Files (x86)\Vim\vim91\bin",
149+
"C:\Program Files\Vim\vim91\bin",
150+
"C:\tools\vim\vim91\bin"
151+
)
152+
foreach ($path in $vimPaths) {
153+
if (Test-Path $path) {
154+
echo "$path" >> $env:GITHUB_PATH
155+
Write-Host "Added to GITHUB_PATH: $path"
156+
}
157+
}
158+
# Verify vim is available
159+
$vimPath = (Get-Command vim -ErrorAction SilentlyContinue).Source
160+
if ($vimPath) {
161+
Write-Host "Vim found at: $vimPath"
162+
& $vimPath --version
163+
} else {
164+
Write-Host "Vim not in PATH, trying to find it..."
165+
$possiblePaths = @(
166+
"C:\Program Files (x86)\Vim\vim91\vim.exe",
167+
"C:\Program Files\Vim\vim91\vim.exe",
168+
"C:\tools\vim\vim91\vim.exe"
169+
)
170+
$found = $false
171+
foreach ($path in $possiblePaths) {
172+
if (Test-Path $path) {
173+
Write-Host "Found Vim at: $path"
174+
& $path --version
175+
$found = $true
176+
break
177+
}
178+
}
179+
if (-not $found) {
180+
Write-Host "ERROR: Could not find Vim installation"
181+
exit 1
182+
}
183+
}
138184
139185
- name: Run Vader test suite
140186
shell: pwsh

scripts/cicd/run_vader_tests_direct.sh

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,44 @@ for test_file in "${TEST_FILES[@]}"; do
179179
# Create output file for this test
180180
VIM_OUTPUT_FILE=$(mktemp)
181181

182-
# Run Vader test
182+
# Run Vader test with timeout
183+
# macOS doesn't have timeout by default, so use gtimeout if available, or run without timeout
183184
set +e # Don't exit on error, we'll check exit code
184-
timeout 120 vim \
185-
--not-a-term \
186-
-es \
187-
-i NONE \
188-
-u "${CI_VIMRC}" \
189-
-c "Vader! ${TEST_FILE_ABS}" \
190-
-c "qa!" \
191-
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
192-
193-
EXIT_CODE=$?
185+
if command -v timeout &> /dev/null; then
186+
timeout 120 vim \
187+
--not-a-term \
188+
-es \
189+
-i NONE \
190+
-u "${CI_VIMRC}" \
191+
-c "Vader! ${TEST_FILE_ABS}" \
192+
-c "qa!" \
193+
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
194+
EXIT_CODE=$?
195+
elif command -v gtimeout &> /dev/null; then
196+
# macOS with GNU coreutils installed via Homebrew
197+
gtimeout 120 vim \
198+
--not-a-term \
199+
-es \
200+
-i NONE \
201+
-u "${CI_VIMRC}" \
202+
-c "Vader! ${TEST_FILE_ABS}" \
203+
-c "qa!" \
204+
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
205+
EXIT_CODE=$?
206+
else
207+
# No timeout available (macOS without GNU coreutils)
208+
# Run without timeout - tests should complete quickly anyway
209+
log_warn "timeout command not available, running without timeout"
210+
vim \
211+
--not-a-term \
212+
-es \
213+
-i NONE \
214+
-u "${CI_VIMRC}" \
215+
-c "Vader! ${TEST_FILE_ABS}" \
216+
-c "qa!" \
217+
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
218+
EXIT_CODE=$?
219+
fi
194220
set -e
195221

196222
OUTPUT=$(cat "${VIM_OUTPUT_FILE}" 2>/dev/null || echo "")

scripts/cicd/run_vader_tests_windows.ps1

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,53 @@ $ProjectRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
3131
Set-Location $ProjectRoot
3232

3333
Write-Info "Project root: $ProjectRoot"
34-
Write-Info "Python version: $(python --version 2>&1)"
35-
Write-Info "Vim version: $(vim --version 2>&1 | Select-Object -First 1)"
3634

37-
# Check prerequisites
38-
if (-not (Get-Command vim -ErrorAction SilentlyContinue)) {
39-
Write-Error "Vim is not installed"
35+
# Try python3 first, then python, then py
36+
$PythonCmd = $null
37+
if (Get-Command python3 -ErrorAction SilentlyContinue) {
38+
$PythonCmd = "python3"
39+
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
40+
$PythonCmd = "python"
41+
} elseif (Get-Command py -ErrorAction SilentlyContinue) {
42+
$PythonCmd = "py"
43+
} else {
44+
Write-Error "Python is not installed (tried python3, python, py)"
4045
exit 1
4146
}
4247

43-
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
44-
Write-Error "Python is not installed"
45-
exit 1
48+
Write-Info "Python command: $PythonCmd"
49+
Write-Info "Python version: $(& $PythonCmd --version 2>&1)"
50+
51+
# Try to find vim in PATH or common locations
52+
$VimCmd = $null
53+
if (Get-Command vim -ErrorAction SilentlyContinue) {
54+
$VimCmd = "vim"
55+
} else {
56+
# Try common Vim installation paths
57+
$possiblePaths = @(
58+
"C:\Program Files (x86)\Vim\vim91\vim.exe",
59+
"C:\Program Files\Vim\vim91\vim.exe",
60+
"C:\tools\vim\vim91\vim.exe"
61+
)
62+
foreach ($path in $possiblePaths) {
63+
if (Test-Path $path) {
64+
$VimCmd = $path
65+
$env:Path += ";$(Split-Path $path -Parent)"
66+
Write-Info "Found Vim at: $VimCmd"
67+
break
68+
}
69+
}
70+
if (-not $VimCmd) {
71+
Write-Error "Vim is not installed or not found in PATH"
72+
exit 1
73+
}
4674
}
4775

76+
Write-Info "Vim command: $VimCmd"
77+
Write-Info "Vim version: $(& $VimCmd --version 2>&1 | Select-Object -First 1)"
78+
79+
# Prerequisites already checked above
80+
4881
# Set up Vim runtime paths (Windows uses different path format)
4982
$VimHome = Join-Path $env:USERPROFILE ".vim"
5083
$VaderDir = Join-Path $VimHome "pack\vader\start\vader.vim"
@@ -179,9 +212,19 @@ foreach ($TestFile in $TestFiles) {
179212
)
180213

181214
try {
182-
$Output = & vim $VimArgs 2>&1 | Out-String
215+
# Capture both stdout and stderr
216+
$Output = & $VimCmd $VimArgs 2>&1 | Out-String
183217
$ExitCode = $LASTEXITCODE
184218

219+
# If LASTEXITCODE is not set, check the actual exit code
220+
if ($null -eq $ExitCode) {
221+
if ($Output -match "error|Error|ERROR|failed|Failed|FAILED") {
222+
$ExitCode = 1
223+
} else {
224+
$ExitCode = 0
225+
}
226+
}
227+
185228
# Check for timeout (not applicable in PowerShell, but keep for consistency)
186229
if ($ExitCode -eq 124) {
187230
Write-Error "Test timed out: $TestName (exceeded 120s timeout)"
@@ -239,8 +282,8 @@ New-Item -ItemType Directory -Force -Path $ResultsDir | Out-Null
239282
New-Item -ItemType Directory -Force -Path $LogsDir | Out-Null
240283

241284
$TestResultsJson = Join-Path $ProjectRoot "test-results.json"
242-
$PythonVersion = (python --version 2>&1).ToString() -replace 'Python ', ''
243-
$VimVersion = (vim --version 2>&1 | Select-Object -First 1).ToString() -replace '.*VIM.*v(\S+).*', '$1'
285+
$PythonVersion = (& $PythonCmd --version 2>&1).ToString() -replace 'Python ', ''
286+
$VimVersion = (& $VimCmd --version 2>&1 | Select-Object -First 1).ToString() -replace '.*VIM.*v(\S+).*', '$1'
244287

245288
$ResultsJson = @{
246289
timestamp = [int64]((Get-Date).ToUniversalTime() - (Get-Date "1970-01-01")).TotalSeconds
@@ -273,8 +316,8 @@ $SummaryLog = Join-Path $LogsDir "test-summary.log"
273316
$SummaryContent = @"
274317
Test Summary
275318
============
276-
Python Version: $(python --version 2>&1)
277-
Vim Version: $(vim --version 2>&1 | Select-Object -First 1)
319+
Python Version: $(& $PythonCmd --version 2>&1)
320+
Vim Version: $(& $VimCmd --version 2>&1 | Select-Object -First 1)
278321
Timestamp: $(Get-Date)
279322
280323
Total Tests: $($TestFiles.Count)

0 commit comments

Comments
 (0)