diff --git a/.gitea/workflows/check.yml b/.gitea/workflows/check.yml new file mode 100644 index 00000000..f0bdb2c4 --- /dev/null +++ b/.gitea/workflows/check.yml @@ -0,0 +1,18 @@ +# Tests bei jedem Push (lessons-bimcraft [57]). Braucht einen Gitea-Actions-Runner mit +# Docker/Node; ohne Runner passiert nichts. Die WASM-Pakete (src/engine/pkg*) sind nicht im +# Repo und werden hier gebaut, weil Tests wie truckBrep.wasm.test.ts sie lesen. +name: check +on: [push, pull_request] +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: { node-version: 22, cache: npm } + - uses: dtolnay/rust-toolchain@stable + with: { targets: wasm32-unknown-unknown } + - run: cargo install wasm-pack --locked + - run: npm ci + - run: npm run build:truck && npm run build:engine3d && npm run build:engine && npm run build:kernel2d && npm run build:dwgimport + - run: npm run check diff --git a/package.json b/package.json index c800e9dd..2cc662ea 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "preview": "vite preview", "test": "vitest run", "test:watch": "vitest", + "check": "node scripts/check.mjs", "tauri": "tauri", "tauri:dev": "node scripts/tauri-native.mjs dev", "tauri:build": "node scripts/tauri-native.mjs build", diff --git a/scripts/check.mjs b/scripts/check.mjs new file mode 100644 index 00000000..93d865b8 --- /dev/null +++ b/scripts/check.mjs @@ -0,0 +1,31 @@ +// Fester Check vor jedem Abschluss (lessons-bimcraft [22]): TypeScript, Vitest und die +// Rust-Tests aller eigenständigen Crates. Bricht beim ersten Fehler ab. +// npm run check alles +// npm run check -- --fast nur tsc + vitest +// `cargo fmt`/`clippy` sind noch nicht Teil des Checks: die Crates sind nie formatiert +// worden (ein Reformat wäre ein Riesen-Diff) — eigener Schritt, s. docs/lessons-bimcraft.md. +import { spawnSync } from "node:child_process"; + +const fast = process.argv.includes("--fast"); +const crates = ["render2d", "render3d", "kernel2d", "trucksolid", "dwgimport"]; +const steps = [ + { name: "tsc", cmd: "npx", args: ["tsc", "--noEmit", "-p", "."] }, + { name: "vitest", cmd: "npx", args: ["vitest", "run"] }, + ...(fast ? [] : crates.map((c) => ({ name: `cargo test ${c}`, cmd: "cargo", args: ["test", "--quiet"], cwd: `src-tauri/${c}` }))), +]; + +const t0 = Date.now(); +for (const s of steps) { + const t = Date.now(); + process.stdout.write(`▶ ${s.name} … `); + const r = spawnSync(s.cmd, s.args, { cwd: s.cwd, encoding: "utf8" }); + const secs = ((Date.now() - t) / 1000).toFixed(1); + if (r.status !== 0) { + console.log(`FEHLER (${secs}s)\n`); + console.log((r.stdout ?? "").split("\n").slice(-40).join("\n")); + console.log(r.stderr ?? ""); + process.exit(1); + } + console.log(`ok (${secs}s)`); +} +console.log(`\nAlles grün (${((Date.now() - t0) / 1000).toFixed(0)}s).`);