mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Split CI testing based on flutter channels (#651)
This commit is contained in:
19
.github/workflows/main.yml
vendored
19
.github/workflows/main.yml
vendored
@@ -9,16 +9,19 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *' # Every day at midnight
|
- cron: '0 0 * * *' # Every day at midnight
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
flutter-tests:
|
flutter-tests:
|
||||||
runs-on: ubuntu-latest
|
name: Test Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
flutter_version: [dev, beta, stable]
|
||||||
- flutter_version: dev
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
- flutter_version: beta
|
|
||||||
- flutter_version: stable
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
@@ -27,11 +30,9 @@ jobs:
|
|||||||
- uses: subosito/flutter-action@v1
|
- uses: subosito/flutter-action@v1
|
||||||
with:
|
with:
|
||||||
channel: ${{ matrix.flutter_version }}
|
channel: ${{ matrix.flutter_version }}
|
||||||
- run: ./tool/flutter_ci_script.sh
|
- run: ./tool/flutter_ci_script_${{ matrix.flutter_version }}.sh
|
||||||
android-build:
|
android-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
@@ -43,8 +44,6 @@ jobs:
|
|||||||
- run: ./tool/android_ci_script.sh
|
- run: ./tool/android_ci_script.sh
|
||||||
ios-build:
|
ios-build:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:file_selector/file_selector.dart';
|
import 'package:file_selector/file_selector.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// for details. All rights reserved. Use of this source code is governed by a
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// ignore_for_file: unused_local_variable
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'services.dart';
|
import 'services.dart';
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// This is a basic Flutter widget test.
|
||||||
|
//
|
||||||
|
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||||
|
// utility that Flutter provides. For example, you can send tap and scroll
|
||||||
|
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||||
|
// tree, read text, and verify that the values of widget properties are correct.
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Rendering the page throws an exception',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
// Do nothing, running the app throws an exception on widget render.
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -23,7 +23,8 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
|||||||
|
|
||||||
static Route<void> _routeBuilder(BuildContext context, Object argument) {
|
static Route<void> _routeBuilder(BuildContext context, Object argument) {
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
builder: (context) => VeggieCategorySettingsScreen(restorationId: 'category'),
|
builder: (context) =>
|
||||||
|
VeggieCategorySettingsScreen(restorationId: 'category'),
|
||||||
title: 'Preferred Categories',
|
title: 'Preferred Categories',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -136,9 +137,10 @@ class CalorieSettingsScreen extends StatelessWidget {
|
|||||||
label: cals.toString(),
|
label: cals.toString(),
|
||||||
icon: SettingsIcon(
|
icon: SettingsIcon(
|
||||||
icon: Styles.checkIcon,
|
icon: Styles.checkIcon,
|
||||||
foregroundColor: snapshot.hasData && snapshot.data == cals
|
foregroundColor:
|
||||||
? CupertinoColors.activeBlue
|
snapshot.hasData && snapshot.data == cals
|
||||||
: Styles.transparentColor,
|
? CupertinoColors.activeBlue
|
||||||
|
: Styles.transparentColor,
|
||||||
backgroundColor: Styles.transparentColor,
|
backgroundColor: Styles.transparentColor,
|
||||||
),
|
),
|
||||||
onPress: snapshot.hasData
|
onPress: snapshot.hasData
|
||||||
@@ -219,7 +221,8 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
restorationId: restorationId,
|
restorationId: restorationId,
|
||||||
child: CupertinoPageScaffold(
|
child: CupertinoPageScaffold(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Styles.scaffoldBackground(CupertinoTheme.brightnessOf(context)),
|
color:
|
||||||
|
Styles.scaffoldBackground(CupertinoTheme.brightnessOf(context)),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
restorationId: 'list',
|
restorationId: 'list',
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
|
|||||||
@@ -43,27 +43,32 @@ void main() {
|
|||||||
expect(find.text('Grapes'), findsNothing);
|
expect(find.text('Grapes'), findsNothing);
|
||||||
expect(find.text('Figs'), findsOneWidget);
|
expect(find.text('Figs'), findsOneWidget);
|
||||||
expect(find.text('Serving info'), findsOneWidget);
|
expect(find.text('Serving info'), findsOneWidget);
|
||||||
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value, isFalse);
|
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value,
|
||||||
|
isFalse);
|
||||||
await tester.tap(find.byType(CupertinoSwitch));
|
await tester.tap(find.byType(CupertinoSwitch));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value, isTrue);
|
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value,
|
||||||
|
isTrue);
|
||||||
|
|
||||||
// Current details page is restored.
|
// Current details page is restored.
|
||||||
await tester.restartAndRestore();
|
await tester.restartAndRestore();
|
||||||
expect(find.text('Grapes'), findsNothing);
|
expect(find.text('Grapes'), findsNothing);
|
||||||
expect(find.text('Figs'), findsOneWidget);
|
expect(find.text('Figs'), findsOneWidget);
|
||||||
expect(find.text('Serving info'), findsOneWidget);
|
expect(find.text('Serving info'), findsOneWidget);
|
||||||
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value, isTrue);
|
expect(tester.widget<CupertinoSwitch>(find.byType(CupertinoSwitch)).value,
|
||||||
|
isTrue);
|
||||||
|
|
||||||
await tester.tap(find.text('Trivia'));
|
await tester.tap(find.text('Trivia'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Serving info'), findsNothing);
|
expect(find.text('Serving info'), findsNothing);
|
||||||
expect(find.text("Which of these isn't a variety of figs?"), findsOneWidget);
|
expect(
|
||||||
|
find.text("Which of these isn't a variety of figs?"), findsOneWidget);
|
||||||
|
|
||||||
// Restores to trivia page.
|
// Restores to trivia page.
|
||||||
await tester.restartAndRestore();
|
await tester.restartAndRestore();
|
||||||
expect(find.text('Serving info'), findsNothing);
|
expect(find.text('Serving info'), findsNothing);
|
||||||
expect(find.text("Which of these isn't a variety of figs?"), findsOneWidget);
|
expect(
|
||||||
|
find.text("Which of these isn't a variety of figs?"), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.text('Brown Turkey'));
|
await tester.tap(find.text('Brown Turkey'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -92,13 +97,15 @@ void main() {
|
|||||||
await tester.tap(find.text('My Garden'));
|
await tester.tap(find.text('My Garden'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.text('My Garden'), findsNWidgets(2)); // Name of the tap & title of page.
|
expect(find.text('My Garden'),
|
||||||
|
findsNWidgets(2)); // Name of the tap & title of page.
|
||||||
expect(find.text('Grapes'), findsNothing);
|
expect(find.text('Grapes'), findsNothing);
|
||||||
expect(find.text('Figs'), findsOneWidget);
|
expect(find.text('Figs'), findsOneWidget);
|
||||||
|
|
||||||
// Restores the current selected tab.
|
// Restores the current selected tab.
|
||||||
await tester.restartAndRestore();
|
await tester.restartAndRestore();
|
||||||
expect(find.text('My Garden'), findsNWidgets(2)); // Name of the tap & title of page.
|
expect(find.text('My Garden'),
|
||||||
|
findsNWidgets(2)); // Name of the tap & title of page.
|
||||||
expect(find.text('Grapes'), findsNothing);
|
expect(find.text('Grapes'), findsNothing);
|
||||||
expect(find.text('Figs'), findsOneWidget);
|
expect(find.text('Figs'), findsOneWidget);
|
||||||
expect(find.text('Apples'), findsNothing);
|
expect(find.text('Apples'), findsNothing);
|
||||||
@@ -109,7 +116,8 @@ void main() {
|
|||||||
|
|
||||||
expect(find.text('Apples'), findsOneWidget);
|
expect(find.text('Apples'), findsOneWidget);
|
||||||
expect(find.text('Tangelo'), findsNothing);
|
expect(find.text('Tangelo'), findsNothing);
|
||||||
await tester.enterText(find.byType(CupertinoTextField).hitTestable(), 'Tan');
|
await tester.enterText(
|
||||||
|
find.byType(CupertinoTextField).hitTestable(), 'Tan');
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Apples'), findsNothing);
|
expect(find.text('Apples'), findsNothing);
|
||||||
expect(find.text('Tangelo'), findsOneWidget);
|
expect(find.text('Tangelo'), findsOneWidget);
|
||||||
@@ -129,7 +137,7 @@ void main() {
|
|||||||
|
|
||||||
expect(find.text('Tangelo'), findsOneWidget);
|
expect(find.text('Tangelo'), findsOneWidget);
|
||||||
expect(find.text('Serving info'), findsOneWidget);
|
expect(find.text('Serving info'), findsOneWidget);
|
||||||
|
|
||||||
// Restores details page
|
// Restores details page
|
||||||
await tester.restartAndRestore();
|
await tester.restartAndRestore();
|
||||||
expect(find.text('Tangelo'), findsOneWidget);
|
expect(find.text('Tangelo'), findsOneWidget);
|
||||||
|
|||||||
@@ -54,4 +54,3 @@ class _FirebaseUser implements User {
|
|||||||
|
|
||||||
_FirebaseUser(this.uid);
|
_FirebaseUser(this.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class MockAuthService implements Auth {
|
|||||||
Future<User> signIn() async {
|
Future<User> signIn() async {
|
||||||
// Sign in will randomly fail 25% of the time.
|
// Sign in will randomly fail 25% of the time.
|
||||||
var random = Random();
|
var random = Random();
|
||||||
if (random.nextInt(4) == 0) {
|
if (random.nextInt(4) == 0) {
|
||||||
throw SignInException();
|
throw SignInException();
|
||||||
}
|
}
|
||||||
return MockUser();
|
return MockUser();
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class _SignInButtonState extends State<SignInButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showError() {
|
void _showError() {
|
||||||
Scaffold.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('Unable to sign in.'),
|
content: Text('Unable to sign in.'),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ void runWeb() {
|
|||||||
@Task()
|
@Task()
|
||||||
void runFirebase() {
|
void runFirebase() {
|
||||||
run('flutter',
|
run('flutter',
|
||||||
arguments: 'run -d web --web-port=5000 lib/main_firebase.dart '.split(' '));
|
arguments:
|
||||||
|
'run -d web --web-port=5000 lib/main_firebase.dart '.split(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Task()
|
@Task()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ declare -ar ANDROID_PROJECT_NAMES=(
|
|||||||
|
|
||||||
for PROJECT_NAME in "${ANDROID_PROJECT_NAMES[@]}"
|
for PROJECT_NAME in "${ANDROID_PROJECT_NAMES[@]}"
|
||||||
do
|
do
|
||||||
echo "== Testing '${PROJECT_NAME}' on Flutter's ${FLUTTER_VERSION} channel =="
|
echo "== Testing '${PROJECT_NAME}' on Flutter's stable channel =="
|
||||||
pushd "${PROJECT_NAME}"
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
./gradlew --stacktrace assembleDebug
|
./gradlew --stacktrace assembleDebug
|
||||||
|
|||||||
63
tool/flutter_ci_script_beta.sh
Executable file
63
tool/flutter_ci_script_beta.sh
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
declare -ar PROJECT_NAMES=(
|
||||||
|
"add_to_app/flutter_module" \
|
||||||
|
"add_to_app/flutter_module_using_plugin" \
|
||||||
|
"add_to_app/flutter_module_books" \
|
||||||
|
"animations" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/652
|
||||||
|
# "flutter_maps_firestore" \
|
||||||
|
"infinite_list" \
|
||||||
|
"ios_app_clip" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/653
|
||||||
|
# "isolate_example" \
|
||||||
|
"jsonexample" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/655
|
||||||
|
# "place_tracker" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/656
|
||||||
|
# "platform_channels" \
|
||||||
|
"platform_design"
|
||||||
|
"platform_view_swift" \
|
||||||
|
"provider_counter" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/657
|
||||||
|
# "provider_shopper" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/658
|
||||||
|
# "testing_app" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/659
|
||||||
|
# "experimental/federated_plugin/federated_plugin" \
|
||||||
|
"experimental/null_safety/null_safe_app" \
|
||||||
|
"experimental/null_safety/null_unsafe_app" \
|
||||||
|
"experimental/veggieseasons" \
|
||||||
|
"experimental/web_dashboard" \
|
||||||
|
)
|
||||||
|
|
||||||
|
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
|
||||||
|
do
|
||||||
|
echo "== Testing '${PROJECT_NAME}' on Flutter's beta channel =="
|
||||||
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
|
# Grab packages.
|
||||||
|
flutter pub get
|
||||||
|
|
||||||
|
# Run the analyzer to find any static analysis issues.
|
||||||
|
flutter analyze
|
||||||
|
|
||||||
|
# Reformat the web plugin registrant, if necessary.
|
||||||
|
if [ -f "lib/generated_plugin_registrant.dart" ]
|
||||||
|
then
|
||||||
|
echo "Renaming $(pwd)/lib/generated_plugin_registrant.dart"
|
||||||
|
flutter format "lib/generated_plugin_registrant.dart"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the formatter on all the dart files to make sure everything's linted.
|
||||||
|
flutter format -n --set-exit-if-changed .
|
||||||
|
|
||||||
|
# Run the actual tests.
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "-- Success --"
|
||||||
64
tool/flutter_ci_script_dev.sh
Executable file
64
tool/flutter_ci_script_dev.sh
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
declare -ar PROJECT_NAMES=(
|
||||||
|
"add_to_app/flutter_module" \
|
||||||
|
"add_to_app/flutter_module_using_plugin" \
|
||||||
|
"add_to_app/flutter_module_books" \
|
||||||
|
"animations" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/652
|
||||||
|
# "flutter_maps_firestore" \
|
||||||
|
"infinite_list" \
|
||||||
|
"ios_app_clip" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/653
|
||||||
|
# "isolate_example" \
|
||||||
|
"jsonexample" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/655
|
||||||
|
# "place_tracker" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/656
|
||||||
|
# "platform_channels" \
|
||||||
|
"platform_design"
|
||||||
|
"platform_view_swift" \
|
||||||
|
"provider_counter" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/657
|
||||||
|
# "provider_shopper" \
|
||||||
|
# Tracking issue: https://github.com/flutter/samples/issues/658
|
||||||
|
# "testing_app" \
|
||||||
|
"experimental/desktop_photo_search" \
|
||||||
|
# https://github.com/flutter/samples/issues/659
|
||||||
|
# "experimental/federated_plugin/federated_plugin" \
|
||||||
|
"experimental/null_safety/null_safe_app" \
|
||||||
|
"experimental/null_safety/null_unsafe_app" \
|
||||||
|
"experimental/veggieseasons" \
|
||||||
|
"experimental/web_dashboard" \
|
||||||
|
)
|
||||||
|
|
||||||
|
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
|
||||||
|
do
|
||||||
|
echo "== Testing '${PROJECT_NAME}' on Flutter's dev channel =="
|
||||||
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
|
# Grab packages.
|
||||||
|
flutter pub get
|
||||||
|
|
||||||
|
# Run the analyzer to find any static analysis issues.
|
||||||
|
flutter analyze
|
||||||
|
|
||||||
|
# Reformat the web plugin registrant, if necessary.
|
||||||
|
if [ -f "lib/generated_plugin_registrant.dart" ]
|
||||||
|
then
|
||||||
|
echo "Renaming $(pwd)/lib/generated_plugin_registrant.dart"
|
||||||
|
flutter format "lib/generated_plugin_registrant.dart"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the formatter on all the dart files to make sure everything's linted.
|
||||||
|
flutter format -n --set-exit-if-changed .
|
||||||
|
|
||||||
|
# Run the actual tests.
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "-- Success --"
|
||||||
@@ -25,7 +25,7 @@ declare -ar PROJECT_NAMES=(
|
|||||||
|
|
||||||
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
|
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
|
||||||
do
|
do
|
||||||
echo "== Testing '${PROJECT_NAME}' on Flutter's ${FLUTTER_VERSION} channel =="
|
echo "== Testing '${PROJECT_NAME}' on Flutter's stable channel =="
|
||||||
pushd "${PROJECT_NAME}"
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
# Grab packages.
|
# Grab packages.
|
||||||
Reference in New Issue
Block a user