File tree 6 files changed +3322
-156
lines changed
6 files changed +3322
-156
lines changed Original file line number Diff line number Diff line change 1
1
name : Verify Docs Formatting
2
2
3
- on : [push, pull_request]
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
4
8
5
9
permissions :
6
10
contents : read
Original file line number Diff line number Diff line change 1
- name : Verify Links
1
+ name : ci
2
2
3
- on : [push, pull_request]
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
4
8
5
9
permissions :
6
10
contents : read
7
11
8
12
jobs :
9
13
lint :
10
- name : ESLint
14
+ name : Lint
11
15
runs-on : ubuntu-latest
12
16
steps :
13
- - name : Checkout repository
14
- uses : actions/checkout@v4
15
-
16
- - name : Install Node v18
17
- uses : actions/setup-node@v4
17
+ - uses : actions/checkout@v4
18
+ - uses : actions/setup-node@v4
18
19
with :
19
- node-version : 18
20
+ node-version : 20
20
21
cache : npm
21
-
22
- - name : Install dependencies
23
- run : npm ci
24
-
25
- - name : Run ESLint
26
- run : npm run lint
27
-
22
+ - run : npm ci
23
+ - run : npm run lint
24
+ - run : npm run build
28
25
links :
29
26
name : Check Links
30
27
runs-on : ubuntu-latest
31
28
steps :
32
- - name : Checkout repository
33
- uses : actions/checkout@v4
34
-
35
- - name : Install Node v18
36
- uses : actions/setup-node@v4
29
+ - uses : actions/checkout@v4
30
+ - uses : actions/setup-node@v4
37
31
with :
38
- node-version : 18
32
+ node-version : 20
39
33
cache : npm
40
-
41
- - name : Install dependencies
42
- run : npm ci
43
-
44
- - name : Build
45
- run : npm run build
46
-
47
- - name : Run Link Checks
48
- run : npm run test:links
34
+ - run : npm ci
35
+ - run : npm run test:links
36
+ mdx :
37
+ name : Validate mdx
38
+ runs-on : ubuntu-latest
39
+ steps :
40
+ - uses : actions/checkout@v4
41
+ - uses : actions/setup-node@v4
42
+ with :
43
+ node-version : 20
44
+ cache : npm
45
+ - run : npm ci
46
+ - run : npm run test:build
Original file line number Diff line number Diff line change
1
+ import fs from "node:fs/promises" ;
2
+ import path from "node:path" ;
3
+ import { compile } from "@mdx-js/mdx" ;
4
+
5
+ const args = process . argv . slice ( 2 ) ;
6
+ const bail = args . includes ( "--bail" ) ;
7
+
8
+ const ROOT_DIR = path . join ( import . meta. dirname , ".." ) ;
9
+ const DOCS_DIR = path . join ( ROOT_DIR , "docs" ) ;
10
+
11
+ const extensions = [ ".mdx" , ".md" ] ;
12
+ let hasErrors = false ;
13
+
14
+ for ( const docsRelativePath of await fs . readdir ( DOCS_DIR , { recursive : true } ) ) {
15
+ const filePath = path . join ( DOCS_DIR , docsRelativePath ) ;
16
+ const rootRelPath = path . relative ( ROOT_DIR , filePath ) ;
17
+
18
+ if ( extensions . includes ( path . extname ( filePath ) ) ) {
19
+ try {
20
+ console . error ( `Compiling ${ rootRelPath } ` ) ;
21
+ await compile ( await fs . readFile ( filePath ) , {
22
+ format : path . extname ( filePath ) === ".mdx" ? "mdx" : "md" ,
23
+ } ) ;
24
+ } catch ( error ) {
25
+ console . error ( `Error compiling ${ rootRelPath } :` ) ;
26
+ console . error ( error ) ;
27
+ hasErrors = true ;
28
+ if ( bail ) {
29
+ process . exit ( 1 ) ;
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ if ( hasErrors ) {
36
+ process . exit ( 1 ) ;
37
+ }
You can’t perform that action at this time.
0 commit comments