|
| 1 | +name: Server Installer Windows-Latest Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + tags: |
| 7 | + - v* |
| 8 | + pull_request: |
| 9 | + branches: ["main"] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + make-server-installer: |
| 14 | + runs-on: windows-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Install NSIS |
| 19 | + shell: PowerShell |
| 20 | + run: | |
| 21 | + # Download NSIS installer |
| 22 | + Invoke-WebRequest -UserAgent "Wget" -Uri "https://sourceforge.net/projects/nsis/files/NSIS%203/3.10/nsis-3.10-setup.exe" -OutFile "nsis.exe" |
| 23 | + |
| 24 | + # Install NSIS |
| 25 | + Start-Process nsis.exe -ArgumentList '/S' -Wait |
| 26 | +
|
| 27 | + - name: Verify NSIS installation |
| 28 | + shell: PowerShell |
| 29 | + run: | |
| 30 | + # Check if NSIS is installed |
| 31 | + & 'C:\Program Files (x86)\NSIS\makensis.exe' /VERSION |
| 32 | +
|
| 33 | + - name: Build the Lemonade Server installer |
| 34 | + shell: PowerShell |
| 35 | + run: | |
| 36 | + cd installer |
| 37 | + & 'C:\Program Files (x86)\NSIS\makensis.exe' 'Installer.nsi' |
| 38 | +
|
| 39 | + if (Test-Path "Lemonade_Server_Installer.exe") { |
| 40 | + Write-Host "Lemonade_Server_Installer.exe has been created successfully." |
| 41 | + } else { |
| 42 | + Write-Host "Lemonade_Server_Installer.exe was not found." |
| 43 | + exit 1 |
| 44 | + } |
| 45 | +
|
| 46 | + - name: Upload Installer |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + if: always() |
| 49 | + with: |
| 50 | + name: LemonadeServerInstaller |
| 51 | + path: | |
| 52 | + installer\Lemonade_Server_Installer.exe |
| 53 | +
|
| 54 | + - name: Attempt to install Lemonade Server using installer |
| 55 | + shell: cmd |
| 56 | + run: | |
| 57 | + cd installer |
| 58 | + Lemonade_Server_Installer.exe /S |
| 59 | +
|
| 60 | + - name: Ensure the Lemonade serer works properly |
| 61 | + shell: pwsh |
| 62 | + run: | |
| 63 | + Write-Host "Use a function to determine the underlying command from the lemonade server shortcut" |
| 64 | + function Get-ShortcutTarget { |
| 65 | + param ( |
| 66 | + [string]$shortcutPath |
| 67 | + ) |
| 68 | + $shell = New-Object -ComObject WScript.Shell |
| 69 | + $shortcut = $shell.CreateShortcut($shortcutPath) |
| 70 | + $targetPath = $shortcut.TargetPath |
| 71 | + $arguments = $shortcut.Arguments |
| 72 | + return "$targetPath $arguments" |
| 73 | + } |
| 74 | +
|
| 75 | + Write-Host "ls of install directory to make sure the server is there" |
| 76 | + ls "$HOME\AppData\Local\lemonade_server" |
| 77 | +
|
| 78 | + $shortcutPath = "$HOME\AppData\Local\lemonade_server\lemonade-server.lnk" |
| 79 | + $fullCommand = Get-ShortcutTarget -shortcutPath $shortcutPath |
| 80 | +
|
| 81 | + Write-Host "Server shortcut full command: $fullCommand" |
| 82 | +
|
| 83 | + $quotedCommand = "`"$fullCommand`"" |
| 84 | + |
| 85 | + $outputFile = "output.log" |
| 86 | + $errorFile = "error.log" |
| 87 | + $serverProcess = Start-Process -FilePath "cmd.exe" -ArgumentList "/C $quotedCommand" -RedirectStandardOutput $outputFile -RedirectStandardError $errorFile -PassThru -NoNewWindow |
| 88 | +
|
| 89 | + Write-Host "Wait for 30 seconds to let the server come up" |
| 90 | + Start-Sleep -Seconds 30 |
| 91 | + |
| 92 | + Write-Host "Check if server process successfully launched" |
| 93 | + $serverRunning = Get-Process -Id $serverProcess.Id -ErrorAction SilentlyContinue |
| 94 | + if (-not $serverRunning) { |
| 95 | + Write-Host "Error: Server process isn't running, even though we just tried to start it!" |
| 96 | + Write-Host "Standard Output:" |
| 97 | + Get-Content $outputFile |
| 98 | +
|
| 99 | + Write-Host "Standard Error:" |
| 100 | + Get-Content $errorFile |
| 101 | + exit 1 |
| 102 | + } else { |
| 103 | + Write-Host "Server process is alive." |
| 104 | + } |
| 105 | +
|
| 106 | + Write-Host "Wait for the server port to come up" |
| 107 | + while ($true) { |
| 108 | + |
| 109 | + $llmPortCheck = Test-NetConnection -ComputerName 127.0.0.1 -Port 8000 |
| 110 | + if (-not $llmPortCheck.TcpTestSucceeded) { |
| 111 | + Write-Host "LLM server is not yet running on port 8000!" |
| 112 | + Write-Host "Standard Output:" |
| 113 | + Get-Content $outputFile |
| 114 | +
|
| 115 | + Write-Host "Standard Error:" |
| 116 | + Get-Content $errorFile |
| 117 | + } else { |
| 118 | + Write-Host "LLM server is running on port 8000." |
| 119 | + break |
| 120 | + } |
| 121 | +
|
| 122 | + Start-Sleep -Seconds 30 |
| 123 | + } |
| 124 | +
|
| 125 | + Write-Host "Checking the /health endpoint" |
| 126 | + $response = Invoke-WebRequest -Uri http://localhost:8000/api/v0/health -UseBasicParsing |
| 127 | +
|
| 128 | + if ($response.StatusCode -eq 200) { |
| 129 | + Write-Output "Good: /health status code is 200" |
| 130 | + } else { |
| 131 | + Write-Output "Error: /health status code is not 200" |
| 132 | + Write-Host "Standard Output:" |
| 133 | + Get-Content $outputFile |
| 134 | +
|
| 135 | + Write-Host "Standard Error:" |
| 136 | + Get-Content $errorFile |
| 137 | + exit 1 |
| 138 | + } |
| 139 | +
|
| 140 | + $jsonContent = $response.Content | ConvertFrom-Json |
| 141 | + if ($jsonContent) { |
| 142 | + Write-Output "Good: /health JSON content is not empty: $jsonContent" |
| 143 | + } else { |
| 144 | + Write-Output "Error: /health JSON content is empty" |
| 145 | + Write-Host "Standard Output:" |
| 146 | + Get-Content $outputFile |
| 147 | +
|
| 148 | + Write-Host "Standard Error:" |
| 149 | + Get-Content $errorFile |
| 150 | + exit 1 |
| 151 | + } |
| 152 | +
|
| 153 | + Write-Host "Close the server process" |
| 154 | +
|
| 155 | + function Kill-Tree { |
| 156 | + Param([int]$ppid) |
| 157 | + Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq $ppid } | ForEach-Object { Kill-Tree $_.ProcessId } |
| 158 | + Stop-Process -Id $ppid |
| 159 | + } |
| 160 | + Kill-Tree $serverProcess.Id |
| 161 | +
|
| 162 | + - name: Release |
| 163 | + uses: softprops/action-gh-release@v2 |
| 164 | + if: startsWith(github.ref, 'refs/tags/v') |
| 165 | + with: |
| 166 | + files: installer/Lemonade_Server_Installer.exe |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
0 commit comments