Skip to content

Commit 1214d94

Browse files
authored
Enha: polish the CI for Dart and Flutter (#196)
1 parent 87a6b5f commit 1214d94

File tree

9 files changed

+83
-20
lines changed

9 files changed

+83
-20
lines changed

.github/workflows/dart.yml

+27-4
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,34 @@ jobs:
3535
with:
3636
release-channel: ${{ matrix.sdk }}
3737
- uses: actions/checkout@v2
38-
- run: pub get
38+
# consider -p "chrome,vm" and --coverage=coverage
3939
- name: Test (VM and browser)
40-
run: pub run test test
41-
- run: dartanalyzer --fatal-warnings ./
42-
- run: dartfmt -n --set-exit-if-changed ./
40+
run: |
41+
pub get
42+
pub run test --coverage=coverage
43+
pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib
44+
45+
- uses: codecov/codecov-action@v1
46+
if: runner.os == 'Linux'
47+
with:
48+
name: sentry
49+
file: ./dart/coverage/lcov.info
50+
51+
analyze:
52+
runs-on: ubuntu-latest
53+
defaults:
54+
run:
55+
working-directory: ./dart
56+
steps:
57+
- uses: cedx/setup-dart@v2
58+
with:
59+
release-channel: stable
60+
- uses: actions/checkout@v2
61+
- run: |
62+
pub get
63+
dartanalyzer --fatal-warnings ./
64+
dartfmt -n --set-exit-if-changed ./
65+
4366
package-analysis:
4467
runs-on: ubuntu-latest
4568
steps:

.github/workflows/flutter.yml

+45-8
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,36 @@ jobs:
2828
target: web
2929
steps:
3030
- uses: actions/checkout@v2
31+
3132
- uses: actions/setup-java@v1
3233
with:
3334
java-version: '8'
35+
3436
- uses: subosito/flutter-action@v1
3537
with:
3638
channel: ${{ matrix.channel }}
39+
3740
- name: enable web
3841
if: matrix.target == 'web'
3942
run: flutter config --enable-web
43+
4044
# https://github.com/flutter/flutter/issues/59522#issuecomment-646208247
4145
- name: Fix iOS build bug
4246
if: matrix.target == 'ios'
4347
run: rm flutter/example/ios/Podfile
48+
4449
- name: Test
4550
run: |
4651
cd flutter
47-
flutter test
52+
flutter pub get
53+
flutter test --coverage test
54+
55+
- uses: codecov/codecov-action@v1
56+
if: runner.os == 'Linux'
57+
with:
58+
name: sentry_flutter
59+
file: ./flutter/coverage/lcov.info
60+
4861
- name: Build ${{ matrix.target }}
4962
env:
5063
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
@@ -56,12 +69,33 @@ jobs:
5669
flutter build ios --release --no-codesign
5770
;;
5871
android)
59-
flutter build appbundle
72+
flutter build appbundle --release
6073
;;
6174
web)
6275
flutter build web
6376
;;
6477
esac
78+
79+
format:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v2
83+
- uses: subosito/flutter-action@v1
84+
- run: |
85+
cd flutter
86+
flutter pub get
87+
flutter format --set-exit-if-changed .
88+
89+
analyze:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v2
93+
- uses: subosito/flutter-action@v1
94+
- run: |
95+
cd flutter
96+
flutter pub get
97+
flutter analyze
98+
6599
package-analysis:
66100
runs-on: ubuntu-latest
67101
steps:
@@ -77,29 +111,32 @@ jobs:
77111
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
78112
run: |
79113
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
80-
if (( $PERCENTAGE < 90 ))
114+
if (( $PERCENTAGE < 100 ))
81115
then
82116
echo Score too low!
83117
exit 1
84118
fi
119+
85120
pod-lint:
86121
runs-on: macos-latest
87122
steps:
88123
- uses: actions/checkout@v2
89124
# https://github.com/CocoaPods/CocoaPods/issues/5275#issuecomment-315461879
90125
- run: pod lib lint flutter/ios/sentry_flutter.podspec --skip-import-validation --allow-warnings
126+
91127
swift-lint:
92128
runs-on: ubuntu-latest
93129
steps:
94130
- uses: actions/checkout@v2
95-
- uses: norio-nomura/[email protected]
131+
- uses: norio-nomura/[email protected]
132+
96133
ktlint:
97134
runs-on: ubuntu-latest
98135
steps:
99136
- uses: actions/checkout@v2
100-
- run: brew install ktlint
101-
- name: run ktlint
102-
run: ktlint --reporter=checkstyle,output=build/ktlint-report.xml || true
103-
- uses: yutailang0119/action-ktlint@v1.0.0
137+
- run: |
138+
brew install ktlint
139+
ktlint --reporter=checkstyle,output=build/ktlint-report.xml || true
140+
- uses: yutailang0119/action-ktlint@v1
104141
with:
105142
xml_path: build/ktlint-report.xml

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ build/
2121
dart/coverage/*
2222
pubspec.lock
2323
Podfile.lock
24+
flutter/coverage/*

dart/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 4.0.0-alpha.3
33
description: >
44
A crash reporting library for Dart that sends crash reports to Sentry.io.
55
This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.
6-
homepage: https://github.com/getsentry/sentry-dart
6+
homepage: https://docs.sentry.io/platforms/dart/
77
repository: https://github.com/getsentry/sentry-dart
88

99
environment:
@@ -20,5 +20,5 @@ dev_dependencies:
2020
pedantic: ^1.9.2
2121
test: ^1.15.4
2222
yaml: ^2.2.1
23-
test_coverage: ^0.4.1
2423
collection: ^1.14.13
24+
coverage: ^0.14.2

flutter/example/lib/main.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class _MyAppState extends State<MyApp> {
4848
),
4949
RaisedButton(
5050
child: const Text('Flutter error : Scaffold.of()'),
51-
onPressed: () => Scaffold.of(context).showSnackBar(SnackBar(
51+
onPressed: () =>
52+
Scaffold.of(context).showSnackBar(const SnackBar(
5253
content: Text(''),
5354
)),
5455
),
@@ -102,6 +103,7 @@ class _MyAppState extends State<MyApp> {
102103
class AndroidExample extends StatelessWidget {
103104
const AndroidExample({Key key}) : super(key: key);
104105

106+
// ignore: avoid_field_initializers_in_const_classes
105107
final channel = const MethodChannel('example.flutter.sentry.io');
106108

107109
@override

flutter/lib/src/sentry_flutter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mixin SentryFlutter {
6262
? const String.fromEnvironment('SENTRY_DSN')
6363
: options.dsn;
6464

65-
// TODO: load debug images when split symbols are enabled.
65+
// TODO(todo): load debug images when split symbols are enabled.
6666

6767
// first step is to install the native integration and set default values,
6868
// so we are able to capture future errors.

flutter/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repository: https://github.com/getsentry/sentry-dart
66

77
environment:
88
sdk: ">=2.8.0 <3.0.0"
9-
flutter: ^1.17.0
9+
flutter: ">=1.17.0 <2.0.0"
1010

1111
dependencies:
1212
flutter:

flutter/test/load_contexts_integrations_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ void main() {
106106
final eventSdk = SdkVersion(
107107
name: 'sdk1',
108108
version: '1.0',
109-
integrations: ['EventIntegration'],
110-
packages: [const SentryPackage('event-package', '2.0')],
109+
integrations: const ['EventIntegration'],
110+
packages: const [SentryPackage('event-package', '2.0')],
111111
);
112112
final e = SentryEvent(sdk: eventSdk);
113113
final event = await options.eventProcessors.first(e, null);

flutter/test/sentry_flutter_web_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:test/test.dart';
77
// import 'sentry_flutter_util_test.dart';
88

99
Future<void> main() async {
10-
// TODO: validate if flag isWeb will work as intended
10+
// TODO(todo): validate if flag isWeb will work as intended
1111

1212
// final options = SentryOptions();
1313
// await SentryFlutter.init(configurationTester(options, isWeb: true), callback);

0 commit comments

Comments
 (0)