Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Run verifications on all platforms #565

Merged
merged 11 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 50 additions & 60 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests
on:
push:
branches:
- master
- master
pull_request:

jobs:
Expand All @@ -13,79 +13,69 @@ jobs:
matrix:
os: [ubuntu-18.04, windows-2019, macos-10.15]
steps:
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v

# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get
# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get

# Analyze, check formatting, and run unit tests.
- run: flutter analyze
- name: Ensure the Dart code is formatted correctly
run: flutter format --set-exit-if-changed --dry-run .
- name: Run Flutter unit tests
run: flutter test

# Run custom scripts defined in `tool/grind.dart`.
- name: Verify that localizations are up to date
run: flutter pub run grinder verify-l10n
# TODO: Enable verify-l10n for Windows when it behaves the same as on macOS/Ubuntu:
# https://github.com/material-components/material-components-flutter-gallery/issues/565
if: startsWith(matrix.os, 'macOS') || startsWith(matrix.os, 'ubuntu')
- name: Verify that code segments are up to date
run: flutter pub run grinder verify-code-segments
# TODO: Enable verify-code-segments for Unix and Windows when it behaves the same as on macOS:
# https://github.com/material-components/material-components-flutter-gallery/issues/565
if: startsWith(matrix.os, 'macOS')
# Analyze, check formatting, and run unit tests.
- run: flutter analyze
- name: Ensure the Dart code is formatted correctly
run: flutter format --set-exit-if-changed --dry-run .
- name: Run Flutter unit tests
run: flutter test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only change is here, the rest is automatic formatting


# Run custom scripts defined in `tool/grind.dart`.
- name: Verify that code segments are up to date
run: flutter pub run grinder verify-code-segments

benchmark-test:
name: Benchmark tests
runs-on: ubuntu-18.04
steps:
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v
- run: flutter config --enable-web

# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v
- run: flutter config --enable-web

- run: flutter test test_benchmarks
# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get

- run: flutter test test_benchmarks

golden-test:
name: Golden tests
runs-on: macos-10.15
steps:
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@4389e6cbc6cb8a4b18c628ff96ff90be0e926aa8
with:
channel: master
- run: flutter doctor -v

# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get
# Checkout gallery code and get packages.
- name: Checkout gallery code
uses: actions/checkout@v2
- run: flutter pub get

# Run the golden tests and upload failed test artifacts.
- run: flutter test test_goldens
- name: Upload goldens if tests fail
uses: actions/upload-artifact@v1
if: failure()
with:
name: goldens
path: test_goldens/failures/
# Run the golden tests and upload failed test artifacts.
- run: flutter test test_goldens
- name: Upload goldens if tests fail
uses: actions/upload-artifact@v1
if: failure()
with:
name: goldens
path: test_goldens/failures/
16 changes: 8 additions & 8 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
"@rallyLoginButtonLogin": {
"description": "Text for login button."
},
"rallyAlertsMessageHeadsUpShopping": "Heads up, youve used up {percent} of your Shopping budget for this month.",
"rallyAlertsMessageHeadsUpShopping": "Heads up, you've used up {percent} of your Shopping budget for this month.",
"@rallyAlertsMessageHeadsUpShopping": {
"description": "Alert message shown when for example, user has used more than 90% of their shopping budget.",
"placeholders": {
Expand All @@ -352,7 +352,7 @@
}
}
},
"rallyAlertsMessageSpentOnRestaurants": "Youve spent {amount} on Restaurants this week.",
"rallyAlertsMessageSpentOnRestaurants": "You've spent {amount} on Restaurants this week.",
"@rallyAlertsMessageSpentOnRestaurants": {
"description": "Alert message shown when for example, user has spent $120 on Restaurants this week.",
"placeholders": {
Expand All @@ -361,7 +361,7 @@
}
}
},
"rallyAlertsMessageATMFees": "Youve spent {amount} in ATM fees this month",
"rallyAlertsMessageATMFees": "You've spent {amount} in ATM fees this month",
"@rallyAlertsMessageATMFees": {
"description": "Alert message shown when for example, the user has spent $24 in ATM fees this month.",
"placeholders": {
Expand Down Expand Up @@ -601,7 +601,7 @@
"@demoAppBarSubtitle": {
"description": "Subtitle for the material App bar component demo."
},
"demoAppBarDescription": "The App bar provides content and actions related to the current screen. Its used for branding, screen titles, navigation, and actions",
"demoAppBarDescription": "The App bar provides content and actions related to the current screen. It's used for branding, screen titles, navigation, and actions",
"@demoAppBarDescription": {
"description": "Description for the material App bar component demo."
},
Expand Down Expand Up @@ -781,7 +781,7 @@
"@demoDataTableSubtitle": {
"description": "Subtitle for the material data table component demo."
},
"demoDataTableDescription": "Data tables display information in a grid-like format of rows and columns. They organize information in a way thats easy to scan, so that users can look for patterns and insights.",
"demoDataTableDescription": "Data tables display information in a grid-like format of rows and columns. They organize information in a way that's easy to scan, so that users can look for patterns and insights.",
"@demoDataTableDescription": {
"description": "Description for the material data table component demo."
},
Expand Down Expand Up @@ -1916,7 +1916,7 @@
"@demoSnackbarsSubtitle": {
"description": "Subtitle for snackbars demo."
},
"demoSnackbarsDescription": "Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldnt interrupt the user experience, and they dont require user input to disappear.",
"demoSnackbarsDescription": "Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn't interrupt the user experience, and they don't require user input to disappear.",
"@demoSnackbarsDescription": {
"description": "Description for snackbars demo."
},
Expand All @@ -1934,7 +1934,7 @@
},
"demoSnackbarsAction": "You pressed the snackbar action.",
"@demoSnackbarsAction": {
"description": "Text that appears when you press on a snackbars action."
"description": "Text that appears when you press on a snackbars' action."
},
"demoSelectionControlsTitle": "Selection controls",
"@demoSelectionControlsTitle": {
Expand Down Expand Up @@ -1964,7 +1964,7 @@
"@demoSelectionControlsSwitchTitle": {
"description": "Title for the switches (selection controls) demo."
},
"demoSelectionControlsSwitchDescription": "On/off switches toggle the state of a single settings option. The option that the switch controls, as well as the state its in, should be made clear from the corresponding inline label.",
"demoSelectionControlsSwitchDescription": "On/off switches toggle the state of a single settings option. The option that the switch controls, as well as the state it's in, should be made clear from the corresponding inline label.",
"@demoSelectionControlsSwitchDescription": {
"description": "Description for the switches (selection controls) demo."
},
Expand Down
16 changes: 8 additions & 8 deletions lib/l10n/intl_en_US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@
<string
name="rallyAlertsMessageHeadsUpShopping"
description="Alert message shown when for example, user has used more than 90% of their shopping budget."
>Heads up, youve used up {percent} of your Shopping budget for this month.</string>
>Heads up, you&apos;ve used up {percent} of your Shopping budget for this month.</string>
<string
name="rallyAlertsMessageSpentOnRestaurants"
description="Alert message shown when for example, user has spent $120 on Restaurants this week."
>Youve spent {amount} on Restaurants this week.</string>
>You&apos;ve spent {amount} on Restaurants this week.</string>
<string
name="rallyAlertsMessageATMFees"
description="Alert message shown when for example, the user has spent $24 in ATM fees this month."
>Youve spent {amount} in ATM fees this month</string>
>You&apos;ve spent {amount} in ATM fees this month</string>
<string
name="rallyAlertsMessageCheckingAccount"
description="Alert message shown when for example, the checking account is 1% higher than last month."
Expand Down Expand Up @@ -524,7 +524,7 @@
<string
name="demoAppBarDescription"
description="Description for the material App bar component demo."
>The App bar provides content and actions related to the current screen. Its used for branding, screen titles, navigation, and actions</string>
>The App bar provides content and actions related to the current screen. It&apos;s used for branding, screen titles, navigation, and actions</string>
<string
name="demoBottomAppBarTitle"
description="Title for the material bottom app bar component demo."
Expand Down Expand Up @@ -704,7 +704,7 @@
<string
name="demoDataTableDescription"
description="Description for the material data table component demo."
>Data tables display information in a grid-like format of rows and columns. They organize information in a way thats easy to scan, so that users can look for patterns and insights.</string>
>Data tables display information in a grid-like format of rows and columns. They organize information in a way that&apos;s easy to scan, so that users can look for patterns and insights.</string>
<string
name="dataTableHeader"
description="Header for the data table component demo about nutrition."
Expand Down Expand Up @@ -1804,7 +1804,7 @@
<string
name="demoSnackbarsDescription"
description="Description for snackbars demo."
>Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldnt interrupt the user experience, and they dont require user input to disappear.</string>
>Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn&apos;t interrupt the user experience, and they don&apos;t require user input to disappear.</string>
<string
name="demoSnackbarsButtonLabel"
description="Label for button to show a snackbar."
Expand All @@ -1819,7 +1819,7 @@
>ACTION</string>
<string
name="demoSnackbarsAction"
description="Text that appears when you press on a snackbars action."
description="Text that appears when you press on a snackbars&apos; action."
>You pressed the snackbar action.</string>
<string
name="demoSelectionControlsTitle"
Expand Down Expand Up @@ -1852,7 +1852,7 @@
<string
name="demoSelectionControlsSwitchDescription"
description="Description for the switches (selection controls) demo."
>On/off switches toggle the state of a single settings option. The option that the switch controls, as well as the state its in, should be made clear from the corresponding inline label.</string>
>On/off switches toggle the state of a single settings option. The option that the switch controls, as well as the state it&apos;s in, should be made clear from the corresponding inline label.</string>
<string
name="demoBottomTextFieldsTitle"
description="Title for text fields demo."
Expand Down
21 changes: 21 additions & 0 deletions test/l10n.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:test/test.dart';

import '../tool/l10n_cli/l10n_cli.dart';

String _standardizeLineEndings(String str) => str.replaceAll('\r\n', '\n');

void main() {
/// Verifies that intl_en_US.xml is updated.
test('verify intl_en_US.xml is up to date', () async {
final currentXml = getDefaultXml().replaceAll('\r\n', '\n');
final newXml = (await generateXmlFromArb()).replaceAll('\r\n', '\n');

expect(_standardizeLineEndings(currentXml), _standardizeLineEndings(newXml),
reason: 'intl_en_US.xml is not up to date. '
'Did you forget to run `flutter pub run grinder l10n`?');
});
}
23 changes: 0 additions & 23 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ Future<void> l10n() async {
Dart.run(l10nPath);
}

@Task('Verify xml localizations')
Future<void> verifyL10n() async {
final l10nPath =
path.join(Directory.current.path, 'tool', 'l10n_cli', 'main.dart');

// Run the tool to transform arb to xml, and write the output to stdout.
final xmlOutput = Dart.run(l10nPath, arguments: ['--dry-run'], quiet: true);

// Read the original xml file.
final xmlPath =
path.join(Directory.current.path, 'lib', 'l10n', 'intl_en_US.xml');
final expectedXmlOutput = await File(xmlPath).readAsString();

if (xmlOutput.trim() != expectedXmlOutput.trim()) {
stderr.writeln(
'The contents of $xmlPath are different from that produced by '
'l10n_cli. Did you forget to run `flutter pub run grinder '
'l10n` after updating an .arb file?',
);
exit(1);
}
}

@Task('Update code segments')
Future<void> updateCodeSegments() async {
final codeviewerPath =
Expand Down
Loading