Skip to content

Commit e719f00

Browse files
authored
Merge pull request #65 from ant-media/feature_ci/cd
Feature ci/cd
2 parents 3e5b4f8 + b2ff2b3 commit e719f00

19 files changed

+828
-88
lines changed

.github/workflows/publish.yml

+43-15
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,65 @@
1-
name: Publish Package
1+
2+
name: Run Test Cases And Publish Package
23

34
on:
45
push:
5-
branches: [ main ]
6+
branches:
7+
- main
68

9+
schedule:
10+
- cron: '0 0 * * 2'
711

812
jobs:
913
build:
1014
runs-on: ubuntu-latest
1115

1216
steps:
1317
- uses: actions/checkout@v3
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'zulu'
23+
java-version: '17'
24+
1425
- name: Install Flutter
1526
uses: subosito/flutter-action@v2
1627
with:
17-
channel: 'beta'
18-
- name: Install dependencies
19-
run: flutter pub get
28+
channel: 'stable'
29+
30+
- name: Enable KVM group perms
31+
run: |
32+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
33+
sudo udevadm control --reload-rules
34+
sudo udevadm trigger --name-match=kvm
35+
sudo apt-get -y install android-tools-adb
36+
37+
38+
- name: Run sample application integration tests
39+
uses: reactivecircus/android-emulator-runner@v2
40+
with:
41+
api-level: 29
42+
script: |
43+
cd example/SampleProject && flutter test integration_test/test_conference.dart
44+
cd example/SampleProject && flutter test integration_test/test_play.dart
45+
46+
# Uncomment and adjust for publishing your package
2047
- name: Setup Pub Credentials
2148
shell: bash
2249
env:
23-
PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }}
24-
PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }}
25-
PUB_DEV_PUBLISH_TOKEN_ENDPOINT: ${{ secrets.PUB_DEV_PUBLISH_TOKEN_ENDPOINT }}
26-
PUB_DEV_PUBLISH_EXPIRATION: ${{ secrets.PUB_DEV_PUBLISH_EXPIRATION }}
50+
PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }}
51+
PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }}
52+
PUB_DEV_PUBLISH_TOKEN_ENDPOINT: ${{ secrets.PUB_DEV_PUBLISH_TOKEN_ENDPOINT }}
53+
PUB_DEV_PUBLISH_EXPIRATION: ${{ secrets.PUB_DEV_PUBLISH_EXPIRATION }}
2754
run: |
28-
sh ./pub_login.sh
55+
sh ./pub_login.sh
56+
2957
- name: Check Publish Warnings
3058
run: |
31-
sudo cat /$HOME/.config/dart/pub-credentials.json
32-
flutter pub publish --dry-run
59+
sudo cat /$HOME/.config/dart/pub-credentials.json
60+
flutter pub publish --dry-run
61+
3362
- name: Publish Package
63+
if: github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, 'release')
3464
run: |
35-
yes | flutter pub publish
36-
37-
65+
yes | flutter pub publish
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

example/SampleProject/android/gradle/wrapper/gradle-wrapper.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:integration_test/integration_test.dart';
4+
import 'test_helper.dart';
5+
6+
void main() {
7+
// Initialize the integration test bindings.
8+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
9+
10+
testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Conference example', (WidgetTester tester) async {
11+
// Launch the app.
12+
await launchApp(tester);
13+
14+
// Enter the server URL.
15+
await enterServerUrl(tester, 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket');
16+
17+
// Tap the 'Conference' button.
18+
await tester.tap(find.text('Conference'));
19+
await tester.pumpAndSettle(const Duration(seconds: 1));
20+
21+
// Find the first text field and enter 'test'.
22+
await tester.enterText(find.byType(TextField).at(0), 'test');
23+
await tester.pumpAndSettle();
24+
25+
// Find the second text field and enter 'room'.
26+
await tester.enterText(find.byType(TextField).at(1), 'room');
27+
await tester.pumpAndSettle();
28+
29+
// Tap the 'Connect' button.
30+
await tester.tap(find.text('Connect'));
31+
await tester.pumpAndSettle(const Duration(seconds: 20));
32+
});
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:shared_preferences/shared_preferences.dart';
4+
import 'package:example/main.dart';
5+
import 'package:integration_test/integration_test.dart';
6+
7+
void main() {
8+
// Initialize the integration test bindings.
9+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
11+
testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Data Channel example', (WidgetTester tester) async {
12+
// Mock initial values for shared preferences.
13+
SharedPreferences.setMockInitialValues({});
14+
15+
// Launch the app.
16+
await tester.pumpWidget(const MaterialApp(
17+
home: Scaffold(
18+
body: MyApp(),
19+
)));
20+
21+
// Ensure the app has built.
22+
await tester.pumpAndSettle();
23+
24+
// Verify the settings icon is present.
25+
expect(find.byIcon(Icons.settings), findsOneWidget);
26+
27+
// Tap the settings icon.
28+
await tester.tap(find.byIcon(Icons.settings));
29+
await tester.pumpAndSettle();
30+
31+
// Check if the AlertDialog appears after tapping settings.
32+
expect(find.byType(AlertDialog), findsOneWidget);
33+
34+
// Enter the server URL in the TextField inside the dialog.
35+
await tester.enterText(find.byType(TextField), 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket');
36+
await tester.pumpAndSettle();
37+
38+
// Ensure the "Set Server Ip" button is present and enabled.
39+
final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip');
40+
expect(setServerIpButton, findsOneWidget);
41+
42+
// Tap the "Set Server Ip" button.
43+
await tester.tap(setServerIpButton);
44+
await tester.pumpAndSettle();
45+
46+
// Verify that a SnackBar appears after setting the server IP.
47+
expect(find.byType(SnackBar), findsOneWidget);
48+
49+
// Tap the 'Conference' button.
50+
await tester.tap(find.text('Data Channel'));
51+
await tester.pumpAndSettle();
52+
53+
// Enter Room ID and tap OK.
54+
await tester.enterText(find.byType(TextField), '24x7test');
55+
await tester.tap(find.text('OK'));
56+
await tester.pumpAndSettle(const Duration(seconds: 5));
57+
});
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// test_helper.dart
2+
3+
import 'dart:io';
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:flutter_test/flutter_test.dart';
7+
import 'package:shared_preferences/shared_preferences.dart';
8+
import 'package:example/main.dart';
9+
10+
// A helper method to launch the app.
11+
Future<void> launchApp(WidgetTester tester) async {
12+
13+
// Mock initial values for shared preferences.
14+
SharedPreferences.setMockInitialValues({});
15+
16+
// Launch the app.
17+
await tester.pumpWidget(const MaterialApp(
18+
home: Scaffold(
19+
body: MyApp(),
20+
),
21+
));
22+
await tester.pumpAndSettle();
23+
}
24+
25+
// A helper method to open settings and enter a server URL.
26+
Future<void> enterServerUrl(WidgetTester tester, String url) async {
27+
// Verify the settings icon is present.
28+
expect(find.byIcon(Icons.settings), findsOneWidget);
29+
30+
// Tap the settings icon.
31+
await tester.tap(find.byIcon(Icons.settings));
32+
await tester.pumpAndSettle();
33+
34+
// Check if the AlertDialog appears after tapping settings.
35+
expect(find.byType(AlertDialog), findsOneWidget);
36+
37+
// Enter the server URL in the TextField inside the dialog.
38+
await tester.enterText(find.byType(TextField), url);
39+
await tester.pumpAndSettle();
40+
41+
// Tap the "Set Server Ip" button.
42+
final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip');
43+
expect(setServerIpButton, findsOneWidget);
44+
await tester.tap(setServerIpButton);
45+
await tester.pumpAndSettle();
46+
47+
// Verify that a SnackBar appears after setting the server IP.
48+
expect(find.byType(SnackBar), findsOneWidget);
49+
}
50+
51+
// A helper method to enter a Room ID and tap OK.
52+
Future<void> enterRoomId(WidgetTester tester, String roomId) async {
53+
await tester.enterText(find.byType(TextField), roomId);
54+
await tester.tap(find.text('OK'));
55+
await tester.pumpAndSettle();
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:integration_test/integration_test.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:shared_preferences/shared_preferences.dart';
5+
import 'package:example/main.dart';
6+
7+
void main() {
8+
// Initialize the integration test bindings.
9+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
11+
testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Peer to Peer example', (WidgetTester tester) async {
12+
// Mock initial values for shared preferences.
13+
SharedPreferences.setMockInitialValues({});
14+
15+
// Launch the app.
16+
await tester.pumpWidget(const MaterialApp(
17+
home: Scaffold(
18+
body: MyApp(),
19+
)));
20+
21+
// Ensure the app has built.
22+
await tester.pumpAndSettle();
23+
24+
// Verify the settings icon is present.
25+
expect(find.byIcon(Icons.settings), findsOneWidget);
26+
27+
// Tap the settings icon.
28+
await tester.tap(find.byIcon(Icons.settings));
29+
await tester.pumpAndSettle();
30+
31+
// Check if the AlertDialog appears after tapping settings.
32+
expect(find.byType(AlertDialog), findsOneWidget);
33+
34+
// Enter the server URL in the TextField inside the dialog.
35+
await tester.enterText(find.byType(TextField), 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket');
36+
await tester.pumpAndSettle();
37+
38+
// Ensure the "Set Server Ip" button is present and enabled.
39+
final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip');
40+
expect(setServerIpButton, findsOneWidget);
41+
42+
// Tap the "Set Server Ip" button.
43+
await tester.tap(setServerIpButton);
44+
await tester.pumpAndSettle();
45+
46+
// Verify that a SnackBar appears after setting the server IP.
47+
expect(find.byType(SnackBar), findsOneWidget);
48+
49+
// Tap the 'Conference' button.
50+
await tester.tap(find.text('Peer to Peer'));
51+
await tester.pumpAndSettle();
52+
53+
// Enter Room ID and tap OK.
54+
await tester.enterText(find.byType(TextField), 'p2pTest');
55+
await tester.tap(find.text('OK'));
56+
await tester.pumpAndSettle(const Duration(seconds: 5));
57+
});
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:integration_test/integration_test.dart';
4+
import 'test_helper.dart';
5+
6+
void main() {
7+
// Initialize the integration test bindings.
8+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
9+
10+
testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the play example', (WidgetTester tester) async {
11+
// Launch the app.
12+
await launchApp(tester);
13+
14+
// Enter the server URL.
15+
await enterServerUrl(tester, 'wss://test.antmedia.io:5443/24x7test/websocket');
16+
17+
// Tap the 'Play' button.
18+
await tester.tap(find.text('Play'));
19+
await tester.pumpAndSettle();
20+
21+
// Enter Room ID and tap OK.
22+
await enterRoomId(tester, '24x7test');
23+
await tester.pumpAndSettle(const Duration(seconds: 10));
24+
25+
// Verify the content of the SnackBar.
26+
expect(find.textContaining('Received: '), findsOneWidget);
27+
});
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
import 'dart:io';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:integration_test/integration_test.dart';
6+
import 'package:example/publish.dart';
7+
import 'test_helper.dart';
8+
9+
void main() {
10+
11+
// Initialize the integration test bindings.
12+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
13+
14+
testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Publish example', (WidgetTester tester) async {
15+
// Launch the app.
16+
await launchApp(tester);
17+
18+
// Enter the server URL.
19+
await enterServerUrl(tester, 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket');
20+
21+
// Tap the 'Publish' button.
22+
await tester.tap(find.text('Publish'));
23+
await tester.pumpAndSettle(const Duration(seconds: 2));
24+
25+
26+
// Enter Room ID and tap OK.
27+
await enterRoomId(tester, 'publishTest');
28+
29+
// Verify the AlertDialog to choose the publishing source appears.
30+
expect(find.byType(AlertDialog), findsOneWidget);
31+
32+
// Tap the "Camera" button.
33+
await tester.tap(find.widgetWithText(MaterialButton, 'Camera'));
34+
await tester.pumpAndSettle(const Duration(seconds: 15));
35+
36+
// Verify that the Publish screen is loaded.
37+
expect(find.byType(Publish), findsOneWidget);
38+
39+
// Check if the call_end icon is present and tap it if it appears.
40+
final callEndIcon = find.byIcon(Icons.call_end);
41+
await tester.tap(callEndIcon);
42+
await tester.pumpAndSettle();
43+
});
44+
}

0 commit comments

Comments
 (0)