Skip to content

Commit 548eb66

Browse files
authored
Enhance Windows Daemon Test Workflow
Updated workflow for Windows daemon with improved logging and diagnostics.
1 parent 94ba00f commit 548eb66

1 file changed

Lines changed: 155 additions & 80 deletions

File tree

Lines changed: 155 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "🪟 Windows Daemon Start & Log Scan"
1+
name: "Windows Daemon Test - Improved"
22

33
on:
44
workflow_dispatch:
@@ -10,133 +10,208 @@ on:
1010

1111
jobs:
1212
windows-daemon-test:
13-
name: "WinLatest Daemon Test"
13+
name: "Windows Daemon Diagnostic Test"
1414
runs-on: windows-latest
15+
timeout-minutes: 15
1516

1617
steps:
17-
- name: 🏁 Checkout Code
18+
- name: Checkout Code
1819
uses: actions/checkout@v4
1920

20-
- name: 🐍 Set up Python 3.11
21+
- name: Set up Python 3.11
2122
uses: actions/setup-python@v5
2223
with:
2324
python-version: '3.11'
2425
cache: 'pip'
2526

26-
- name: 📦 Install Omnipkg
27+
- name: Configure UTF-8 Environment
28+
shell: pwsh
29+
run: |
30+
# Force UTF-8 for all Python I/O operations
31+
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
32+
[System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
33+
34+
echo "PYTHONIOENCODING=utf-8" >> $env:GITHUB_ENV
35+
echo "PYTHONUTF8=1" >> $env:GITHUB_ENV
36+
echo "PYTHONLEGACYWINDOWSSTDIO=utf-8" >> $env:GITHUB_ENV
37+
38+
Write-Host "UTF-8 encoding configured"
39+
40+
- name: Install Omnipkg
41+
shell: pwsh
2742
run: |
2843
python -m pip install --upgrade pip
2944
pip install -e .
45+
Write-Host "Omnipkg installed"
3046
31-
- name: ⚙️ Generate Basic Config (Windows)
32-
# We create a config to ensure the daemon has valid settings to load
33-
shell: python
47+
- name: Generate Config (No Emojis)
48+
shell: pwsh
3449
run: |
35-
import json
36-
import os
37-
from pathlib import Path
38-
39-
# Windows-specific config path
40-
config_dir = Path(os.environ['USERPROFILE']) / '.config' / 'omnipkg'
41-
config_dir.mkdir(parents=True, exist_ok=True)
42-
43-
config = {
44-
"interactive": False,
45-
"auto_confirm": True,
46-
"daemon_port": 5678,
47-
"log_level": "DEBUG" # Force debug logging for better scan results
50+
$configDir = "$env:USERPROFILE\.config\omnipkg"
51+
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
52+
53+
$config = @{
54+
interactive = $false
55+
auto_confirm = $true
56+
daemon_port = 5678
57+
log_level = "DEBUG"
4858
}
4959
50-
config_path = config_dir / 'config.json'
51-
with open(config_path, 'w') as f:
52-
json.dump(config, f, indent=2)
53-
print(f"✅ Config created at: {config_path}")
60+
$config | ConvertTo-Json | Out-File -FilePath "$configDir\config.json" -Encoding utf8
61+
Write-Host "Config created at: $configDir\config.json"
62+
Get-Content "$configDir\config.json"
63+
64+
- name: Pre-create Log Directory
65+
shell: pwsh
66+
run: |
67+
# Create potential log directories ahead of time
68+
$logDirs = @(
69+
"$env:USERPROFILE\.omnipkg\logs",
70+
"$env:USERPROFILE\.config\omnipkg\logs",
71+
"$env:LOCALAPPDATA\omnipkg\logs",
72+
"$env:TEMP\omnipkg"
73+
)
74+
75+
foreach ($dir in $logDirs) {
76+
New-Item -ItemType Directory -Force -Path $dir | Out-Null
77+
Write-Host "Created: $dir"
78+
}
5479
55-
- name: 🚀 Start Omnipkg Daemon
80+
- name: Start Daemon with Verbose Output
5681
id: start_daemon
57-
shell: powershell
82+
continue-on-error: true
83+
shell: pwsh
5884
run: |
59-
Write-Host "--- Starting Omnipkg Daemon ---"
60-
omnipkg daemon start
85+
Write-Host "============================================"
86+
Write-Host "Starting Omnipkg Daemon"
87+
Write-Host "============================================"
88+
89+
# Capture both stdout and stderr
90+
$output = omnipkg daemon start 2>&1
91+
$exitCode = $LASTEXITCODE
92+
93+
Write-Host "Output:"
94+
Write-Host $output
95+
Write-Host "Exit Code: $exitCode"
6196
62-
# Give it a moment to initialize or crash
63-
Start-Sleep -Seconds 5
97+
# Wait for daemon initialization
98+
Start-Sleep -Seconds 8
99+
100+
exit $exitCode
64101
65-
- name: 🔍 Verify Daemon Status
66-
id: check_status
67-
shell: powershell
102+
- name: Check Daemon Status
103+
if: steps.start_daemon.outcome == 'success'
104+
shell: pwsh
68105
run: |
69-
Write-Host "--- Checking Daemon Status ---"
106+
Write-Host "Checking daemon status..."
70107
omnipkg daemon status
71108
72109
if ($LASTEXITCODE -ne 0) {
73-
Write-Error "Daemon is not running!"
74-
exit 1
110+
Write-Error "Daemon status check failed"
111+
exit 1
75112
}
76-
Write-Host "✅ Daemon is running successfully."
113+
Write-Host "Daemon is running"
114+
115+
- name: Test Daemon Functionality
116+
if: steps.start_daemon.outcome == 'success'
117+
continue-on-error: true
118+
shell: pwsh
119+
run: |
120+
Write-Host "Testing daemon with a simple command..."
121+
omnipkg list --limit 5
122+
123+
- name: Stop Daemon
124+
if: always()
125+
continue-on-error: true
126+
shell: pwsh
127+
run: |
128+
omnipkg daemon stop 2>&1
129+
Start-Sleep -Seconds 2
77130
78131
# ════════════════════════════════════════════════════════════════
79-
# 🕵️ LOG SCANNING SECTION (Runs only if previous steps failed)
132+
# COMPREHENSIVE LOG COLLECTION
80133
# ════════════════════════════════════════════════════════════════
81-
- name: 🩺 Scan and Dump Omnipkg Logs
82-
if: failure() || cancelled()
83-
shell: powershell
134+
135+
- name: Collect All Logs
136+
if: always()
137+
shell: pwsh
84138
run: |
85-
Write-Host "::group::🔍 LOCATING OMNIPKG LOGS"
86-
87-
# Define common log locations on Windows
88-
$userProfile = $env:USERPROFILE
89-
$locations = @(
90-
"$userProfile\.omnipkg\logs",
91-
"$userProfile\.config\omnipkg\logs",
92-
"$userProfile\AppData\Local\omnipkg\logs"
139+
Write-Host "::group::Searching for Omnipkg Logs"
140+
141+
$searchPaths = @(
142+
"$env:USERPROFILE\.omnipkg\logs",
143+
"$env:USERPROFILE\.config\omnipkg\logs",
144+
"$env:LOCALAPPDATA\omnipkg\logs",
145+
"$env:TEMP\omnipkg",
146+
"$env:USERPROFILE\AppData\Local\Temp\omnipkg"
93147
)
94148
95-
$logFiles = @()
149+
$allLogs = @()
96150
97-
# Attempt to find logs in known locations
98-
foreach ($loc in $locations) {
99-
if (Test-Path $loc) {
100-
Write-Host "Found log directory: $loc"
101-
$files = Get-ChildItem -Path $loc -Filter "*.log" -Recurse
102-
$logFiles += $files
151+
foreach ($path in $searchPaths) {
152+
if (Test-Path $path) {
153+
Write-Host "Checking: $path"
154+
$logs = Get-ChildItem -Path $path -Filter "*.log" -Recurse -ErrorAction SilentlyContinue
155+
if ($logs) {
156+
Write-Host " Found $($logs.Count) log file(s)"
157+
$allLogs += $logs
158+
}
159+
} else {
160+
Write-Host " Path does not exist: $path"
103161
}
104162
}
105163
106-
# Fallback: Search user profile if nothing found (slower but thorough)
107-
if ($logFiles.Count -eq 0) {
108-
Write-Host "⚠️ No logs in standard paths. Searching UserProfile (this may take a moment)..."
109-
$logFiles = Get-ChildItem -Path $userProfile -Filter "omnipkg*.log" -Recurse -ErrorAction SilentlyContinue
110-
}
111-
112164
Write-Host "::endgroup::"
113165
114-
if ($logFiles.Count -eq 0) {
115-
Write-Host "❌ NO LOG FILES FOUND."
116-
exit 0
166+
if ($allLogs.Count -eq 0) {
167+
Write-Host "::warning::No log files found!"
168+
169+
# Try broader search as fallback
170+
Write-Host "Attempting broader search in TEMP and AppData..."
171+
$broadLogs = Get-ChildItem -Path $env:TEMP -Filter "*omnipkg*.log" -Recurse -ErrorAction SilentlyContinue
172+
$allLogs += $broadLogs
117173
}
118174
119-
# Loop through found logs and print them
120-
foreach ($file in $logFiles) {
121-
Write-Host "══════════════════════════════════════════════════════"
122-
Write-Host "📄 LOG FILE: $($file.FullName)"
123-
Write-Host "🕒 Last Write: $($file.LastWriteTime)"
124-
Write-Host "══════════════════════════════════════════════════════"
175+
# Display all found logs
176+
foreach ($log in $allLogs) {
177+
Write-Host ""
178+
Write-Host "================================================================"
179+
Write-Host "LOG: $($log.FullName)"
180+
Write-Host "SIZE: $($log.Length) bytes | MODIFIED: $($log.LastWriteTime)"
181+
Write-Host "================================================================"
125182
126-
Get-Content $file.FullName
183+
try {
184+
$content = Get-Content $log.FullName -Raw -Encoding utf8 -ErrorAction Stop
185+
Write-Host $content
186+
} catch {
187+
Write-Host "::error::Failed to read log: $_"
188+
}
127189
128190
Write-Host ""
129-
Write-Host ""
130191
}
131192
132-
- name: 📤 Upload Logs as Artifact
193+
- name: Show Process Information
194+
if: always()
195+
shell: pwsh
196+
run: |
197+
Write-Host "::group::Active Python Processes"
198+
Get-Process | Where-Object {$_.ProcessName -like "*python*"} | Format-Table -AutoSize
199+
Write-Host "::endgroup::"
200+
201+
Write-Host "::group::Network Listeners on Port 5678"
202+
netstat -ano | Select-String "5678"
203+
Write-Host "::endgroup::"
204+
205+
- name: Upload Logs as Artifact
133206
if: always()
134207
uses: actions/upload-artifact@v4
135208
with:
136-
name: windows-omnipkg-logs
209+
name: windows-daemon-logs
137210
path: |
138-
~/.omnipkg/logs/*.log
139-
~/.config/omnipkg/logs/*.log
140-
~/AppData/Local/omnipkg/logs/*.log
211+
${{ runner.temp }}/omnipkg/*.log
212+
~/.omnipkg/logs/**/*.log
213+
~/.config/omnipkg/logs/**/*.log
214+
~/AppData/Local/omnipkg/logs/**/*.log
215+
~/AppData/Local/Temp/omnipkg/**/*.log
141216
if-no-files-found: warn
142-
retention-days: 5
217+
retention-days: 7

0 commit comments

Comments
 (0)