Skip to content

Commit 3f97db6

Browse files
authored
Chore/add jest (#88)
update dependencies and remove unnecessary ones setup jest and ESLint limit CI jobs adjust ci for new ts output directory cc @ktrz on performance alert
1 parent 5d6c8c4 commit 3f97db6

33 files changed

+11320
-6404
lines changed

.eslintrc.json

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
{
2-
"extends": [
3-
"eslint:recommended",
4-
"plugin:@typescript-eslint/recommended",
5-
"prettier",
6-
"prettier/@typescript-eslint",
7-
"plugin:prettier/recommended"
8-
],
9-
"parser": "@typescript-eslint/parser",
10-
"parserOptions": {
11-
"project": "./tsconfig.json"
12-
},
13-
"plugins": [
14-
"@typescript-eslint",
15-
"prettier"
16-
],
17-
"env": {
18-
"es6": true,
19-
"mocha": true,
20-
"node": true
21-
},
22-
"rules": {
23-
"prefer-spread": "off",
24-
"@typescript-eslint/explicit-function-return-type": "off",
25-
"@typescript-eslint/explicit-member-accessibility": "off",
26-
"eqeqeq": "error",
2+
"root": true,
3+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:prettier/recommended"],
4+
"env": {
5+
"es6": true,
6+
"node": true
7+
},
8+
"rules": {
9+
"prefer-spread": "off",
10+
"eqeqeq": "error"
11+
},
12+
"ignorePatterns": ["examples/**", "dist/**"],
13+
"overrides": [
14+
{
15+
"files": ["**/*.ts"],
16+
"parser": "@typescript-eslint/parser",
17+
"parserOptions": {
18+
"project": ["./tsconfig.build.json", "./tsconfig.spec.json"]
19+
},
20+
"plugins": ["@typescript-eslint", "prettier"],
21+
"rules": {
22+
"@typescript-eslint/naming-convention": "error",
2723
"@typescript-eslint/no-floating-promises": "error",
2824
"@typescript-eslint/no-unnecessary-type-arguments": "error",
2925
"@typescript-eslint/no-non-null-assertion": "error",
@@ -32,7 +28,7 @@
3228
"@typescript-eslint/no-extra-non-null-assertion": "error",
3329
"@typescript-eslint/prefer-nullish-coalescing": "error",
3430
"@typescript-eslint/prefer-optional-chain": "error",
35-
"@typescript-eslint/ban-ts-ignore": "error",
31+
"@typescript-eslint/ban-ts-comment": "error",
3632
"@typescript-eslint/prefer-includes": "error",
3733
"@typescript-eslint/prefer-for-of": "error",
3834
"@typescript-eslint/prefer-string-starts-ends-with": "error",
@@ -41,26 +37,27 @@
4137
"@typescript-eslint/await-thenable": "error",
4238
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
4339
"@typescript-eslint/switch-exhaustiveness-check": "error"
40+
}
41+
},
42+
{
43+
"files": ["test/*.ts"],
44+
"plugins": ["jest"],
45+
"env": {
46+
"jest/globals": true
47+
},
48+
"rules": {
49+
"@typescript-eslint/no-explicit-any": "off",
50+
"@typescript-eslint/no-var-requires": "off",
51+
"@typescript-eslint/ban-ts-comment": "warn",
52+
"@typescript-eslint/naming-convention": "off"
53+
}
4454
},
45-
"overrides": [
46-
{
47-
"files": [
48-
"test/*.ts"
49-
],
50-
"plugins": [
51-
"mocha"
52-
],
53-
"extends": [
54-
"plugin:mocha/recommended"
55-
],
56-
"rules": {
57-
"@typescript-eslint/no-explicit-any": "off",
58-
"@typescript-eslint/no-var-requires": "off",
59-
"@typescript-eslint/camelcase": "off",
60-
"mocha/no-setup-in-describe": "off",
61-
"mocha/no-hooks-for-single-case": "off",
62-
"mocha/no-exclusive-tests": "error"
63-
}
64-
}
65-
]
55+
{
56+
"files": ["**/*.js"],
57+
"env": {
58+
"browser": true
59+
},
60+
"rules": {}
61+
}
62+
]
6663
}

.github/workflows/benchmarkjs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
alert-threshold: '200%'
3030
comment-on-alert: true
3131
fail-on-alert: true
32-
alert-comment-cc-users: '@rhysd'
32+
alert-comment-cc-users: '@ktrz'

.github/workflows/catch2.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
uses: benchmark-action/github-action-benchmark@v1
2626
with:
2727
name: Catch2 Benchmark
28-
tool: "catch2"
28+
tool: 'catch2'
2929
output-file-path: examples/catch2/benchmark_result.txt
3030
github-token: ${{ secrets.GITHUB_TOKEN }}
3131
auto-push: true
3232
# Show alert with commit comment on detecting possible performance regression
33-
alert-threshold: "200%"
33+
alert-threshold: '200%'
3434
comment-on-alert: true
3535
fail-on-alert: true
36-
alert-comment-cc-users: "@bernedom,@rhysd"
36+
alert-comment-cc-users: '@bernedom,@ktrz'

.github/workflows/ci.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: CI
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
39

410
jobs:
511
rust:
@@ -31,7 +37,7 @@ jobs:
3137
output-file-path: examples/rust/output.txt
3238
skip-fetch-gh-pages: true
3339
fail-on-alert: true
34-
- run: node ./scripts/ci_validate_modification.js before_data.js 'Rust Benchmark'
40+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Rust Benchmark'
3541
go:
3642
name: Run Go benchmark example
3743
runs-on: ubuntu-latest
@@ -61,7 +67,7 @@ jobs:
6167
output-file-path: examples/go/output.txt
6268
skip-fetch-gh-pages: true
6369
fail-on-alert: true
64-
- run: node ./scripts/ci_validate_modification.js before_data.js 'Go Benchmark'
70+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Go Benchmark'
6571
benchmarkjs:
6672
name: Run JavaScript benchmark example
6773
runs-on: ubuntu-latest
@@ -90,7 +96,7 @@ jobs:
9096
output-file-path: examples/benchmarkjs/output.txt
9197
skip-fetch-gh-pages: true
9298
fail-on-alert: true
93-
- run: node ./scripts/ci_validate_modification.js before_data.js 'Benchmark.js Benchmark'
99+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Benchmark.js Benchmark'
94100
pytest-benchmark:
95101
name: Run Pytest benchmark example
96102
runs-on: ubuntu-latest
@@ -125,7 +131,7 @@ jobs:
125131
output-file-path: examples/pytest/output.json
126132
skip-fetch-gh-pages: true
127133
fail-on-alert: true
128-
- run: node ./scripts/ci_validate_modification.js before_data.js 'Python Benchmark with pytest-benchmark'
134+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Python Benchmark with pytest-benchmark'
129135
google-benchmark-framework:
130136
name: Run Google C++ Benchmark Framework example
131137
runs-on: ubuntu-latest
@@ -161,7 +167,7 @@ jobs:
161167
output-file-path: examples/cpp/benchmark_result.json
162168
skip-fetch-gh-pages: true
163169
fail-on-alert: true
164-
- run: node ./scripts/ci_validate_modification.js before_data.js 'C++ Benchmark'
170+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'C++ Benchmark'
165171
catch2-framework:
166172
name: Run Catch2 C++ Benchmark Framework example
167173
runs-on: ubuntu-latest
@@ -191,11 +197,11 @@ jobs:
191197
uses: ./
192198
with:
193199
name: Catch2 Benchmark
194-
tool: "catch2"
200+
tool: 'catch2'
195201
output-file-path: examples/catch2/benchmark_result.txt
196202
skip-fetch-gh-pages: true
197203
fail-on-alert: true
198-
- run: node ./scripts/ci_validate_modification.js before_data.js 'Catch2 Benchmark'
204+
- run: node ./dist/scripts/ci_validate_modification.js before_data.js 'Catch2 Benchmark'
199205

200206
only-alert-with-cache:
201207
name: Run alert check with actions/cache
@@ -228,7 +234,7 @@ jobs:
228234
alert-threshold: '200%'
229235
comment-on-alert: true
230236
fail-on-alert: true
231-
alert-comment-cc-users: '@rhysd'
237+
alert-comment-cc-users: '@ktrz'
232238
unit-tests:
233239
name: Run unit tests
234240
runs-on: ubuntu-latest
@@ -242,11 +248,25 @@ jobs:
242248
path: ~/.npm
243249
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
244250
- run: npm ci
245-
- run: npm run lint
246-
- run: npm run build
247251
- run: npm run coverage
248252
- name: Apply yamllint
249253
run: |
250254
sudo pip install yamllint
251255
yamllint --strict .github/workflows
252256
- uses: codecov/codecov-action@v2
257+
258+
lint:
259+
name: Run linting and formatting check
260+
runs-on: ubuntu-latest
261+
steps:
262+
- uses: actions/checkout@v2
263+
- uses: actions/setup-node@v1
264+
with:
265+
node-version: 12
266+
- uses: actions/cache@v1
267+
with:
268+
path: ~/.npm
269+
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
270+
- run: npm ci
271+
- run: npm run lint
272+
- run: npm run format:check

.github/workflows/commit-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
alert-threshold: '200%'
3434
comment-on-alert: true
3535
fail-on-alert: true
36-
alert-comment-cc-users: '@rhysd'
36+
alert-comment-cc-users: '@ktrz'

.github/workflows/cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
alert-threshold: '200%'
3434
comment-on-alert: true
3535
fail-on-alert: true
36-
alert-comment-cc-users: '@rhysd'
36+
alert-comment-cc-users: '@ktrz'

.github/workflows/criterion-rs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
alert-threshold: '200%'
3030
comment-on-alert: true
3131
fail-on-alert: true
32-
alert-comment-cc-users: '@rhysd'
32+
alert-comment-cc-users: '@ktrz'

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
alert-threshold: '200%'
3030
comment-on-alert: true
3131
fail-on-alert: true
32-
alert-comment-cc-users: '@rhysd'
32+
alert-comment-cc-users: '@ktrz'

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
alert-threshold: '200%'
3636
comment-on-alert: true
3737
fail-on-alert: true
38-
alert-comment-cc-users: '@rhysd'
38+
alert-comment-cc-users: '@ktrz'

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
alert-threshold: '200%'
3030
comment-on-alert: true
3131
fail-on-alert: true
32-
alert-comment-cc-users: '@rhysd'
32+
alert-comment-cc-users: '@ktrz'

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/node_modules
2-
/src/*.js
3-
/src/*.js.map
42
/examples/rust/Cargo.lock
53
/examples/rust/target
64
/examples/criterion-rs/Cargo.lock
75
/examples/criterion-rs/target
8-
/test/*.js
9-
/test/*.js.map
10-
/scripts/*.js
11-
/scripts/*.js.map
126
/.nyc_output
137
/coverage
8+
/dist
9+
/.idea

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
test/data
2+
coverage
3+
dist
4+
**/*.md
5+
**/*.txt

.prettierrc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33
"semi": true,
44
"singleQuote": true,
55
"trailingComma": "all",
6-
"printWidth": 120
6+
"printWidth": 120,
7+
"overrides": [
8+
{
9+
"files": ["**/*.{yml,json}"],
10+
"options": {
11+
"tabWidth": 2
12+
}
13+
}
14+
]
715
}

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ inputs:
7272

7373
runs:
7474
using: 'node12'
75-
main: 'src/index.js'
75+
main: 'dist/src/index.js'

examples/benchmarkjs/bench.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ suite
99
.add('fib(20)', () => {
1010
fib(20);
1111
})
12-
.on('cycle', event => {
12+
.on('cycle', (event) => {
1313
console.log(String(event.target));
1414
})
1515
.run();

jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
globals: {
4+
'ts-jest': {
5+
tsconfig: 'tsconfig.spec.json',
6+
},
7+
},
8+
preset: 'ts-jest',
9+
testEnvironment: 'node',
10+
};

0 commit comments

Comments
 (0)