Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

ci: run agent Go checks and backend pytest on push/PR (addresses audit M4)

Juan Denis0bc30b62efbc
diff --git a/.github/workflows/agent-ci.yml b/.github/workflows/agent-ci.yml
new file mode 100644
index 00000000..c2c33607
--- /dev/null
+++ b/.github/workflows/agent-ci.yml
@@ -0,0 +1,68 @@
+name: Agent CI
+
+# Validates the Go agent on every change: it must vet clean, pass its unit
+# tests, and — critically — still COMPILE for every platform it ships on. The
+# cross-compile matrix is what catches "this builds on my machine but breaks
+# the Windows/macOS build" before it reaches a release, which the
+# build-only release workflow did not guard on PRs.
+
+on:
+ push:
+ branches: [dev, main]
+ paths:
+ - 'agent/**'
+ - '.github/workflows/agent-ci.yml'
+ pull_request:
+ branches: [dev, main]
+ paths:
+ - 'agent/**'
+ - '.github/workflows/agent-ci.yml'
+
+defaults:
+ run:
+ working-directory: agent
+
+jobs:
+ test:
+ name: vet & test (linux)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: agent/go.mod
+ cache-dependency-path: agent/go.sum
+ - name: go vet
+ run: go vet ./...
+ - name: go test
+ run: go test ./... -count=1
+
+ build:
+ name: build (${{ matrix.goos }}/${{ matrix.goarch }})
+ runs-on: ubuntu-latest
+ # darwin is intentionally NOT in this matrix: the tray dependency
+ # (fyne.io/systray) needs the macOS Cocoa toolchain and cannot be
+ # cross-compiled from Linux. It is built on a macOS host at release time
+ # (and is treated as best-effort there). These three targets cover the
+ # real deployment surface — Linux servers and Windows.
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - goos: linux
+ goarch: amd64
+ - goos: linux
+ goarch: arm64
+ - goos: windows
+ goarch: amd64
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: agent/go.mod
+ cache-dependency-path: agent/go.sum
+ - name: go build
+ env:
+ GOOS: ${{ matrix.goos }}
+ GOARCH: ${{ matrix.goarch }}
+ run: go build ./...
diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml
new file mode 100644
index 00000000..0ad97fc8
--- /dev/null
+++ b/.github/workflows/backend-ci.yml
@@ -0,0 +1,38 @@
+name: Backend CI
+
+# Runs the full backend pytest suite on every change to backend/. This is the
+# net that catches regressions in the panel — including the agent gateway,
+# registry, pairing, and the panel<->agent command loop exercised end-to-end
+# by tests/test_agent_poll_e2e.py — instead of finding out at install time.
+
+on:
+ push:
+ branches: [dev, main]
+ paths:
+ - 'backend/**'
+ - '.github/workflows/backend-ci.yml'
+ pull_request:
+ branches: [dev, main]
+ paths:
+ - 'backend/**'
+ - '.github/workflows/backend-ci.yml'
+
+jobs:
+ pytest:
+ name: pytest
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.11'
+ cache: pip
+ cache-dependency-path: backend/requirements.txt
+ - name: Install dependencies
+ working-directory: backend
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r requirements.txt
+ - name: Run tests
+ working-directory: backend
+ run: python -m pytest -v
diff --git a/docs/AGENT_AUDIT.md b/docs/AGENT_AUDIT.md
index 35a7ff64..0dabc4bb 100644
--- a/docs/AGENT_AUDIT.md
+++ b/docs/AGENT_AUDIT.md
@@ -56,6 +56,15 @@ Severity counts: **3 High, 5 Medium, 7 Low/Informational.**
future caller can't bypass it. Cron is intentionally **not** AllowedPaths-
restricted (that would break legitimate jobs like `/usr/bin/certbot renew`);
its blast radius is addressed by M3 instead.
+- **M4 — fixed.** Added `.github/workflows/agent-ci.yml` (go vet + go test +
+ cross-compile build matrix for linux amd64/arm64 and windows/amd64 — darwin
+ excluded because the tray dep can't cross-compile from Linux) and
+ `backend-ci.yml` (full pytest suite). Also added
+ `backend/tests/test_agent_poll_e2e.py`, an end-to-end test that drives the
+ real panel↔agent command loop (HMAC auth → register → queue → poll → result →
+ the synchronous waiter resolves) over the poll transport, which shares the
+ WebSocket path's auth/registry/routing code. This is the "prove it actually
+ works" net the subsystem lacked.
- **M3 — fixed.** The DEB/RPM units now run as the dedicated unprivileged
`serverkit-agent` account with the same hardening as `install.sh`
(`NoNewPrivileges=yes`, `ProtectSystem=strict`, `ProtectHome=yes`,