Skip to content

Commit bc95470

Browse files
authored
Turn on tests again. (#26)
This enables tests again on PRs. See the .github/workflows/flutter_packages.yaml file for details. They got broken because I set it up with specific paths. This should now search for directories with pubspec.yaml files and run the tests in each one. I also fixed all the existing issues, and normalized the SDK constraints. It does do the setup for Flutter for each package, but the Flutter download is cached. I tried making it all one step, but then you can't see separate steps in the Github UI, and they can't run in parallel.
1 parent a50042f commit bc95470

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1007
-840
lines changed

.gemini/config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Maximize verbosity.
2-
have_fun: true
2+
have_fun: false
33
code_review:
4+
disable: false
5+
# Set to -1 for unlimited comments.
6+
max_review_comments: 3
47
# For now, use the default of MEDIUM for testing. Based on desired verbosity,
58
# we can change this to LOW or HIGH in the future.
69
comment_severity_threshold: MEDIUM
@@ -10,4 +13,4 @@ code_review:
1013
help: false
1114
# These tend to be verbose, and since we expect PR authors to clearly
1215
# describe their PRs this would be at best duplicative.
13-
summary: false
16+
summary: false

.github/workflows/flutter_packages.yaml

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,76 +9,126 @@ on:
99
paths:
1010
- ".github/workflows/flutter_packages.yaml"
1111
- "pkgs/**"
12+
- "examples/**"
1213
pull_request:
1314
branches:
1415
- main
1516
paths:
1617
- ".github/workflows/flutter_packages.yaml"
1718
- "pkgs/**"
19+
- "examples/**"
1820

1921
concurrency:
2022
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2123
cancel-in-progress: true
2224

2325
jobs:
24-
changes:
26+
matrix:
2527
runs-on: ubuntu-latest
2628
outputs:
27-
# The output will be a JSON array of package names, e.g.
28-
# '["genui_client"]'
29-
matrix: ${{ steps.filter.outputs.changes }}
29+
matrix: ${{ steps.generate_matrix.outputs.matrix }}
3030
steps:
3131
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
32-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
33-
id: filter
3432
with:
35-
# For pushes, the base is the previous commit. For PRs, it's the
36-
# target branch.
37-
base: ${{ github.base_ref }}
38-
# The name of the filter becomes the value in the output matrix.
39-
filters: |
40-
genui_client:
41-
- "pkgs/genui_client/**"
42-
# To add another package, create a new entry here.
43-
# another_package:
44-
# - "pkgs/another_package/**"
33+
# Fetch the full history to be able to diff against the base branch
34+
fetch-depth: 0
35+
36+
- name: Generate testing matrix
37+
id: generate_matrix
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
# Find all directories containing pubspec.yaml in pkgs and examples.
42+
ALL_DIRS=$(find pkgs examples -name pubspec.yaml -not -path "*/.dart_tool/*" -exec dirname {} \;)
43+
44+
# Get the list of changed files. The method depends on the event type.
45+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
46+
# For PRs, use the GitHub CLI to get a precise list of changed files.
47+
CHANGED_FILES=$(gh pr diff --name-only ${{ github.event.pull_request.number }})
48+
else
49+
# For pushes, diff between the two SHAs of the push.
50+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
51+
fi
52+
53+
# If the workflow file itself changed, we run all packages.
54+
if echo "$CHANGED_FILES" | grep -q "^\.github/workflows/flutter_packages.yaml$"; then
55+
echo "Workflow file changed. Testing all packages."
56+
CHANGED_DIRS=$ALL_DIRS
57+
else
58+
# Otherwise, determine which packages were actually changed.
59+
CHANGED_DIRS=""
60+
for dir in $ALL_DIRS; do
61+
# Check if any changed file starts with the package directory path.
62+
if echo "$CHANGED_FILES" | grep -q "^$dir/"; then
63+
CHANGED_DIRS="$CHANGED_DIRS$dir "
64+
fi
65+
done
66+
fi
67+
68+
# Build a JSON array of package objects for the matrix.
69+
JSON_MATRIX="["
70+
FIRST=true
71+
for dir in $CHANGED_DIRS; do
72+
if [ "$FIRST" = false ]; then
73+
JSON_MATRIX="$JSON_MATRIX,"
74+
fi
75+
FIRST=false
76+
# The name for the job (path with '/' -> '_')
77+
package_name=$(echo "$dir" | tr '/' '_')
78+
# The actual path to the package
79+
package_path="$dir"
80+
JSON_MATRIX="$JSON_MATRIX{\"name\":\"$package_name\",\"path\":\"$package_path\"}"
81+
done
82+
JSON_MATRIX="$JSON_MATRIX]"
83+
84+
echo "matrix=$JSON_MATRIX" >> $GITHUB_OUTPUT
4585
4686
analyze_and_test:
47-
needs: changes
48-
# Only run if the 'changes' job has found changed packages.
49-
if: github.repository == 'flutter/genui' && needs.changes.outputs.matrix != '[]'
50-
name: Test ${{ matrix.package }} on ${{ matrix.os }} with Flutter ${{ matrix.flutter_version }}
87+
needs: matrix
88+
# Only run if the matrix job has produced a non-empty matrix.
89+
if: github.repository == 'flutter/genui' && ${{ needs.matrix.outputs.matrix != '[]' }}
90+
name: ${{ matrix.package.name }} (${{ matrix.flutter_version }})
5191
runs-on: ${{ matrix.os }}
5292
strategy:
5393
fail-fast: false
5494
matrix:
55-
# The list of packages is dynamically set from the 'changes' job.
56-
package: ${{ fromJSON(needs.changes.outputs.matrix) }}
57-
flutter_version: [stable, beta, master]
58-
os: [ubuntu-latest, macos-latest, windows-latest]
59-
defaults:
60-
run:
61-
working-directory: pkgs/${{ matrix.package }}
95+
package: ${{ fromJson(needs.matrix.outputs.matrix) }}
96+
flutter_version: [beta]
97+
os: [ubuntu-latest]
6298
steps:
6399
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
64100
- uses: actions/setup-java@17f84c3641ba7b8f6deff6309fc4c864478f5d62
65101
with:
66102
distribution: "zulu"
67103
java-version: "17"
104+
cache: "gradle"
68105
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
69106
with:
70107
channel: ${{ matrix.flutter_version }}
108+
cache: true
71109
- name: Cache Pub dependencies
72110
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
73111
with:
74112
path: ${{ env.PUB_CACHE }}
75113
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
76114
restore-keys: ${{ runner.os }}-pub-
115+
- name: Update submodules
116+
working-directory: ${{ matrix.package.path }}
117+
run: git submodule update --init --recursive
77118
- name: Install dependencies
119+
working-directory: ${{ matrix.package.path }}
78120
run: dart pub get
79121
- name: Check formatting
122+
working-directory: ${{ matrix.package.path }}
80123
run: dart format --output=none --set-exit-if-changed .
81124
- name: Analyze code
125+
working-directory: ${{ matrix.package.path }}
82126
run: flutter analyze --fatal-infos
83-
- name: Run Flutter tests
84-
run: flutter test --test-randomize-ordering-seed=random
127+
- name: Run tests
128+
working-directory: ${{ matrix.package.path }}
129+
run: |
130+
if [ -d "test" ]; then
131+
flutter test --test-randomize-ordering-seed=random
132+
else
133+
echo "No 'test' directory found in ${{ matrix.package.path }}, skipping tests."
134+
fi

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "pkgs/spikes/dart_schema_builder/submodules/JSON-Schema-Test-Suite"]
2-
path = pkgs/dart_schema_builder/submodules/JSON-Schema-Test-Suite
3-
url = git@github.com:json-schema-org/JSON-Schema-Test-Suite.git
1+
[submodule "pkgs/dart_schema_builder/submodules/JSON-Schema-Test-Suite"]
2+
path = pkgs/dart_schema_builder/submodules/JSON-Schema-Test-Suite
3+
url = https://github.com/json-schema-org/JSON-Schema-Test-Suite.git

examples/generic_chat/lib/main.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ Typically, you should not update existing surfaces and instead just continually
1717

1818
void main() async {
1919
WidgetsFlutterBinding.ensureInitialized();
20-
await Firebase.initializeApp(
21-
options: DefaultFirebaseOptions.currentPlatform,
22-
);
20+
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
2321
await FirebaseAppCheck.instance.activate(
2422
appleProvider: AppleProvider.debug,
2523
androidProvider: AndroidProvider.debug,
@@ -29,9 +27,7 @@ void main() async {
2927
}
3028

3129
class GenUIApp extends StatelessWidget {
32-
const GenUIApp({
33-
super.key,
34-
});
30+
const GenUIApp({super.key});
3531

3632
@override
3733
Widget build(BuildContext context) {
@@ -99,9 +95,7 @@ class _GenUIHomePageState extends State<GenUIHomePage> {
9995
constraints: const BoxConstraints(maxWidth: 1000),
10096
child: Column(
10197
children: [
102-
Expanded(
103-
child: _conversationManager.widget(),
104-
),
98+
Expanded(child: _conversationManager.widget()),
10599
Padding(
106100
padding: const EdgeInsets.all(8.0),
107101
child: Row(

examples/generic_chat/linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <url_launcher_linux/url_launcher_plugin.h>
910

1011
void fl_register_plugins(FlPluginRegistry* registry) {
12+
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
13+
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
14+
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
1115
}

examples/generic_chat/linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
url_launcher_linux
67
)
78

89
list(APPEND FLUTTER_FFI_PLUGIN_LIST

examples/generic_chat/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import Foundation
88
import firebase_app_check
99
import firebase_auth
1010
import firebase_core
11+
import url_launcher_macos
1112

1213
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
1314
FLTFirebaseAppCheckPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAppCheckPlugin"))
1415
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
1516
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
17+
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
1618
}

examples/generic_chat/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ publish_to: "none"
44
version: 0.1.0
55

66
environment:
7-
sdk: ">=3.3.0 <4.0.0"
7+
sdk: ">=3.8.0 <4.0.0"
88

99
dependencies:
1010
collection: ^1.19.1
1111
file: ^7.0.1
12-
firebase_ai: ^2.2.1
13-
firebase_app_check: ^0.3.0+1
14-
firebase_auth: ^5.1.2
15-
firebase_core: ^3.2.0
12+
firebase_ai: ^3.0.0
13+
firebase_app_check: ^0.4.0
14+
firebase_auth: ^6.0.0
15+
firebase_core: ^4.0.0
1616
flutter:
1717
sdk: flutter
1818
flutter_genui:

examples/generic_chat/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
#include <firebase_auth/firebase_auth_plugin_c_api.h>
1010
#include <firebase_core/firebase_core_plugin_c_api.h>
11+
#include <url_launcher_windows/url_launcher_windows.h>
1112

1213
void RegisterPlugins(flutter::PluginRegistry* registry) {
1314
FirebaseAuthPluginCApiRegisterWithRegistrar(
1415
registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi"));
1516
FirebaseCorePluginCApiRegisterWithRegistrar(
1617
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
18+
UrlLauncherWindowsRegisterWithRegistrar(
19+
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
1720
}

examples/generic_chat/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
list(APPEND FLUTTER_PLUGIN_LIST
66
firebase_auth
77
firebase_core
8+
url_launcher_windows
89
)
910

1011
list(APPEND FLUTTER_FFI_PLUGIN_LIST

0 commit comments

Comments
 (0)