main
1name: 'Extended testing'
2
3on:
4 workflow_dispatch:
5
6jobs:
7 setup-env:
8 name: "Setup environment"
9 runs-on: ubuntu-latest
10 steps:
11 - name: Checkout code
12 uses: actions/checkout@v4
13 with:
14 # ensures there are no unexpected directories needed
15 sparse-checkout: |
16 app
17 health_data_store
18 - name: Cache generated health data store
19 id: cache-generated
20 uses: actions/cache@v4
21 with:
22 path: health_data_store/lib
23 key: builder-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
24 - name: Setup dart
25 if: steps.cache-generated.outputs.cache-hit != 'true'
26 uses: dart-lang/setup-dart@v1
27 with:
28 sdk: stable
29 - name: Generate code
30 if: steps.cache-generated.outputs.cache-hit != 'true'
31 run: dart run build_runner build
32 working-directory: health_data_store
33 - name: Setup Flutter
34 uses: subosito/flutter-action@v2
35 with:
36 channel: stable
37 cache: true
38 - name: Disable analytics
39 run:
40 flutter config --no-analytics --suppress-analytics
41 - name: Update app dependencies
42 run: flutter pub get
43 working-directory: app
44 - name: Generate app mock code
45 run: flutter pub run build_runner build
46 working-directory: app
47 - name: Upload results
48 uses: actions/upload-artifact@v4
49 with:
50 name: src
51 path: ./
52
53 unit-test:
54 name: "🧩🧪 Run unit tests"
55 runs-on: ubuntu-latest
56 needs: setup-env
57 permissions:
58 contents: write
59 pull-requests: write
60 steps:
61 - uses: actions/checkout@v4
62 with:
63 sparse-checkout: |
64 app
65 health_data_store
66 - name: Download src directory
67 uses: actions/download-artifact@v4
68 with:
69 name: src
70 - name: Setup Flutter
71 uses: subosito/flutter-action@v2
72 with:
73 channel: stable
74 cache: true
75 - name: Disable analytics
76 run: flutter config --no-analytics --suppress-analytics
77 - name: Run tests ignoring goldens
78 run: flutter test --coverage --update-goldens
79 working-directory: app
80
81# Disabled: Integration tests are disabled as emulator setup fails on
82# GH-actions. Actions images no longer provide enough disk space to create
83# the userdata partition.
84#
85# integration-test:
86# name: "🛠️🧪 Run integration tests"
87# runs-on: ubuntu-latest
88#
89# steps:
90# - name: Checkout code
91# uses: actions/checkout@v4
92# with:
93# # ensures there are no unexpected directories needed
94# sparse-checkout: |
95# app
96# health_data_store
97# - name: Enable KVM group perms
98# # see: https://github.com/actions/runner-images/discussions/7191
99# run: |
100# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
101# sudo udevadm control --reload-rules
102# sudo udevadm trigger --name-match=kvm
103# - name: Setup Java
104# uses: actions/setup-java@v3
105# with:
106# distribution: 'zulu'
107# java-version: ${{ env.JAVA_VERSION }}
108#
109# - name: Download Android emulator image
110# run: |
111# export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
112# echo "y" | $ANDROID_TOOLS/sdkmanager --install "${{ env.EMULATOR_VERSION }}"
113# echo "no" | $ANDROID_TOOLS/avdmanager create avd --force --name emu -k '${{ env.EMULATOR_VERSION }}'
114# echo "Android emulator installed"
115# $ANDROID_HOME/emulator/emulator -list-avds
116# - name: Setup dart
117# uses: dart-lang/setup-dart@v1
118# with:
119# sdk: ${{ env.DART_SDK }}
120# - name: Generate code
121# run: dart run build_runner build
122# working-directory: health_data_store
123# - name: Setup Flutter
124# uses: subosito/flutter-action@v2
125# with:
126# channel: ${{ env.FLUTTER_CHANNEL }}
127# - name: Start Android emulator
128# timeout-minutes: 10
129# run: |
130# export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
131# echo "Starting emulator"
132# $ANDROID_TOOLS/sdkmanager "platform-tools" "${{ env.EMULATOR_VERSION }}"
133# nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window &
134# $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
135# $ANDROID_HOME/platform-tools/adb devices
136# echo "Android emulator started"
137# - name: Run integration tests
138# run: flutter test integration_test --flavor github
139# working-directory: app
140
141 build-android:
142 name: "🛠️ Build Android"
143 strategy:
144 matrix:
145 java-version:
146 - 17
147 - 21
148 build:
149 - debug
150 - release
151
152 flavor:
153 - github
154 - fdroid
155 runs-on: ubuntu-latest
156 needs: setup-env
157 steps:
158 - name: Download src directory
159 uses: actions/download-artifact@v4
160 with:
161 name: src
162 - name: Setup Flutter
163 uses: subosito/flutter-action@v2
164 with:
165 channel: stable
166 cache: true
167 - name: Disable analytics
168 run: flutter config --no-analytics --suppress-analytics
169 - name: Setup java
170 uses: actions/setup-java@v2
171 with:
172 java-version: "17"
173 distribution: "temurin"
174 cache: 'gradle'
175 - name: Build apk
176 run: flutter build apk --flavor ${{ matrix.flavor }} --${{ matrix.build }}
177 working-directory: app
178 - name: Upload apks
179 uses: actions/upload-artifact@v4
180 with:
181 name: app-${{ matrix.build }}-java${{ matrix.java-version }}-flutter
182 path: ./app/build/app/outputs/flutter-apk/*.apk
183 build-linux:
184 name: "🖥️ Build Desktop (linux)"
185 strategy:
186 build:
187 - debug
188 - release
189
190 runs-on: ubuntu-latest
191 needs: setup-env
192 steps:
193 - name: Download src directory
194 uses: actions/download-artifact@v4
195 with:
196 name: src
197 - name: Setup Flutter
198 uses: subosito/flutter-action@v2
199 with:
200 channel: stable
201 cache: true
202 - name: Disable analytics
203 run: flutter config --no-analytics --suppress-analytics
204 - name: Build linux
205 run: flutter build linux --${{ matrix.build }}
206 working-directory: app
207 - name: Upload program
208 uses: actions/upload-artifact@v4
209 with:
210 name: linux-${{ matrix.build }}-flutter${{ matrix.branch }}-
211 path: ./app/build/linux/x64/release/bundle/blood_pressure_app/
212