Skip to content

Commit 07c5ee0

Browse files
committed
ci: add unit tests workflow (#2)
1 parent 247d2ad commit 07c5ee0

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: 'pnpm'
31+
32+
- name: Install dependencies
33+
run: pnpm install --frozen-lockfile
34+
35+
- name: Run linter
36+
run: pnpm lint
37+
38+
- name: Run tests
39+
run: pnpm test:run
40+
41+
- name: Generate coverage report
42+
run: pnpm test:coverage
43+
44+
- name: Upload coverage to Codecov
45+
uses: codecov/codecov-action@v4
46+
with:
47+
files: ./coverage/coverage-final.json
48+
flags: unittests
49+
name: codecov-umbrella
50+
fail_ci_if_error: false
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53+
54+
- name: Comment coverage on PR
55+
if: github.event_name == 'pull_request'
56+
uses: romeovs/lcov-reporter-action@v0.3.1
57+
with:
58+
lcov-file: ./coverage/lcov.info
59+
github-token: ${{ secrets.GITHUB_TOKEN }}
60+
delete-old-comments: true

0 commit comments

Comments
 (0)