-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (38 loc) · 1.02 KB
/
coverage.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
name: Coverage
on:
push:
branches:
- main
- developer
pull_request:
branches:
- main
- developer
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20.17.0'
- name: Install dependencies
run: npm install
- name: Generate test coverage
run: npm run coverage | tee coverage_output.txt
- name: Show coverage output
run: cat coverage_output.txt
- name: Check coverage threshold
run: |
COVERAGE=$(grep -oP 'All files\s+\|\s+\K[0-9]+(?=\s+\|)' coverage_output.txt)
echo "Coverage is at $COVERAGE%"
if [ -z "$COVERAGE" ]; then
echo "No coverage value found, failing the job."
exit 1
fi
if [ "$COVERAGE" -lt 80 ]; then
echo "Coverage is below 80%, failing the job."
exit 1
fi