Skip to content

Commit 6094edb

Browse files
committed
chore(ci): Add smoke tests to CI and release workflows
1 parent 64fac49 commit 6094edb

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ jobs:
2828

2929
- name: Build
3030
run: npm run build
31+
32+
- name: Smoke test
33+
run: node smoke.js

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
- name: Unit Tests
4444
run: pnpm test
4545

46+
- name: Smoke test
47+
run: node smoke.js
48+
4649
- name: Semantic Release
4750
run: npx semantic-release
4851
env:

smoke.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const root = __dirname;
5+
const files = {
6+
json: path.join(root, "dist", "openapi.json"),
7+
yaml: path.join(root, "dist", "openapi.yaml"),
8+
ts: path.join(root, "openapi.ts"),
9+
};
10+
11+
let failed = false;
12+
13+
// JSON parse check
14+
try {
15+
JSON.parse(fs.readFileSync(files.json, "utf8"));
16+
console.log("OK: openapi.json is valid JSON");
17+
} catch (e) {
18+
console.error("FAIL: openapi.json is not valid JSON:", e.message);
19+
failed = true;
20+
}
21+
22+
// YAML basic structure check
23+
try {
24+
const yaml = fs.readFileSync(files.yaml, "utf8");
25+
if (!yaml.includes("openapi:")) throw new Error("Missing openapi: key");
26+
console.log("OK: openapi.yaml has valid structure");
27+
} catch (e) {
28+
console.error("FAIL: openapi.yaml:", e.message);
29+
failed = true;
30+
}
31+
32+
// TypeScript file exists and is non-empty
33+
try {
34+
const ts = fs.readFileSync(files.ts, "utf8");
35+
if (ts.length === 0) throw new Error("File is empty");
36+
console.log("OK: openapi.ts is non-empty");
37+
} catch (e) {
38+
console.error("FAIL: openapi.ts:", e.message);
39+
failed = true;
40+
}
41+
42+
if (failed) process.exit(1);

0 commit comments

Comments
 (0)