Skip to content

Commit c1f1bdc

Browse files
committed
ci: implement workflow
1 parent 4f5ddd2 commit c1f1bdc

File tree

9 files changed

+317
-162
lines changed

9 files changed

+317
-162
lines changed

.github/workflows/android.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: android
2+
on:
3+
workflow_dispatch:
4+
branches:
5+
- master
6+
pull_request:
7+
branches: ['master']
8+
paths: ['app_widget_android/lib/**', 'app_widget_android/test/**']
9+
push:
10+
branches: ['master']
11+
paths: ['app_widget_android/lib/**', 'app_widget_android/test/**']
12+
jobs:
13+
analysis:
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: ./app_widget_android
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
steps:
22+
- uses: actions/checkout@v3 # checkout to current dir
23+
- uses: subosito/flutter-action@v2
24+
with:
25+
channel: 'stable'
26+
cache: true
27+
cache-key: ${{ runner.os }}-flutter-install-cache
28+
cache-path: ${{ runner.tool_cache }}/flutter
29+
- run: flutter pub get
30+
- name: Static Analysis
31+
run: flutter analyze
32+
- name: unit test
33+
run: flutter test
34+
- name: pub publishable
35+
run: flutter pub publish --dry-run

.github/workflows/interface.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: platform-interface
2+
on:
3+
workflow_dispatch:
4+
branches:
5+
- master
6+
pull_request:
7+
branches: ['master']
8+
paths: ['app_widget_platform_interface/lib/**', 'app_widget_platform_interface/test/**']
9+
push:
10+
branches: ['master']
11+
paths: ['app_widget_platform_interface/lib/**', 'app_widget_platform_interface/test/**']
12+
jobs:
13+
analysis:
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: ./app_widget_platform_interface
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
steps:
22+
- uses: actions/checkout@v3 # checkout to current dir
23+
- uses: subosito/flutter-action@v2
24+
with:
25+
channel: 'stable'
26+
cache: true
27+
cache-key: ${{ runner.os }}-flutter-install-cache
28+
cache-path: ${{ runner.tool_cache }}/flutter
29+
- run: flutter pub get
30+
- name: Static Analysis
31+
run: flutter analyze
32+
- name: pub publishable
33+
run: flutter pub publish --dry-run

.github/workflows/main.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: build
2+
on:
3+
workflow_dispatch:
4+
branches:
5+
- master
6+
pull_request:
7+
branches: ['master']
8+
paths: ['lib/**', 'android/**', 'app_widget/test/**', 'app_widget/example/**']
9+
push:
10+
branches: ['master']
11+
paths: ['lib/**', 'android/**', 'app_widget/test/**', 'app_widget/example/**']
12+
jobs:
13+
analysis:
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: ./app_widget
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
steps:
22+
- uses: actions/checkout@v3 # checkout to current dir
23+
- uses: subosito/flutter-action@v2
24+
with:
25+
channel: 'stable'
26+
cache: true
27+
cache-key: ${{ runner.os }}-flutter-install-cache
28+
cache-path: ${{ runner.tool_cache }}/flutter
29+
- run: flutter pub get
30+
- name: Static Analysis
31+
run: flutter analyze
32+
- name: pub publishable
33+
run: flutter pub publish --dry-run
34+
- name: unit test
35+
run: flutter test
36+
# never finish on CI, but run fine on local
37+
# build_android:
38+
# needs: analysis
39+
# strategy:
40+
# matrix:
41+
# api-level: [29, 30, 31, 32, 33]
42+
# runs-on: macos-latest
43+
# defaults:
44+
# run:
45+
# working-directory: ./app_widget/example
46+
# steps:
47+
# - uses: actions/checkout@v3
48+
# - uses: subosito/flutter-action@v2
49+
# with:
50+
# channel: 'stable'
51+
# cache: true
52+
# cache-key: ${{ runner.os }}-flutter-install-cache
53+
# cache-path: ${{ runner.tool_cache }}/flutter
54+
# - run: flutter pub get
55+
# - name: AVD cache
56+
# uses: actions/cache@v3
57+
# id: avd-cache
58+
# with:
59+
# path: |
60+
# ~/.android/avd/*
61+
# ~/.android/adb*
62+
# key: avd-${{ matrix.api-level }}
63+
# - name: create AVD and generate snapshot for caching
64+
# if: steps.avd-cache.outputs.cache-hit != 'true'
65+
# uses: reactivecircus/android-emulator-runner@v2
66+
# with:
67+
# api-level: ${{ matrix.api-level }}
68+
# arch: x86_64
69+
# profile: Nexus 6
70+
# target: playstore
71+
# force-avd-creation: false
72+
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
73+
# disable-animations: false
74+
# script: echo "Generated AVD snapshot for caching."
75+
# - uses: actions/setup-java@v2
76+
# with:
77+
# distribution: 'adopt'
78+
# java-version: '11'
79+
# cache: 'gradle'
80+
# - name: Integration Test
81+
# uses: reactivecircus/android-emulator-runner@v2
82+
# with:
83+
# target: playstore
84+
# api-level: ${{ matrix.api-level }}
85+
# arch: x86_64
86+
# profile: Nexus 6
87+
# force-avd-creation: false
88+
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
89+
# disable-animations: true
90+
# working-directory: ./app_widget/example
91+
# script: flutter test integration_test/android_test.dart && sleep 2 && flutter test integration_test/android_test_2.dart
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import 'package:app_widget/app_widget.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:integration_test/integration_test.dart';
4+
5+
// there is no way to test callback as it need to interact with actual widgets
6+
void main() {
7+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
8+
9+
group('with androidPackageName', () {
10+
final AppWidgetPlugin appWidgetPlugin = AppWidgetPlugin(
11+
androidPackageName: 'tech.noxasch.app_widget_example',
12+
);
13+
14+
testWidgets('configureWidget', (tester) async {
15+
final res = await appWidgetPlugin.configureWidget(
16+
widgetId: 1,
17+
widgetLayout: 'example_layout',
18+
payload: '{"itemId": 1, "stringUid": "uid"}',
19+
url: 'https://google.come',
20+
);
21+
expect(res, isTrue);
22+
});
23+
24+
testWidgets('cancelConfigureWidget', (tester) async {
25+
final res = await appWidgetPlugin.cancelConfigureWidget();
26+
27+
expect(res, isTrue);
28+
});
29+
30+
testWidgets('updateWidget', (tester) async {
31+
final res = await appWidgetPlugin.updateWidget(
32+
widgetId: 1,
33+
widgetLayout: 'example_layout',
34+
payload: '{"itemId": 1, "stringUid": "uid"}',
35+
url: 'https://google.come',
36+
textViews: {'widget_title': 'my title'},
37+
);
38+
39+
expect(res, isTrue);
40+
});
41+
42+
testWidgets('getWidgetIds', (tester) async {
43+
final res = await appWidgetPlugin.getWidgetIds(
44+
androidProviderName: 'AppWidgetExampleProvider',
45+
);
46+
47+
expect(res, []);
48+
});
49+
50+
testWidgets('reloadWidgets', (tester) async {
51+
final res = await appWidgetPlugin.reloadWidgets(
52+
androidProviderName: 'AppWidgetExampleProvider',
53+
);
54+
55+
expect(res, isTrue);
56+
});
57+
58+
testWidgets('widgetExist', (tester) async {
59+
final res = await appWidgetPlugin.widgetExist(12);
60+
61+
expect(res, isFalse);
62+
});
63+
});
64+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import 'package:app_widget/app_widget.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:integration_test/integration_test.dart';
4+
5+
// there is no way to test callback as it need to interact with actual widgets
6+
void main() {
7+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
8+
9+
group('without androidPackageName', () {
10+
final AppWidgetPlugin appWidgetPlugin = AppWidgetPlugin();
11+
12+
testWidgets('configureWidget', (tester) async {
13+
final res = await appWidgetPlugin.configureWidget(
14+
widgetId: 1,
15+
widgetLayout: 'example_layout',
16+
payload: '{"itemId": 1, "stringUid": "uid"}',
17+
url: 'https://google.come',
18+
);
19+
expect(res, isTrue);
20+
});
21+
22+
testWidgets('cancelConfigureWidget', (tester) async {
23+
final res = await appWidgetPlugin.cancelConfigureWidget();
24+
25+
expect(res, isTrue);
26+
});
27+
28+
testWidgets('updateWidget', (tester) async {
29+
final res = await appWidgetPlugin.updateWidget(
30+
widgetId: 1,
31+
widgetLayout: 'example_layout',
32+
payload: '{"itemId": 1, "stringUid": "uid"}',
33+
url: 'https://google.come',
34+
textViews: {'widget_title': 'my title'},
35+
);
36+
37+
expect(res, isTrue);
38+
});
39+
40+
testWidgets('getWidgetIds', (tester) async {
41+
final res = await appWidgetPlugin.getWidgetIds(
42+
androidProviderName: 'AppWidgetExampleProvider',
43+
);
44+
45+
expect(res, []);
46+
});
47+
48+
testWidgets('reloadWidgets', (tester) async {
49+
final res = await appWidgetPlugin.reloadWidgets(
50+
androidProviderName: 'AppWidgetExampleProvider',
51+
);
52+
53+
expect(res, isTrue);
54+
});
55+
56+
testWidgets('widgetExist', (tester) async {
57+
final res = await appWidgetPlugin.widgetExist(12);
58+
59+
expect(res, isFalse);
60+
});
61+
});
62+
}

0 commit comments

Comments
 (0)