Adding coverage checking (#794)

* Adding coverage checking

* Installing lcov on ci

* printing summary

* Update scripts/test.sh

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Improving scripts

* Update .github/pull_request_template.md

Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>

* Update scripts/test.sh

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* reverting to pwd

* Update scripts/test.sh

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Updating changelog and min coverage

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
This commit is contained in:
Erick
2021-05-18 11:42:31 -03:00
committed by GitHub
parent e4281d6471
commit 2dc47fe66a
7 changed files with 42 additions and 2 deletions

View File

@ -8,6 +8,7 @@ Before you create this PR confirm that it meets all requirements listed below by
- [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [ ] My PR includes unit or integration tests for *all* changed/updated/fixed behaviors and are passing (See [Contributor Guide]).
- [ ] My PR does not decrease the code coverage, or I have __a very special case__ and explained on the PR description why this PR decreases the coverage.
- [ ] I updated/added relevant documentation (doc comments with `///`) and updated/added examples in `doc/examples`.
- [ ] I have formatted my code with `./scripts/format.sh` and the Flame analyzer (`./scripts/analyze.sh`) does not report any problems.
- [ ] I read and followed the [Flame Style Guide].

View File

@ -58,5 +58,6 @@ jobs:
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
- run: sudo apt-get install lcov -y
- run: ./scripts/test.sh
# END TESTING STAGE

2
.gitignore vendored
View File

@ -16,3 +16,5 @@ android/
ios/
desktop/
build/
coverage

View File

@ -0,0 +1 @@
42.7

View File

@ -5,6 +5,7 @@
- Fix the anchor of SpriteWidget
- Add test for re-adding previously removed component
- Add onCollisionEnd to make it possible for the user to easily detect when a collision ends
- Adding test coverage to packages
## [1.0.0-rc10]
- Updated tutorial documentation to indicate use of new version

View File

@ -0,0 +1,18 @@
import 'dart:io';
void main(args) {
final coverageSummary = args[0] as String;
final currentRaw = coverageSummary.replaceFirstMapped(
RegExp(r".* (\d+\.\d+)%.*"),
(matches) => '${matches[1]}',
);
final current = double.parse(currentRaw);
final min = double.parse(args[1].replaceAll('\n', ''));
if (current < min) {
exit(1);
} else {
exit(0);
}
}

View File

@ -2,15 +2,31 @@
echo "Starting Flame Tester"
echo "---------------------"
root_dir="$(realpath $(dirname "$0")/..)"
for file in $(find . -type d -name "test"); do
dir=$(dirname $file)
cd $dir
echo "Testing $dir"
flutter test
flutter test --coverage
test_result=$?
if [ $test_result -ne 0 ]; then
exit $test_result
fi
if [ -f ".min_coverage" ]; then
min_coverage=$(cat .min_coverage)
coverage_summary=$(lcov --summary coverage/lcov.info)
coverage_line=$(echo "$coverage_summary" | grep lines)
echo "$coverage_summary"
dart "$root_dir/scripts/check_coverage.dart" "$coverage_line" "$min_coverage"
coverage_result=$?
if [ $coverage_result -ne 0 ]; then
echo "Current coverage $current_cov is smaller than min: $min_coverage"
exit $coverage_result
fi
fi
cd $(cd -)
done