Skip to content

Self-hosted monitoring for homelabs: host and container metrics and uptime checks from all your machines in one dashboard, with an optional AI agent that diagnoses incidents and suggests fixes.

ci: run tests and lint on every pull request

Karlo Kajba Šimanić41b29096ff03
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..7c49911
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,45 @@
+# Runs the backend tests, the frontend helper tests and the frontend linter on every pull request and on pushes
+# to main. Needs no services: the backend tests use an in-memory database and fakes (see TESTS.md).
+# Third-party actions are pinned to commit hashes; update them deliberately.
+name: Tests
+
+on:
+ pull_request:
+ push:
+ branches: [main]
+
+permissions:
+ contents: read
+
+jobs:
+ backend:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
+ with:
+ python-version: "3.12"
+ cache: pip
+ cache-dependency-path: requirements*.txt
+ - run: pip install -r requirements-dev.txt
+ - run: pytest
+
+ frontend:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: src/frontend
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ with:
+ node-version: "20"
+ cache: npm
+ cache-dependency-path: src/frontend/package-lock.json
+ - run: npm ci
+ - run: node --test
+ - run: npx oxlint
diff --git a/tests/collectors/test_pending_collectors.py b/tests/collectors/test_pending_collectors.py
index 128477d..b7984cf 100644
--- a/tests/collectors/test_pending_collectors.py
+++ b/tests/collectors/test_pending_collectors.py
@@ -326,5 +326,6 @@ def test_a_bad_token_is_refused_even_in_open_mode(db):
def test_install_info_reports_the_configured_addresses(db, monkeypatch):
monkeypatch.setattr(main, "COLLECTOR_PUBLIC_URL", "http://10.8.0.1:8081/api")
monkeypatch.setattr(main, "COLLECTOR_IMAGE", "ghcr.io/o/c@sha256:abc")
+ monkeypatch.setattr(main, "DOCKER_PROXY_IMAGE", "")
info = monitoring_routes.install_info(session_id="s", db=db)
assert info == {"strict": False, "collector_url": "http://10.8.0.1:8081/api", "collector_image": "ghcr.io/o/c@sha256:abc", "proxy_image": None}