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