Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 2d0c361

Browse files
committed
add min_coverage input
1 parent 2c10c1b commit 2d0c361

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ A Github Action which helps enforce a minimum code coverage threshold.
88

99
**Required** The path to the `lcov.info` file.
1010

11+
### `min_coverage`
12+
13+
**Required** The minimum coverage percentage allowed.
14+
15+
**Default** 100
16+
1117
## Example usage
1218

1319
```yaml
1420
uses: ChicagoFlutter/lcov-cop@master
1521
with:
16-
path: './coverage/lcov.info'
17-
```
22+
path: "./coverage/lcov.info"
23+
min_coverage: 95
24+
```

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ inputs:
88
path:
99
description: 'lcov path'
1010
required: true
11+
min_coverage:
12+
description: 'minimum coverage percentage allowed',
13+
required: true
14+
default: 100
1115
runs:
1216
using: 'docker'
1317
image: 'Dockerfile'
1418
args:
15-
- ${{ inputs.path }}
19+
- ${{ inputs.path }}
20+
- ${{ inputs.min_coverage }}

entrypoint.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/sh -l
22

33
LCOV_PATH=$1
4+
MINIMUM_COVERAGE=$2
45

5-
code_coverage=$(lcov --list ${LCOV_PATH} | sed -n "s/.*Total:|\(.*\)%.*/\1/p")
6+
CODE_COVERAGE=$(lcov --list ${LCOV_PATH} | sed -n "s/.*Total:|\(.*\)%.*/\1/p")
67

7-
echo "Code Coverage: ${code_coverage}%"
8-
if (( $(echo "$code_coverage < 100" | bc) )); then exit 1; fi
8+
echo "Minumum Coverage: ${MINIMUM_COVERAGE}$"
9+
echo "Code Coverage: ${CODE_COVERAGE}%"
10+
if (( $(echo "$CODE_COVERAGE < $2" | bc) )); then
11+
exit 1;
12+
fi

0 commit comments

Comments
 (0)