Skip to content

Commit 46ec797

Browse files
authored
ci: run lint, test and typecheck on pull requests and main (#29)
1 parent 6d6206c commit 46ec797

File tree

7 files changed

+144
-6536
lines changed

7 files changed

+144
-6536
lines changed

.github/workflows/tests.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
env:
12+
YARN_CACHE_FOLDER: ~/.yarn
13+
14+
jobs:
15+
unit-tests:
16+
name: Unit tests
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: 14
28+
29+
- name: Caching
30+
uses: actions/cache@v2
31+
with:
32+
path: ${{ env.YARN_CACHE_FOLDER }}
33+
key: ${{ runner.OS }}-yarn-${{ hashFiles('**/yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.OS }}-yarn-${{ env.cache-name }}
36+
${{ runner.OS }}-yarn-
37+
38+
- name: Installing dependencies
39+
run: yarn install --frozen-lockfile
40+
41+
- name: Unit test
42+
run: yarn test
43+
44+
- uses: artiomtr/[email protected]
45+
if: "github.event_name == 'pull_request'"
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
skip-step: all
49+
50+
typecheck:
51+
name: Typecheck
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v2
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v1
61+
with:
62+
node-version: 14
63+
64+
- name: Caching
65+
uses: actions/cache@v2
66+
with:
67+
path: ${{ env.YARN_CACHE_FOLDER }}
68+
key: ${{ runner.OS }}-yarn-${{ hashFiles('**/yarn.lock') }}
69+
restore-keys: |
70+
${{ runner.OS }}-yarn-${{ env.cache-name }}
71+
${{ runner.OS }}-yarn-
72+
73+
- name: Installing dependencies
74+
run: yarn install --frozen-lockfile
75+
76+
- name: Typecheck
77+
run: yarn typecheck
78+
79+
lint:
80+
name: Lint
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v2
85+
with:
86+
fetch-depth: 0
87+
88+
- name: Setup Node.js
89+
uses: actions/setup-node@v1
90+
with:
91+
node-version: 14
92+
93+
- name: Caching
94+
uses: actions/cache@v2
95+
with:
96+
path: ${{ env.YARN_CACHE_FOLDER }}
97+
key: ${{ runner.OS }}-yarn-${{ hashFiles('**/yarn.lock') }}
98+
restore-keys: |
99+
${{ runner.OS }}-yarn-${{ env.cache-name }}
100+
${{ runner.OS }}-yarn-
101+
102+
- name: Installing dependencies
103+
run: yarn install --frozen-lockfile
104+
105+
- name: Lint
106+
run: yarn lint
107+
108+
check-format:
109+
name: Check format
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v2
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Setup Node.js
118+
uses: actions/setup-node@v1
119+
with:
120+
node-version: 14
121+
122+
- name: Caching
123+
uses: actions/cache@v2
124+
with:
125+
path: ${{ env.YARN_CACHE_FOLDER }}
126+
key: ${{ runner.OS }}-yarn-${{ hashFiles('**/yarn.lock') }}
127+
restore-keys: |
128+
${{ runner.OS }}-yarn-${{ env.cache-name }}
129+
${{ runner.OS }}-yarn-
130+
131+
- name: Installing dependencies
132+
run: yarn install --frozen-lockfile
133+
134+
- name: Check format
135+
run: yarn lint:format

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
coverage/
44
junit.xml
55
*.tgz
6+
report.json

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const config: Config.InitialOptions = {
1414
roots: ['<rootDir>/test'],
1515
moduleNameMapper,
1616
testEnvironment: 'jest-environment-jsdom',
17-
reporters: ['default', 'jest-junit'],
1817
collectCoverage: true,
19-
coverageReporters: ['json', 'text', 'cobertura'],
18+
coverageReporters: ['json'],
19+
testLocationInResults: true,
2020
};
2121

2222
export default config;

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
"scripts": {
2121
"build": "rollup -c rollup.config.ts --configPlugin rollup-plugin-typescript2",
2222
"clean": "rm -rf dist/ node_modules/",
23-
"lint": "prettier --check . && eslint --max-warnings 0 .",
23+
"lint": "eslint --max-warnings 0 .",
24+
"lint:format": "prettier --check .",
2425
"start": "rollup -c rollup.config.js --watch",
25-
"test": "NODE_OPTIONS=--experimental-vm-modules jest --forceExit --detectOpenHandles",
26+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --forceExit --detectOpenHandles --testLocationInResults --json --outputFile=report.json",
2627
"test:watch": "yarn test --watch",
28+
"typecheck": "tsc --noEmit",
2729
"release": "semantic-release"
2830
},
2931
"devDependencies": {
@@ -36,7 +38,6 @@
3638
"esbuild": "0.12.9",
3739
"eslint": "7.29.0",
3840
"jest": "26.6.3",
39-
"jest-junit": "12.2.0",
4041
"mongodb": "3.6.10",
4142
"prettier": "2.3.1",
4243
"rollup": "2.52.2",

0 commit comments

Comments
 (0)