chore: add mandatory test concept and smoke-test workflow

This commit is contained in:
openclaw 2026-03-04 18:28:50 +00:00
parent d08e6f8a17
commit d2ed667f0c
3 changed files with 59 additions and 2 deletions

36
TESTING.md Normal file
View file

@ -0,0 +1,36 @@
# Testkonzept helpyourneighbour
Dieses Testkonzept ist **verpflichtend vor jedem Push**.
## Ziel
Stabile, sichere Releases durch standardisierte Tests in Docker auf dem Unraid-Host.
## Pflichtablauf (immer)
1. **Lokaler Schnelltest**
- `cd backend && npm ci && npm test`
2. **Docker-Test auf Unraid**
- Image bauen und Smoke-Test im Container ausführen.
3. **Erst danach pushen**
- Wenn ein Test fehlschlägt: kein Push, zuerst Fix.
## Docker-Standard (Unraid)
Im Repo-Root ausführen:
```bash
docker run --rm -t \
-v "$PWD":/app \
-w /app/backend \
node:22-bookworm \
bash -lc "npm ci && npm test"
```
## Mindest-Testumfang
- Syntax-Validierung aller Backend-JS-Dateien (`node --check`)
- Smoke-Test-Exitcode 0
## Erweiterung (nächster Schritt)
- API-Integrationstests (Auth, Requests, Offers, Contacts)
- DB-Container für reproduzierbare End-to-End-Tests
## Verbindlichkeit
Dieses Konzept gilt als Standardprozess für alle weiteren Änderungen in `helpyourneighbour`.

View file

@ -4,11 +4,12 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "npm run test:smoke",
"start": "node src/server.js", "start": "node src/server.js",
"dev": "node --watch src/server.js", "dev": "node --watch src/server.js",
"db:init": "node src/db/init.js", "db:init": "node src/db/init.js",
"db:seed": "node src/db/seed.js" "db:seed": "node src/db/seed.js",
"test:smoke": "node scripts/smoke-test.mjs"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

View file

@ -0,0 +1,20 @@
import { spawn } from 'node:child_process';
const run = (cmd, args, opts = {}) =>
new Promise((resolve, reject) => {
const p = spawn(cmd, args, { stdio: 'inherit', ...opts });
p.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`${cmd} exited with ${code}`))));
});
const main = async () => {
await run('bash', ['-lc', 'find src -name "*.js" -print0 | xargs -0 -n1 node --check'], {
cwd: process.cwd(),
});
console.log('Smoke test passed: syntax checks OK');
};
main().catch((err) => {
console.error('Smoke test failed:', err.message);
process.exit(1);
});