-
Notifications
You must be signed in to change notification settings - Fork 12
237 lines (219 loc) · 8.26 KB
/
dev-workflow.yaml
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
name: Development workflow
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '.gitignore'
- '.metadata'
- '*.md'
- 'android/fastlane/**'
- 'ios/fastlane/**'
- '.github/**'
- '.githooks/**'
- '!.github/workflows/dev-workflow.yaml'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
APP_NAME: 'notre_dame'
jobs:
##############################################################
# Testing
##############################################################
testing:
name: Tests and checks
runs-on: ubuntu-latest
outputs:
coverage: ${{ steps.coverage.outputs.percentage }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PTA }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.x'
channel: 'stable'
cache: true
- run: flutter doctor
- name: Decrypt SignETS certificate and Google Services files
run: |
chmod +x ./scripts/decrypt.sh
./scripts/decrypt.sh
env:
ENCRYPTED_SIGNETS_API_CERT_PASSWORD: ${{ secrets.ENCRYPTED_SIGNETS_API_CERT_PASSWORD }}
ENCRYPTED_GOOGLE_SERVICE_PASSWORD: ${{ secrets.ENCRYPTED_GOOGLE_SERVICE_PASSWORD }}
# Get flutter dependencies.
- run: |
flutter pub get
dart run build_runner build --delete-conflicting-outputs
# Check the format of the code and commit the formatted files.
- name: Format files in lib and test directories
run: dart format lib test
- name: Commit formatted files
id: commit_formatted
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "*.dart"
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_message: "[BOT] Applying format."
add_options: '-u'
# Fail workflow, because new commit will execute workflow
- if: ${{ steps.commit_formatted.outputs.changes_detected == 'true' }}
name: Fail workflow if linting commit
run: |
echo 'Linting applied, running bot commit workflow'
exit 1
# Check if the code has any errors/warnings
- name: Analyze code
run: flutter analyze
# Run the tests with --update-goldens.
- name: Run tests
run: flutter test --coverage --update-goldens
# Commit and push the goldens files updated.
- name: Commit golden files
id: commit_golden
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: test/*
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_message: '[BOT] Update golden files'
# Fail workflow, because new commit will execute workflow
- if: ${{ steps.commit_golden.outputs.changes_detected == 'true' }}
name: Fail workflow if golden commit
run: |
echo 'Golden files changes commit, running bot commit workflow'
exit 1
- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: lcov.info
path: ${{ github.workspace }}/coverage/lcov.info
- name: Get code coverage
id: coverage
run: |
chmod +x ./scripts/determine_code_coverage.sh
export COV="$(./scripts/determine_code_coverage.sh coverage/lcov.info)"
echo "Coverage detected is: $COV"
echo "percentage=$COV" >> $GITHUB_OUTPUT
coverage:
name: Update coverage
needs:
- testing
runs-on: ubuntu-latest
steps:
- name: Download coverage file
uses: actions/download-artifact@v4
with:
name: lcov.info
# Comment coverage report
- name: Comment the coverage of the PR
uses: romeovs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./lcov.info
##############################################################
# Build
##############################################################
build:
name: Create ${{ matrix.target }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [ iOS, Android ]
include:
- os: macos-latest
target: iOS
build_target: ios
build_args: --no-codesign
build_path: build/ios/iphoneos
asset_extension: zip
asset_content_type: application/zip
- os: ubuntu-latest
target: Android
build_target: apk
build_args: ''
build_path: build/app/outputs/apk/release
asset_extension: apk
asset_content_type: application/zip
# Disable fail-fast as we want results from all even if one fails.
fail-fast: false
needs:
- testing
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.x'
channel: 'stable'
cache: true
- name: Install Android dependencies
if: matrix.target == 'Android'
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- run: flutter doctor -v
- name: Install iOS dependencies
if: matrix.target == 'iOS'
run: |
flutter pub get
dart run build_runner build --delete-conflicting-outputs
cd ios
pod update
flutter clean
- name: Commit pod updates
if: matrix.target == 'iOS'
id: commit_pod_versions
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "*.lock"
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_message: "[BOT] Applying pod update."
add_options: '-u'
# Fail workflow, because new commit will execute workflow
- if: ${{ matrix.target == 'iOS' && steps.commit_pod_versions.outputs.changes_detected == 'true' }}
name: Fail workflow if pod version change
run: |
echo 'Pod update applied, running bot commit workflow'
exit 1
# Get dependencies and decrypt needed files.
- run: |
flutter pub get
dart run build_runner build --delete-conflicting-outputs
- name: Decrypt SignETS certificate and Google Services files
run: |
chmod +x ./scripts/decrypt.sh
./scripts/decrypt.sh
env:
ENCRYPTED_SIGNETS_API_CERT_PASSWORD: ${{ secrets.ENCRYPTED_SIGNETS_API_CERT_PASSWORD }}
ENCRYPTED_GOOGLE_SERVICE_PASSWORD: ${{ secrets.ENCRYPTED_GOOGLE_SERVICE_PASSWORD }}
ENCRYPTED_ETSMOBILE_KEYSTORE_PASSWORD: ${{ secrets.ENCRYPTED_ETSMOBILE_KEYSTORE_PASSWORD }}
ENCRYPTED_KEYSTORE_PROPERTIES_PASSWORD: ${{ secrets.ENCRYPTED_KEYSTORE_PROPERTIES_PASSWORD }}
# Build the application.
- name: Build the application
run: flutter build -v ${{ matrix.build_target }} ${{ matrix.build_args }} --release --dart-define=GH_API_TOKEN=${{ secrets.GH_API_TOKEN }}
- name: Rename Android build
if: matrix.target == 'Android'
run: mv app-release.${{ matrix.asset_extension }} ${{ github.workspace }}/${{ env.APP_NAME }}_${{ matrix.target }}.${{ matrix.asset_extension }}
working-directory: ${{ matrix.build_path }}
- name: Compress iOS build
if: matrix.target == 'iOS'
run: |
mv Runner.app ${{ env.APP_NAME }}.app
ditto -c -k --sequesterRsrc --keepParent ${{ env.APP_NAME }}.app ${{ github.workspace }}/${{ env.APP_NAME }}_${{ matrix.target }}.${{ matrix.asset_extension }}
working-directory: ${{ matrix.build_path }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ${{ github.workspace }}/${{ env.APP_NAME }}_${{ matrix.target }}.${{ matrix.asset_extension }}