-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from icapps/github-actions
added github actions integration
- Loading branch information
Showing
11 changed files
with
234 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Analyzer | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
check_analyzer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2.8.0 | ||
with: | ||
channel: 'stable' | ||
- run: flutter packages get | ||
- run: flutter analyze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Code Formatting | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
check_formatting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2.8.0 | ||
with: | ||
channel: 'stable' | ||
- run: flutter packages get | ||
- run: dart format --set-exit-if-changed . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2.8.0 | ||
with: | ||
channel: 'stable' | ||
- run: flutter packages get | ||
- run: dart run ./tool/test_coverage_create_helper.dart | ||
- run: flutter test --coverage | ||
- run: dart run ./tool/test_coverage_filter.dart | ||
- run: dart run ./tool/test_coverage_validate_percentage.dart | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import 'dart:io'; | ||
|
||
void main(List<String> args) { | ||
printMessage('Start filtering the lcov.info file'); | ||
final file = File('coverage/lcov.info'); | ||
if (!file.existsSync()) { | ||
printMessage('${file.path}" does not exist'); | ||
return; | ||
} | ||
const endOfRecord = 'end_of_record'; | ||
final sections = <LcovSection>[]; | ||
final lines = file.readAsLinesSync(); | ||
LcovSection? currentSection; | ||
for (final line in lines) { | ||
if (line.endsWith('.dart')) { | ||
final filePath = line.replaceAll('SF:', ''); | ||
currentSection = LcovSection() | ||
..header = line | ||
..filePath = filePath; | ||
} else if (line == endOfRecord) { | ||
final currentSectionTmp = currentSection; | ||
if (currentSectionTmp != null) { | ||
currentSectionTmp.footer = line; | ||
sections.add(currentSectionTmp); | ||
} | ||
} else { | ||
currentSection?.body.add(line); | ||
} | ||
} | ||
final filteredSections = getFilteredSections(sections); | ||
final sb = StringBuffer(); | ||
for (final section in filteredSections) { | ||
sb.write(section.toString()); | ||
} | ||
file.writeAsStringSync(sb.toString()); | ||
printMessage('Filtered the lcov.info file'); | ||
} | ||
|
||
class LcovSection { | ||
String? filePath; | ||
String? header; | ||
final body = <String>[]; | ||
String? footer; | ||
|
||
String? getBodyString() { | ||
final filePathTmp = filePath; | ||
if (filePathTmp == null) return null; | ||
final file = File(filePathTmp); | ||
final content = file.readAsLinesSync(); | ||
final sb = StringBuffer(); | ||
getFilteredBody(body, content).forEach((item) => sb | ||
..write(item) | ||
..write('\n')); | ||
return sb.toString(); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return '$header\n${getBodyString()}$footer\n'; | ||
} | ||
} | ||
|
||
List<LcovSection> getFilteredSections(List<LcovSection> sections) { | ||
return sections.where((section) { | ||
final header = section.header; | ||
if (header == null) return false; | ||
if (!header.endsWith('.dart')) { | ||
return false; | ||
} else if (header.endsWith('.g.dart')) { | ||
return false; | ||
} else if (header.endsWith('.config.dart')) { | ||
return false; | ||
} else if (header.endsWith('injectable.dart')) { | ||
return false; | ||
} else if (header.startsWith('SF:lib/util/locale')) { | ||
return false; | ||
} else if (header.startsWith('SF:lib/widget')) { | ||
return false; | ||
} else if (header.startsWith('SF:lib/screen')) { | ||
return false; | ||
} else if (header.startsWith('SF:lib/navigator')) { | ||
return false; | ||
} | ||
return true; | ||
}).toList(); | ||
} | ||
|
||
List<String> getFilteredBody(List<String> body, List<String> lines) { | ||
return body.where((line) { | ||
if (line.startsWith('DA:')) { | ||
final sections = line.split(','); | ||
final lineNr = int.parse(sections[0].replaceAll('DA:', '')); | ||
final callCount = int.parse(sections[1]); | ||
if (callCount == 0) { | ||
final fileLine = lines[lineNr - 1].trim(); | ||
if (excludedLines.contains(fileLine)) { | ||
return false; | ||
} | ||
for (final line in excludedStartsWithLines) { | ||
if (fileLine.trim().startsWith(line)) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
}).toList(); | ||
} | ||
|
||
const excludedLines = <String>[ | ||
'const TranslationWriter._();', | ||
'const CaseUtil._();', | ||
'const LocaleGenParser._();', | ||
'const LocaleGenSbWriter._();', | ||
'const LocaleGenWriter._();', | ||
]; | ||
|
||
const excludedStartsWithLines = <String>[]; | ||
|
||
void printMessage(String message) { | ||
// ignore: avoid_print | ||
print(message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'dart:io'; | ||
|
||
const minRequiredCoverage = 0; | ||
|
||
void main(List<String> args) { | ||
printMessage('Start checking the lcov.info file'); | ||
final file = File('coverage/lcov.info'); | ||
if (!file.existsSync()) { | ||
printMessage('${file.path}" does not exist'); | ||
return; | ||
} | ||
var totalLines = 0; | ||
var totalLinesCovered = 0; | ||
final lines = file.readAsLinesSync(); | ||
for (final line in lines) { | ||
if (line.startsWith('DA')) { | ||
totalLines++; | ||
} else if (line.startsWith('LH')) { | ||
totalLinesCovered += int.parse(line.replaceAll('LH:', '')); | ||
} | ||
} | ||
final codeCoveragePercentage = (totalLinesCovered / totalLines) * 100; | ||
if (codeCoveragePercentage == 100) { | ||
printMessage('\n100% CODE COVERAGE!!!!\n'); | ||
} else if (codeCoveragePercentage >= minRequiredCoverage) { | ||
printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); | ||
printMessage( | ||
'TIS IS ABOVE THE MIN REQUIRED TARGET of $minRequiredCoverage%\n'); | ||
} else { | ||
printMessage('\nCODE COVERAGE IS TO LOW!!\n'); | ||
printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); | ||
printMessage('AMOUNT OF LINES:$totalLines'); | ||
printMessage('AMOUNT OF COVERED:$totalLinesCovered\n'); | ||
exit(-1); | ||
} | ||
} | ||
|
||
void printMessage(String message) { | ||
// ignore: avoid_print | ||
print(message); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.