├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | # ignore all files by default 2 | * 3 | # include required files with an exception 4 | !entrypoint.sh 5 | !LICENSE 6 | !README.md -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y bc 5 | RUN apt-get install -y lcov 6 | 7 | COPY entrypoint.sh /entrypoint.sh 8 | 9 | ENTRYPOINT ["/entrypoint.sh"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ChicagoFlutter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | ⚠️ ⚠️ ⚠️ 3 |
4 | This project has been deprecated in favor of Very Good Coverage. 5 |
6 | Please migrate to Very Good Coverage for continued support and improvements. 7 |

8 | 9 | # lcov cop 10 | 11 | A Github Action which helps enforce a minimum code coverage threshold. 12 | 13 | ## Inputs 14 | 15 | ### `path` 16 | 17 | **Optional** The path to the `lcov.info` file. 18 | 19 | **Default** `./coverage/lcov.info` 20 | 21 | ### `min_coverage` 22 | 23 | **Optional** The minimum coverage percentage allowed. 24 | 25 | **Default** 100 26 | 27 | ### `exclude` 28 | 29 | **Optional** paths to exclude from coverage 30 | 31 | ## Example usage 32 | 33 | ```yaml 34 | uses: ChicagoFlutter/lcov-cop@v1.0.0 35 | with: 36 | path: "./coverage/lcov.info" 37 | min_coverage: 95 38 | exclude: "**/*.g.dart **/l10n/*.dart" 39 | ``` 40 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: lcov-cop 2 | author: felangel 3 | description: 'Enforce LCOV Coverage Thresholds' 4 | branding: 5 | icon: 'check-circle' 6 | color: green 7 | inputs: 8 | path: 9 | description: 'lcov path' 10 | required: false 11 | default: './coverage/lcov.info' 12 | min_coverage: 13 | description: 'minimum coverage percentage allowed' 14 | required: false 15 | default: 100 16 | exclude: 17 | description: 'paths to exclude from coverage' 18 | required: false 19 | runs: 20 | using: 'docker' 21 | image: 'Dockerfile' 22 | args: 23 | - ${{ inputs.path }} 24 | - ${{ inputs.min_coverage }} 25 | - ${{ inputs.exclude }} 26 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | LCOV_PATH=$1 6 | MINIMUM_COVERAGE=$2 7 | FILTERED_COVERAGE_PATH='./lcov_filtered.info' 8 | 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 16 | 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 20 | --------------------------------------------------------------------------------