Skip to content

Commit 2352a8e

Browse files
committed
feat: rules_flutter
1 parent 1624c75 commit 2352a8e

Some content is hidden

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

69 files changed

+11420
-70
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ node_modules
1010
target/
1111
third_party/docsite/node_modules
1212
bazel/rules_dart
13+
bazel/rules_flutter

.github/workflows/flutter.yml

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
name: "Flutter Rules checks"
18+
19+
on:
20+
pull_request:
21+
branches: [main]
22+
push:
23+
branches: [main]
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
check-paths:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
any_changed: ${{ steps.changed-files.outputs.any_changed }}
33+
steps:
34+
- uses: actions/checkout@v6
35+
with:
36+
fetch-depth: 0
37+
- name: Get changed files
38+
id: changed-files
39+
uses: tj-actions/changed-files@v45
40+
with:
41+
files: |
42+
bazel/rules_flutter/**
43+
bazel/rules_dart/**
44+
.github/workflows/flutter.yml
45+
46+
bazel-build:
47+
needs: check-paths
48+
if: needs.check-paths.outputs.any_changed == 'true'
49+
name: Bazel Build (${{ matrix.os }})
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
os: [ubuntu-latest, macos-latest]
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v6
58+
59+
- name: Setup Bazel
60+
uses: bazel-contrib/setup-bazel@0.18.0
61+
with:
62+
bazelisk-cache: true
63+
disk-cache: ${{ github.workflow }}-${{ matrix.os }}
64+
repository-cache: true
65+
66+
- name: Build rules_flutter
67+
working-directory: bazel/rules_flutter
68+
run: bazel build //...
69+
70+
- name: Query all targets
71+
working-directory: bazel/rules_flutter
72+
run: bazel query //...
73+
74+
starlark-lint:
75+
needs: check-paths
76+
if: needs.check-paths.outputs.any_changed == 'true'
77+
name: Starlark Lint
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v6
82+
83+
- name: Install buildifier
84+
run: |
85+
wget -q https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/buildifier-linux-amd64
86+
chmod +x buildifier-linux-amd64
87+
sudo mv buildifier-linux-amd64 /usr/local/bin/buildifier
88+
89+
- name: Check formatting (rules_flutter)
90+
working-directory: bazel/rules_flutter
91+
run: |
92+
buildifier --mode=check --lint=warn -r .
93+
94+
- name: Check formatting (rules_dart)
95+
working-directory: bazel/rules_dart
96+
run: |
97+
buildifier --mode=check --lint=warn -r .
98+
99+
grpc-example:
100+
needs: check-paths
101+
if: needs.check-paths.outputs.any_changed == 'true'
102+
name: gRPC Example (${{ matrix.os }})
103+
runs-on: ${{ matrix.os }}
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
os: [ubuntu-latest, macos-latest]
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v6
111+
112+
- name: Setup Flutter
113+
uses: subosito/flutter-action@v2
114+
with:
115+
flutter-version: '3.27.0'
116+
channel: 'stable'
117+
cache: true
118+
119+
- name: Setup Dart
120+
uses: dart-lang/setup-dart@v1
121+
with:
122+
sdk: stable
123+
124+
- name: Install protoc
125+
uses: arduino/setup-protoc@v3
126+
with:
127+
version: '28.x'
128+
129+
- name: Install protoc-gen-dart
130+
run: dart pub global activate protoc_plugin
131+
132+
- name: Setup gRPC example
133+
working-directory: bazel/rules_flutter/examples/grpc_app
134+
run: |
135+
# Get dependencies
136+
flutter pub get
137+
cd server && dart pub get && cd ..
138+
139+
# Add platform support
140+
flutter create --platforms=web,linux . 2>/dev/null || true
141+
142+
# Generate proto files
143+
mkdir -p lib/generated server/lib/generated
144+
export PATH="$HOME/.pub-cache/bin:$PATH"
145+
protoc --dart_out=grpc:lib/generated -Iproto proto/helloworld.proto
146+
cp lib/generated/*.dart server/lib/generated/
147+
148+
- name: Analyze Flutter client
149+
working-directory: bazel/rules_flutter/examples/grpc_app
150+
run: flutter analyze
151+
152+
- name: Analyze Dart server
153+
working-directory: bazel/rules_flutter/examples/grpc_app/server
154+
run: dart analyze
155+
156+
- name: Build Flutter web
157+
working-directory: bazel/rules_flutter/examples/grpc_app
158+
run: flutter build web
159+
160+
- name: Test server startup
161+
working-directory: bazel/rules_flutter/examples/grpc_app/server
162+
run: |
163+
# Start server in background
164+
dart run bin/server.dart &
165+
SERVER_PID=$!
166+
sleep 3
167+
168+
# Check if server is running
169+
if kill -0 $SERVER_PID 2>/dev/null; then
170+
echo "Server started successfully"
171+
kill $SERVER_PID
172+
else
173+
echo "Server failed to start"
174+
exit 1
175+
fi
176+
177+
container-proxy:
178+
needs: check-paths
179+
if: needs.check-paths.outputs.any_changed == 'true'
180+
name: Container Proxy Config
181+
runs-on: ubuntu-latest
182+
steps:
183+
- name: Checkout code
184+
uses: actions/checkout@v6
185+
186+
- name: Validate Envoy config syntax
187+
working-directory: bazel/rules_flutter/examples/grpc_app/proxy
188+
run: |
189+
# Basic YAML validation
190+
python3 -c "import yaml; yaml.safe_load(open('envoy.yaml'))"
191+
echo "Envoy config is valid YAML"
192+
193+
- name: Validate docker-compose.yaml
194+
working-directory: bazel/rules_flutter/examples/grpc_app/proxy
195+
run: |
196+
# Basic YAML validation
197+
python3 -c "import yaml; yaml.safe_load(open('docker-compose.yaml'))"
198+
echo "docker-compose.yaml is valid YAML"
199+
200+
- name: Test Envoy container start (Podman preferred)
201+
working-directory: bazel/rules_flutter/examples/grpc_app/proxy
202+
run: |
203+
# Prefer Podman, fall back to Docker
204+
if command -v podman &> /dev/null; then
205+
RUNTIME="podman"
206+
else
207+
RUNTIME="docker"
208+
fi
209+
echo "Using container runtime: $RUNTIME"
210+
211+
$RUNTIME run -d --name envoy-test \
212+
-v $(pwd)/envoy.yaml:/etc/envoy/envoy.yaml:ro \
213+
-p 8080:8080 -p 9901:9901 \
214+
envoyproxy/envoy:distroless-v1.28-latest -c /etc/envoy/envoy.yaml
215+
216+
# Give it time to start
217+
sleep 5
218+
219+
# Check if container is running
220+
if $RUNTIME ps | grep envoy-test; then
221+
echo "Envoy container started successfully"
222+
223+
# Check admin endpoint
224+
curl -s http://localhost:9901/ready || true
225+
226+
$RUNTIME stop envoy-test
227+
$RUNTIME rm envoy-test
228+
else
229+
echo "Envoy container failed to start"
230+
$RUNTIME logs envoy-test || true
231+
$RUNTIME rm envoy-test || true
232+
exit 1
233+
fi
234+
235+
windows-build:
236+
needs: check-paths
237+
if: needs.check-paths.outputs.any_changed == 'true'
238+
name: Windows Build
239+
runs-on: windows-latest
240+
steps:
241+
- name: Checkout code
242+
uses: actions/checkout@v6
243+
244+
- name: Setup Bazel
245+
uses: bazel-contrib/setup-bazel@0.18.0
246+
with:
247+
bazelisk-cache: true
248+
disk-cache: ${{ github.workflow }}-windows
249+
repository-cache: true
250+
251+
- name: Build rules_flutter
252+
working-directory: bazel/rules_flutter
253+
run: bazel build //...
254+
255+
- name: Query all targets
256+
working-directory: bazel/rules_flutter
257+
run: bazel query //...
258+
259+
flutter-checks-all:
260+
if: always()
261+
needs: [bazel-build, starlark-lint, grpc-example, container-proxy, windows-build]
262+
runs-on: ubuntu-latest
263+
steps:
264+
- name: Check overall status
265+
run: |
266+
if [[ "${{ needs.bazel-build.result }}" == "failure" || \
267+
"${{ needs.starlark-lint.result }}" == "failure" || \
268+
"${{ needs.grpc-example.result }}" == "failure" || \
269+
"${{ needs.container-proxy.result }}" == "failure" || \
270+
"${{ needs.windows-build.result }}" == "failure" ]]; then
271+
echo "Flutter rules checks failed"
272+
exit 1
273+
fi
274+
echo "Flutter rules checks passed or were skipped"
275+
exit 0

.release-please-config.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"pull-request-title-pattern": "chore(release): ${component} ${version}",
1010
"separate-pull-requests": true,
1111
"skip-github-release": false,
12-
"plugins": ["node-workspace"],
12+
"plugins": [
13+
"node-workspace"
14+
],
1315
"packages": {
1416
"js": {
1517
"release-type": "node",
@@ -93,6 +95,10 @@
9395
"release-type": "simple",
9496
"component": "rules_dart"
9597
},
98+
"bazel/rules_flutter": {
99+
"release-type": "simple",
100+
"component": "rules_flutter"
101+
},
96102
"packages/vscode": {
97103
"release-type": "node",
98104
"component": "dotprompt-vscode"
@@ -126,4 +132,4 @@
126132
"component": "promptly"
127133
}
128134
}
129-
}
135+
}

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"java": "0.1.0",
77
"dart/dotprompt": "0.0.1",
88
"bazel/rules_dart": "0.0.1",
9+
"bazel/rules_flutter": "0.1.0",
910
"rs": "0.1.0",
1011
"packages/vscode": "0.0.1",
1112
"packages/vim": "0.1.0",
@@ -15,4 +16,4 @@
1516
"packages/jetbrains": "0.2.0",
1617
"packages/treesitter": "0.1.0",
1718
"packages/promptly": "0.1.0"
18-
}
19+
}

MODULE.bazel.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/rules_dart/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,29 @@ dart.configure(
459459
)
460460
```
461461

462+
### Disabling Analytics
463+
464+
By default, Dart analytics are disabled for hermetic builds. You can control this:
465+
466+
```python
467+
dart.configure(
468+
version = "3.7.0",
469+
disable_analytics = True, # Default: analytics disabled
470+
)
471+
```
472+
473+
To enable analytics (not recommended for CI/hermetic builds):
474+
475+
```python
476+
dart.configure(
477+
version = "3.7.0",
478+
disable_analytics = False,
479+
)
480+
```
481+
482+
**Note**: Disabling analytics creates `disable_analytics.sh` and `disable_analytics.bat`
483+
scripts in the SDK repository that you can run to permanently disable analytics.
484+
462485
### Gazelle Integration
463486

464487
Generate BUILD files from `pubspec.yaml`:

0 commit comments

Comments
 (0)