-
Notifications
You must be signed in to change notification settings - Fork 38
45 lines (45 loc) · 1.45 KB
/
cli-unit-test.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
name: Unit-Test
on:
push:
paths:
- cli/**
- sdk/**
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "14"
- name: Install Dependencies
run: npm install
- name: Run the tests
run: npm run js:coverage
- name: Code coverage
id: coverage
run: |
echo "total=$(sed -n 47p coverage/lcov-report/index.html | awk -F '>' '{print $2}' | awk -F '%' '{print $1}')" >> $GITHUB_OUTPUT
- name: Checkout master branch
uses: actions/checkout@v2
with:
ref: master
path: master
- name: Master branch code coverage
id: master-coverage
run: |
npm install
npm run js:coverage
echo "total=$(sed -n 47p coverage/lcov-report/index.html | awk -F '>' '{print $2}' | awk -F '%' '{print $1}')" >> $GITHUB_OUTPUT
working-directory: ./master
- name: Coverage threshold check
run: |
COVERAGE=${{ steps.coverage.outputs.total }}
MASTER_COVERAGE=${{ steps.master-coverage.outputs.total }}
COVERAGE_THRESHOLD=${{ vars.COVERAGE_THRESHOLD }}
if (( $(echo "$MASTER_COVERAGE - $COVERAGE > $COVERAGE_THRESHOLD" | bc -l) )) ; then
echo "coverage fell by more than $COVERAGE_THRESHOLD%"
exit 1
fi