Skip to content

Commit 4aebe43

Browse files
committed
Add automation to check that annotation tests are valid
1 parent dd858d0 commit 4aebe43

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Validate annotation tests
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
annotate:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Deno
14+
uses: denoland/setup-deno@v2
15+
with:
16+
deno-version: "2.x"
17+
18+
- name: Validate annotation tests
19+
run: deno --node-modules-dir=auto --allow-read --no-prompt bin/annotation-tests.ts

bin/annotation-tests.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env deno
2+
import { validate } from "npm:@hyperjump/json-schema/draft-07";
3+
import { BASIC } from "npm:@hyperjump/json-schema/experimental";
4+
5+
const validateTestSuite = await validate("./annotations/test-suite.schema.json");
6+
7+
console.log("Validating annotation tests ...");
8+
9+
let isValid = true;
10+
for await (const entry of Deno.readDir("./annotations/tests")) {
11+
if (entry.isFile) {
12+
const json = await Deno.readTextFile(`./annotations/tests/${entry.name}`);
13+
const suite = JSON.parse(json);
14+
15+
const output = validateTestSuite(suite, BASIC);
16+
17+
if (output.valid) {
18+
console.log(`\x1b[32m✔\x1b[0m ${entry.name}`);
19+
} else {
20+
isValid = false;
21+
console.log(`\x1b[31m✖\x1b[0m ${entry.name}`);
22+
console.log(output);
23+
}
24+
}
25+
}
26+
27+
console.log("Done.");
28+
29+
if (!isValid) {
30+
Deno.exit(1);
31+
}

0 commit comments

Comments
 (0)