Skip to content

Commit 4061392

Browse files
committed
Add automation for markdown spec build/lint
1 parent bf7bfd9 commit 4061392

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
name: JSON Schema
22
on:
33
- push
4+
- pull_request
5+
46
jobs:
57
specs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: latest
14+
cache: npm
15+
- run: npm ci
16+
- run: npm run lint
17+
- run: npm run build-all
18+
19+
specs-old:
620
runs-on: ubuntu-22.04
721
steps:
822
- uses: actions/checkout@v3

build/build.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dotenv.config();
2323

2424
const build = async (filename) => {
2525
const md = readFileSync(filename, "utf-8");
26-
const html = await remark()
26+
const file = await remark()
2727
.use(remarkPresetLintMarkdownStyleGuide)
2828
.use(remarkGfm)
2929
.use(remarkHeadingId)
@@ -164,11 +164,13 @@ const build = async (filename) => {
164164
</style>
165165
</head>
166166
<body>
167-
${html.toString()}
167+
${file.toString()}
168168
</body>
169169
</html>`);
170170

171-
console.error(reporter(html));
171+
console.error(reporter(file));
172+
173+
return file.messages.length;
172174
};
173175

174176
(async function () {
@@ -177,9 +179,14 @@ const build = async (filename) => {
177179
console.error("WARNING: No files built. Usage: 'npm run build -- filename.md'");
178180
}
179181

182+
let messageCount = 0;
180183
for (const filename of files) {
181184
console.log(`Building: ${filename} ...`);
182-
await build(filename);
185+
messageCount += await build(filename);
183186
console.log("");
184187
}
188+
189+
if (messageCount > 0) {
190+
process.exit(1);
191+
}
185192
}());

0 commit comments

Comments
 (0)