119 lines
4.8 KiB
YAML
119 lines
4.8 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: clippy, rustfmt
|
|
- name: Install system dependencies
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: sudo apt-get update && sudo apt-get install -y libdrm-dev libdrm-amdgpu1
|
|
- name: Cargo fmt
|
|
run: cargo fmt --all -- --check
|
|
- name: Clippy
|
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
- name: Build (release)
|
|
run: cargo build --release --workspace
|
|
- name: Windows: start agent and run WS probe
|
|
if: matrix.os == 'windows-latest'
|
|
shell: pwsh
|
|
run: |
|
|
# Start the already-built release binary to avoid rebuild delays
|
|
# Force TLS off for this probe and disable slow/fragile sensors
|
|
$env:SOCKTOP_ENABLE_SSL = "0"
|
|
$env:SOCKTOP_AGENT_GPU = "0"
|
|
$env:SOCKTOP_AGENT_TEMP = "0"
|
|
$out = Join-Path $PWD "agent.out.txt"
|
|
$err = Join-Path $PWD "agent.err.txt"
|
|
$p = Start-Process -FilePath "${PWD}\target\release\socktop_agent.exe" -ArgumentList "-p 3000" -RedirectStandardOutput $out -RedirectStandardError $err -PassThru -NoNewWindow
|
|
$ready = $false
|
|
for ($i = 0; $i -lt 60; $i++) {
|
|
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
|
|
$pinfo.FileName = "curl.exe"
|
|
$pinfo.Arguments = "-fsS http://127.0.0.1:3000/healthz"
|
|
$pinfo.RedirectStandardOutput = $true
|
|
$pinfo.RedirectStandardError = $true
|
|
$pinfo.UseShellExecute = $false
|
|
$proc = [System.Diagnostics.Process]::Start($pinfo)
|
|
$proc.WaitForExit()
|
|
if ($proc.ExitCode -eq 0) { $ready = $true; break }
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
if (-not $ready) {
|
|
Write-Warning "TCP connect to (127.0.0.1 : 3000) failed"
|
|
if (Test-Path $out) { Write-Host "--- agent.out (full) ---"; Get-Content $out }
|
|
if (Test-Path $err) { Write-Host "--- agent.err (full) ---"; Get-Content $err }
|
|
Write-Host "--- netstat ---"
|
|
netstat -ano | Select-String ":3000" | ForEach-Object { $_.Line }
|
|
Write-Error "agent did not become ready"
|
|
}
|
|
# Run the test in the same step/session so the agent stays alive
|
|
$env:SOCKTOP_WS = "ws://127.0.0.1:3000/ws"
|
|
try {
|
|
cargo test -p socktop --test ws_probe -- --nocapture
|
|
} finally {
|
|
if ($p -and !$p.HasExited) { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue }
|
|
}
|
|
echo "SOCKTOP_WS=ws://127.0.0.1:3000/ws" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
for ($i = 0; $i -lt 60; $i++) {
|
|
try {
|
|
$resp = Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:3000/healthz" -TimeoutSec 2 -ErrorAction Stop
|
|
if ($resp.StatusCode -eq 200) { $ready = $true; break }
|
|
} catch { }
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
if (-not $ready) {
|
|
Write-Warning "TCP connect to (127.0.0.1 : 3000) failed"
|
|
if (Test-Path $out) { Write-Host "--- agent.out (full) ---"; Get-Content $out }
|
|
if (Test-Path $err) { Write-Host "--- agent.err (full) ---"; Get-Content $err }
|
|
Write-Host "--- netstat ---"
|
|
netstat -ano | Select-String ":3000" | ForEach-Object { $_.Line }
|
|
Write-Error "agent did not become ready"
|
|
}
|
|
|
|
- name: Smoke test (client --help)
|
|
run: cargo run -p socktop -- --help
|
|
- name: Package artifacts
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
mkdir dist
|
|
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
|
|
cp target/release/socktop.exe dist/
|
|
cp target/release/socktop_agent.exe dist/
|
|
7z a socktop-${{ matrix.os }}.zip dist/*
|
|
else
|
|
cp target/release/socktop dist/
|
|
cp target/release/socktop_agent dist/
|
|
tar czf socktop-${{ matrix.os }}.tar.gz -C dist .
|
|
fi
|
|
- name: Upload build artifacts (ephemeral)
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: socktop-${{ matrix.os }}
|
|
path: |
|
|
*.tar.gz
|
|
*.zip
|
|
- name: Upload to rolling GitHub Release (main only)
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: latest
|
|
name: Latest build
|
|
prerelease: true
|
|
draft: false
|
|
files: |
|
|
*.tar.gz
|
|
*.zip
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|