File tree 9 files changed +65
-42
lines changed
9 files changed +65
-42
lines changed Original file line number Diff line number Diff line change 7
7
runs-on : ubuntu-latest
8
8
steps :
9
9
- uses : actions/checkout@v3
10
- - uses : actions/setup-go@v3
11
- - uses : actions/setup-node@v3
12
- - run : yarn install
13
- - run : make build
14
- - run : yarn test
10
+
11
+ - name : Setup Go
12
+ uses : actions/setup-go@v3
13
+
14
+ - name : Setup Node
15
+ uses : actions/setup-node@v3
16
+
17
+ - name : Install dependencies
18
+ run : yarn install
19
+
20
+ - name : Build
21
+ run : make build
22
+
23
+ - name : Test
24
+ run : yarn test
25
+
15
26
- name : Integration test
16
27
run : |
17
28
dir=$(pwd)
18
29
tmp=$(mktemp -d)
19
30
20
31
yarn pack
21
- cd $tmp
32
+ cd " $tmp" || exit 1
22
33
yarn init -y
23
- yarn add "$dir/actionlint-v0.0.0.tgz"
34
+ yarn add "$dir/actionlint-v0.0.0.tgz" typescript @types/node
24
35
25
36
# verify package exports
26
37
ls -la "node_modules/actionlint/$(jq ".exports.types" -r node_modules/actionlint/package.json)"
27
38
ls -la "node_modules/actionlint/$(jq ".exports.node.import" -r node_modules/actionlint/package.json)"
28
39
ls -la "node_modules/actionlint/$(jq ".exports.node.require" -r node_modules/actionlint/package.json)"
29
40
ls -la "node_modules/actionlint/$(jq ".exports.browser" -r node_modules/actionlint/package.json)"
30
41
31
- cat << EOF > test.js
32
- const linter = require( 'actionlint').createLinter() ;
33
- linter ('on: psuh', 'push.yml').then(
42
+ cat << EOF > test.mjs
43
+ import { createLinter } from 'actionlint';
44
+ createLinter() ('on: psuh', 'push.yml').then(
34
45
(results) => process.exit(results.length > 0 ? 0 : 1),
35
46
(err) => { console.error(err); process.exit(1); }
36
47
);
37
48
EOF
38
49
39
50
# test that the linter works
40
- node test.js
51
+ node test.mjs
52
+
53
+ # test that the types are correctly included
54
+ mv test.mjs test.ts
55
+ yarn tsc --noEmit --strict ./test.ts
56
+
41
57
- name : release
42
58
if : github.ref == 'refs/heads/main'
43
59
run : npx --yes semantic-release --branches main
Original file line number Diff line number Diff line change
1
+ .github /
2
+ .vscode /
3
+ go.mod
4
+ go.sum
5
+ globals.d.ts
6
+ main.go
7
+ Makefile
8
+ renovate.json
9
+ test.mjs
10
+ tsconfig.json
11
+ yarn.lock
Original file line number Diff line number Diff line change @@ -2,14 +2,8 @@ require("./wasm_exec.js");
2
2
3
3
/**
4
4
* @typedef {(go: Go) => Promise<WebAssembly.WebAssemblyInstantiatedSource> } WasmLoader
5
- * @typedef {(source: string, path: string) => Promise<LintResult[]> } RunActionlint
6
- *
7
- * @typedef {Object } LintResult
8
- * @property {string } Message
9
- * @property {string } Filepath
10
- * @property {number } Line
11
- * @property {number } Column
12
- * @property {string } Kind
5
+ * @typedef {import("./types").RunActionlint } RunActionlint
6
+ * @typedef {import("./types").LintResult } LintResult
13
7
*/
14
8
15
9
/**
Original file line number Diff line number Diff line change 1
1
import { createActionlint } from "./actionlint.cjs" ;
2
2
3
3
/**
4
- * @typedef {import("./actionlint.cjs").LintResult } LintResult
5
- * @typedef {import("./actionlint.cjs ").WasmLoader } WasmLoader
6
- * @typedef {import("./actionlint.cjs ").RunActionlint } RunActionlint
4
+ * @typedef {(go: Go) => Promise<WebAssembly.WebAssemblyInstantiatedSource> } WasmLoader
5
+ * @typedef {import("./types ").RunActionlint } RunActionlint
6
+ * @typedef {import("./types ").LintResult } LintResult
7
7
*/
8
8
9
9
/** @type {RunActionlint | undefined } */
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ const { readFile } = require("node:fs/promises");
4
4
const { createActionlint } = require ( "./actionlint.cjs" ) ;
5
5
6
6
/**
7
- * @typedef {import("./actionlint.cjs").LintResult } LintResult
8
- * @typedef {import("./actionlint.cjs ").WasmLoader } WasmLoader
9
- * @typedef {import("./actionlint.cjs ").RunActionlint } RunActionlint
7
+ * @typedef {(go: Go) => Promise<WebAssembly.WebAssemblyInstantiatedSource> } WasmLoader
8
+ * @typedef {import("./types ").RunActionlint } RunActionlint
9
+ * @typedef {import("./types ").LintResult } LintResult
10
10
*/
11
11
12
12
/** @type {RunActionlint | undefined } */
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import { readFile } from "node:fs/promises";
2
2
import { createActionlint } from "./actionlint.cjs" ;
3
3
4
4
/**
5
- * @typedef {import("./actionlint.cjs").LintResult } LintResult
6
- * @typedef {import("./actionlint.cjs ").WasmLoader } WasmLoader
7
- * @typedef {import("./actionlint.cjs ").RunActionlint } RunActionlint
5
+ * @typedef {(go: Go) => Promise<WebAssembly.WebAssemblyInstantiatedSource> } WasmLoader
6
+ * @typedef {import("./types ").RunActionlint } RunActionlint
7
+ * @typedef {import("./types ").LintResult } LintResult
8
8
*/
9
9
10
10
/** @type {RunActionlint | undefined } */
Original file line number Diff line number Diff line change 7
7
"test" : " tape test.mjs | tap-spec"
8
8
},
9
9
"main" : " ./node.cjs" ,
10
+ "types" : " ./types.d.ts" ,
10
11
"exports" : {
11
- "types" : " ./types/node .d.mts " ,
12
+ "types" : " ./types.d.ts " ,
12
13
"node" : {
13
14
"import" : " ./node.mjs" ,
14
15
"require" : " ./node.cjs"
15
16
},
16
17
"browser" : " ./browser.mjs"
17
18
},
18
- "files" : [
19
- " actionlint.cjs" ,
20
- " browser.mjs" ,
21
- " main.wasm" ,
22
- " node.cjs" ,
23
- " node.mjs" ,
24
- " types/node.d.mts" ,
25
- " wasm_exec.js"
26
- ],
27
19
"devDependencies" : {
28
20
"@types/golang-wasm-exec" : " ^1.15.0" ,
29
21
"@types/node" : " ^17.0.21" ,
Original file line number Diff line number Diff line change 9
9
"moduleResolution" : " node" ,
10
10
"allowJs" : true ,
11
11
"checkJs" : true ,
12
- "declaration" : true ,
13
- "emitDeclarationOnly" : true ,
12
+ "noEmit" : true ,
14
13
"esModuleInterop" : true ,
15
14
"forceConsistentCasingInFileNames" : true ,
16
15
"strict" : true ,
17
- "skipLibCheck" : true ,
18
- "outDir" : " ./types"
16
+ "skipLibCheck" : true
19
17
}
20
18
}
Original file line number Diff line number Diff line change
1
+ export type RunActionlint = (
2
+ source : string ,
3
+ path : string
4
+ ) => Promise < LintResult [ ] > ;
5
+ export type LintResult = {
6
+ Message : string ;
7
+ Filepath : string ;
8
+ Line : number ;
9
+ Column : number ;
10
+ Kind : string ;
11
+ } ;
12
+ export function createLinter ( url ?: URL ) : RunActionlint ;
You can’t perform that action at this time.
0 commit comments