Skip to content

Commit

Permalink
Added a workflow for running flutter tests and uploading code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuufMaster committed May 30, 2024
1 parent 134feb4 commit 827b7d0
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 2 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CODECOV coverage upload
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubunutu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: pubspec.yaml

- name: Cache Flutter dependancies
uses: actions/cache@v3
with:
path: |
~./.pub-cache
~./.flutter
keys: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-
- name: Install Flutter dependecies
run: flutter pub get

- name: Run Flutter tests
run: flutter test --coverage

- name: Upload coverage artifact
uses: actions/upload-artifact@v3
with:
name: flutter-coverage-report
path: coverage/lcov.info

codecov:
needs: test
runs-on: ubuntu-latest
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
name: flutter-coverage-report
path: coverage

- name: Upload Flutter Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
40 changes: 39 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,45 @@ linter:
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# prefer_single_quotes # Uncomment to enable the `prefer_single_quotes` rule
- avoid_print # discourage using print statements
- prefer_const_constructors
- prefer_const_literals_to_create_immutables # Use const for immutable collections
- prefer_final_locals # Prefer final for local variables if they are not reassigned
- prefer_single_quotes # Prefer single quotes for strings
- annotate_overrides # Require @override for overridden methods
- always_declare_return_types # Always declare return types for methods and functions
- always_put_control_body_on_new_line # Control flow statements should have bodies on new lines
- always_use_package_imports # Use package imports for other files in the same package
- avoid_as # Avoid using `as` for type casts
- avoid_empty_else # Avoid empty else statements
- avoid_function_literals_in_foreach_calls # Avoid using function literals in forEach calls
- avoid_redundant_argument_values # Avoid passing redundant arguments
- avoid_types_on_closure_parameters # Avoid specifying types for closure parameters
- curly_braces_in_flow_control_structures # Use curly braces for all flow control structures
- empty_constructor_bodies # Constructors with empty bodies should be replaced with a semicolon
- implementation_imports # Avoid imports from implementation files
- library_prefixes # Use library prefixes for imports
- prefer_asserts_with_message # Use assert with messages
- prefer_typing_uninitialized_variables # Prefer typing for uninitialized variables
- slash_for_doc_comments # Use /// for documentation comments
- type_annotate_public_apis # Type annotate public APIs
- unnecessary_const # Remove unnecessary const
- unnecessary_new # Remove unnecessary new
- unnecessary_null_in_if_null_operators # Remove unnecessary null in if-null operators
- lines_longer_than_80_chars
- sort_constructors_first
- sort_child_properties_last

# Override Flutter lints
analyzer:
errors:
avoid_print: warning # Set avoid_print as a warning instead of an error

# Exclude generated files from analysis
exclude:
- '**/*.g.dart'
- '**/*.freezed.dart'

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
2 changes: 1 addition & 1 deletion test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:beakpeek/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
testWidgets('Counter increments smoke test', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

Expand Down

0 comments on commit 827b7d0

Please sign in to comment.