Skip to content

Commit c5083bd

Browse files
committed
ci: extract example app builds into a separate workflow
Move the platform builds (web, macOS, Windows, iOS, Android, Linux) of the example app out of the test workflow and into a dedicated build workflow that runs on pull requests. The test workflow keeps formatting, analysis, unit tests, the web test, and coverage.
1 parent 311f883 commit c5083bd

2 files changed

Lines changed: 154 additions & 36 deletions

File tree

.github/workflows/build.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
changes:
15+
name: Detect affected packages
16+
runs-on: ubuntu-latest
17+
outputs:
18+
flutter: ${{ steps.detect.outputs.flutter }}
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup Dart
26+
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # v1.7.1
27+
with:
28+
sdk: stable
29+
30+
- name: Detect affected packages
31+
id: detect
32+
run: |
33+
set -euo pipefail
34+
35+
dart pub global activate melos
36+
37+
BASE="${{ github.event.pull_request.base.sha }}"
38+
39+
FORCE_ALL=false
40+
if [ -z "$BASE" ]; then
41+
FORCE_ALL=true
42+
elif git diff --name-only "$BASE...HEAD" \
43+
| grep -qE '^(\.github/workflows/build\.yml|melos\.yaml|pubspec\.lock|infra/)'; then
44+
FORCE_ALL=true
45+
fi
46+
47+
if [ "$FORCE_ALL" = "true" ]; then
48+
echo "Running all packages."
49+
CHANGED=$(melos list --json | jq -r '.[].name')
50+
else
51+
CHANGED=$(melos list --json --diff="$BASE...HEAD" --include-dependents | jq -r '.[].name')
52+
fi
53+
54+
echo "Affected packages:"
55+
echo "$CHANGED"
56+
57+
if echo "$CHANGED" | grep -qx "supabase_flutter"; then
58+
echo "flutter=true" >> "$GITHUB_OUTPUT"
59+
else
60+
echo "flutter=false" >> "$GITHUB_OUTPUT"
61+
fi
62+
63+
build-flutter:
64+
name: Build on ${{ matrix.os }}
65+
needs: changes
66+
if: ${{ needs.changes.outputs.flutter == 'true' }}
67+
timeout-minutes: 30
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
os: [ubuntu-latest, macos-latest, windows-latest]
72+
73+
defaults:
74+
run:
75+
working-directory: packages/supabase_flutter
76+
77+
runs-on: ${{ matrix.os }}
78+
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
82+
83+
- name: Setup Flutter
84+
uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0
85+
with:
86+
flutter-version: '3.x'
87+
channel: 'stable'
88+
# Caching 3.x (latest stable) is flaky: the cached SDK contains
89+
# runner-image-specific binaries that break silently when the runner
90+
# image is updated.
91+
cache: false
92+
93+
- name: Show Flutter version
94+
run: flutter --version
95+
96+
- name: Bootstrap workspace
97+
run: |
98+
cd ../../
99+
dart pub global activate melos
100+
melos bootstrap
101+
102+
- name: Build web app
103+
if: ${{ matrix.os == 'ubuntu-latest' }}
104+
run: |
105+
cd example
106+
flutter build web
107+
108+
- name: Build Linux app
109+
if: ${{ matrix.os == 'ubuntu-latest' }}
110+
run: |
111+
sudo apt-get update
112+
sudo apt-get install -y libgtk-3-dev libblkid-dev liblzma-dev
113+
cd example
114+
flutter build linux
115+
116+
- name: Build Android app
117+
if: ${{ matrix.os == 'ubuntu-latest' }}
118+
run: |
119+
cd example
120+
flutter build apk
121+
122+
- name: Build macOS app
123+
if: ${{ matrix.os == 'macos-latest' }}
124+
run: |
125+
cd example
126+
flutter build macos
127+
128+
- name: Build iOS app
129+
if: ${{ matrix.os == 'macos-latest' }}
130+
run: |
131+
cd example
132+
flutter build ios --no-codesign
133+
134+
- name: Build Windows app
135+
if: ${{ matrix.os == 'windows-latest' }}
136+
run: |
137+
cd example
138+
flutter build windows
139+
140+
build-result:
141+
name: Build result
142+
needs: [changes, build-flutter]
143+
if: ${{ always() }}
144+
runs-on: ubuntu-latest
145+
steps:
146+
- name: Verify all jobs succeeded
147+
run: |
148+
if ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}; then
149+
echo "One or more jobs failed or were cancelled."
150+
exit 1
151+
fi
152+
echo "All required jobs passed or were skipped."

.github/workflows/test.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -260,43 +260,9 @@ jobs:
260260
path-to-lcov: packages/supabase_flutter/coverage/lcov.info
261261
fail-on-error: false
262262

263-
- name: Build and test web (JS)
263+
- name: Test web (JS)
264264
if: ${{ matrix.os == 'ubuntu-latest' && matrix.flutter-version == '3.x'}}
265-
run: |
266-
flutter test --platform chrome
267-
cd example && flutter build web
268-
269-
- name: Build macOS app
270-
if: ${{ matrix.os == 'macos-latest' && matrix.flutter-version == '3.x'}}
271-
run: |
272-
cd example
273-
flutter build macos
274-
275-
- name: Build Windows app
276-
if: ${{ matrix.os == 'windows-latest' && matrix.flutter-version == '3.x'}}
277-
run: |
278-
cd example
279-
flutter build windows
280-
281-
- name: Build Linux app
282-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.flutter-version == '3.x'}}
283-
run: |
284-
sudo apt-get update
285-
sudo apt-get install -y libgtk-3-dev libblkid-dev liblzma-dev
286-
cd example
287-
flutter build linux
288-
289-
- name: Build iOS app
290-
if: ${{ matrix.os == 'macos-latest' && matrix.flutter-version == '3.x'}}
291-
run: |
292-
cd example
293-
flutter build ios --no-codesign
294-
295-
- name: Build Android app
296-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.flutter-version == '3.x'}}
297-
run: |
298-
cd example
299-
flutter build apk
265+
run: flutter test --platform chrome
300266

301267
coverage-finished:
302268
name: Finish coverage

0 commit comments

Comments
 (0)