-
Notifications
You must be signed in to change notification settings - Fork 14
191 lines (183 loc) · 6.57 KB
/
app-CI.yml
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
name: '📱 Application'
on:
push:
branches:
- 'main'
paths:
- "app/**"
- "health_data_store/**"
- ".github/workflows/app-CI.yml"
workflow_dispatch:
env:
FLUTTER_CHANNEL: 'beta'
DART_SDK: 'beta'
JAVA_VERSION: '17'
EMULATOR_VERSION: 'system-images;android-34;aosp_atd;x86_64'
jobs:
unit-test:
name: "🧩🧪 Run unit tests"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ensures there are no unexpected directories needed
sparse-checkout: |
app
health_data_store
- name: Cache generated health data store
id: cache-generated
uses: actions/cache@v4
with:
path: health_data_store/lib
key: builder-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
- name: Setup dart
if: steps.cache-generated.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ env.DART_SDK }}
- name: Generate code
if: steps.cache-generated.outputs.cache-hit != 'true'
run: dart run build_runner build
working-directory: health_data_store
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Disable analytics
run: flutter config --no-analytics --suppress-analytics
- name: Generate mock code
run: |
flutter pub get
flutter pub run build_runner build
working-directory: app
- name: Run tests
run: flutter test --coverage
working-directory: app
- name: Update goldens
id: gold-upd
if: failure()
run: flutter test --update-goldens --fail-fast
working-directory: app
- name: PR golden changes
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-of-failure-with-conditions
if: ${{ failure() && steps.gold-upd.conclusion == 'success' }}
run: |
git config user.name "GitHub Action (update goldens)"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B action-update-goldens
export STATUS=$(git status)
git commit -am "Update goldens"
git push --set-upstream origin action-update-goldens
gh pr create \
--base main \
--head action-update-goldens \
--title "Update goldens" \
--body "$STATUS"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disabled: Integration tests are disabled as emulator setup fails on
# GH-actions. Actions images no longer provide enough disk space to create
# the userdata partition.
#
# integration-test:
# name: "🛠️🧪 Run integration tests"
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# # ensures there are no unexpected directories needed
# sparse-checkout: |
# app
# health_data_store
# - name: Enable KVM group perms
# # see: https://github.com/actions/runner-images/discussions/7191
# run: |
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger --name-match=kvm
# - name: Setup Java
# uses: actions/setup-java@v3
# with:
# distribution: 'zulu'
# java-version: ${{ env.JAVA_VERSION }}
#
# - name: Download Android emulator image
# run: |
# export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
# echo "y" | $ANDROID_TOOLS/sdkmanager --install "${{ env.EMULATOR_VERSION }}"
# echo "no" | $ANDROID_TOOLS/avdmanager create avd --force --name emu -k '${{ env.EMULATOR_VERSION }}'
# echo "Android emulator installed"
# $ANDROID_HOME/emulator/emulator -list-avds
# - name: Setup dart
# uses: dart-lang/setup-dart@v1
# with:
# sdk: ${{ env.DART_SDK }}
# - name: Generate code
# run: dart run build_runner build
# working-directory: health_data_store
# - name: Setup Flutter
# uses: subosito/flutter-action@v2
# with:
# channel: ${{ env.FLUTTER_CHANNEL }}
# - name: Start Android emulator
# timeout-minutes: 10
# run: |
# export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
# echo "Starting emulator"
# $ANDROID_TOOLS/sdkmanager "platform-tools" "${{ env.EMULATOR_VERSION }}"
# nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window &
# $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'
# $ANDROID_HOME/platform-tools/adb devices
# echo "Android emulator started"
# - name: Run integration tests
# run: flutter test integration_test --flavor github
# working-directory: app
build-android:
name: "🛠️ Build Android"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ensures there are no unexpected directories needed
sparse-checkout: |
app
health_data_store
- name: Cache generated health data store
id: cache-generated
uses: actions/cache@v4
with:
path: health_data_store/lib
key: builder-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }}
- name: Setup dart
if: steps.cache-generated.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ env.DART_SDK }}
- name: Generate code
if: steps.cache-generated.outputs.cache-hit != 'true'
run: dart run build_runner build
working-directory: health_data_store
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Disable analytics
run: flutter config --no-analytics --suppress-analytics
- name: Setup java
uses: actions/setup-java@v2
with:
java-version: "17"
distribution: "temurin"
cache: 'gradle'
- name: Build apk
run: flutter build apk --flavor github --debug
working-directory: app