-
Notifications
You must be signed in to change notification settings - Fork 15
51 lines (42 loc) · 1.43 KB
/
unit-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Unit Tests
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, edited]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install dependencies
run: npm install --save-dev --legacy-peer-deps
- name: Run Tests
run: npm run test
- name: Unit Test Coverage
uses: fylein/comment-test-coverage@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: coverage/coverage-summary.json
title: Unit Test Coverage
- name: Check Coverage Percentage
run: |
lines=$(jq '.total.lines.pct' < coverage/coverage-summary.json)
statements=$(jq '.total.statements.pct' < coverage/coverage-summary.json)
branches=$(jq '.total.branches.pct' < coverage/coverage-summary.json)
functions=$(jq '.total.functions.pct' < coverage/coverage-summary.json)
if (( $(echo "$lines < 95.0" | bc -l) || \
$(echo "$statements < 95.0" | bc -l) || \
$(echo "$branches < 91.10" | bc -l) || \
$(echo "$functions < 94.0" | bc -l) )); then
echo "Code Coverage Percentage is below 95%"
exit 1
fi