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

Commit 56f47c3

Browse files
committed
add exclude input
1 parent a922b66 commit 56f47c3

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ A Github Action which helps enforce a minimum code coverage threshold.
1414

1515
**Default** 100
1616

17+
### `exclude`
18+
19+
**Optional** paths to exclude from coverage
20+
1721
## Example usage
1822

1923
```yaml
2024
uses: ChicagoFlutter/lcov-cop@master
2125
with:
2226
path: "./coverage/lcov.info"
2327
min_coverage: 95
28+
exclude: "**/*.g.dart **/l10n/*.dart"
2429
```

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ inputs:
1212
description: 'minimum coverage percentage allowed'
1313
required: true
1414
default: 100
15+
exclude:
16+
description: 'paths to exclude from coverage'
17+
required: false
1518
runs:
1619
using: 'docker'
1720
image: 'Dockerfile'
1821
args:
1922
- ${{ inputs.path }}
20-
- ${{ inputs.min_coverage }}
23+
- ${{ inputs.min_coverage }}
24+
- ${{ inputs.exclude }}

entrypoint.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ set -e
44

55
LCOV_PATH=$1
66
MINIMUM_COVERAGE=$2
7+
FILTERED_COVERAGE_PATH='./lcov_filtered.info'
78

8-
CODE_COVERAGE=$(lcov --list ${LCOV_PATH} | sed -n "s/.*Total:|\(.*\)%.*/\1/p")
9+
if [ ! -z "$3" ]; then
10+
echo "Excluding $3 from coverage..."
11+
lcov --remove ${LCOV_PATH} $3 -o ${FILTERED_COVERAGE_PATH}
12+
CODE_COVERAGE=$(lcov --list ${FILTERED_COVERAGE_PATH} | sed -n "s/.*Total:|\(.*\)%.*/\1/p")
13+
else
14+
CODE_COVERAGE=$(lcov --list ${LCOV_PATH} | sed -n "s/.*Total:|\(.*\)%.*/\1/p")
15+
fi
916

10-
echo "Minumum Coverage: ${MINIMUM_COVERAGE}%"
11-
echo "Code Coverage: ${CODE_COVERAGE}%"
12-
if (( $(echo "$CODE_COVERAGE < $2" | bc) )); then
13-
exit 1;
14-
fi
17+
echo "Minumum Coverage Required: ${MINIMUM_COVERAGE}%"
18+
echo "Current Code Coverage: ${CODE_COVERAGE}%"
19+
if (( $(echo "$CODE_COVERAGE < $2" | bc) )); then exit 1; fi

0 commit comments

Comments
 (0)