-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmelos.yaml
367 lines (298 loc) · 10.8 KB
/
melos.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
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
name: unself
repository: https://github.com/thipokch/unself
packages:
- "packages/**"
ignore:
- "packages/un_tool/templates/**"
command:
bootstrap:
usePubspecOverrides: true
runPubGetInParallel: true
# It seems so that running "pub get" in parallel cause race condition.
# See: https://github.com/dart-lang/pub/issues/3404).
scripts:
#
# Melos Lifecycle
#
postclean: |
melos exec -c 6 -- "flutter clean"
echo "Cleaning secrets repo..."
rm -rvf ./.secrets
#
# Setup
#
setup:
description: Setup for local development. See 'setup:secrets' for variables.
run: |
melos clean && \
melos bootstrap && \
melos setup:mason && \
melos setup:secrets && \
melos setup:hygiene
setup:ci:
description: Setup for CI build. See 'setup:secrets' for variables.
run: |
melos clean && \
melos bootstrap && \
melos setup:secrets && \
git config --global user.email "noreply@github.com" && \
git config --global user.name "GitHub"
setup:hygiene:
description: Setup scripts to run on git hook events.
run: |
chmod -R +x .githook/ && \
git config core.hooksPath .githook/
setup:secrets:
description: |
Clone secrets repo.
Decode and decrypt google services config in cloned secrets repo.
For local development, use .env to set variables:
SECRETS_GITHUB_TOKEN - Personal acccess token.
SECRETS_GITHUB_PATH - Path of Github repo.
SECRETS_PASSWORD - Encryption passphrase.
run: |
[ ! -f .env ] || export $(grep -v '^#' .env | xargs) && \
echo "Environment variables from .env exported..." && \
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
export SECRETS_DIR=$MELOS_ROOT_PATH/.secrets && \
echo "Using '$SECRETS_DIR'..." && \
echo "Cleaning previous secrets repo..." && \
rm -rf $SECRETS_DIR && \
echo "Using '$SECRETS_GITHUB_PATH'..." && \
git clone https://$SECRETS_GITHUB_TOKEN@github.com/$SECRETS_GITHUB_PATH $SECRETS_DIR && \
for f in $(find $SECRETS_DIR -name '*.enc'); do
echo "Decrypting ${f%.enc}..."
openssl aes-256-cbc -md md5 -d -a -v -k $SECRETS_PASSWORD -in $f -out ${f%.enc}
rm -rfv $f | xargs echo "Decrypted and removed: $1"
done && \
export BUILD_ENV=dev && \
melos setup:build && \
echo "Formatting and Copying environment configurations..." && \
dart format $SECRETS_DIR/flutter/ && \
cp -v -r "$SECRETS_DIR/flutter/"* "$APP_DIR/lib"
setup:mason:
description: Setup mason
# Workaround: checked_yaml 2.0.2 is not used for compiling pre-gen scripts.
run: |
dart pub global activate mason_cli && \
dart pub cache add checked_yaml -v 2.0.1 && \
mason get
setup:build:
description: Setup for building given environment.
For local development, use .env to set variables
BUILD_ENV - build environment (dev, stg, prd)
run: |
melos setup:doc && \
export SECRETS_DIR=$MELOS_ROOT_PATH/.secrets && \
echo "Copying Google service configurations for $BUILD_ENV environment..." && \
cp -v -r "$SECRETS_DIR/android/$BUILD_ENV/"* "$APP_DIR/android/" && \
cp -v -r "$SECRETS_DIR/apple/$BUILD_ENV/"* "$APP_DIR/ios/" && \
cp -v -r "$SECRETS_DIR/apple/$BUILD_ENV/"* "$APP_DIR/macos/"
# Web is configured from RudderStack
# cp -v -r "$SECRETS_DIR/darwin/$BUILD_ENV/"* "$APP_DIR/macos/" && \
# cp -v -r "$SECRETS_DIR/web/$BUILD_ENV/"* "$APP_DIR/web/"
setup:upgrade:
run: |
melos exec -c 1 -- \
flutter pub upgrade --major-versions --dry-run
setup:outdated:
run: |
melos exec -c 1 -- \
flutter pub outdated
setup:canvaskit:
run: |
dart ./packages/script/bin/version_canvaskit.dart
setup:doc:
run: |
cd ./docs && \
yarn install
#
# Hygiene
#
hygiene:
description: Run all targets generally expected for local quality check. For visibility, CI uses individual steps.
run: |
melos setup && \
melos build:generate && \
melos hygiene:format && \
melos hygiene:analyze && \
melos test:fast
# melos hygiene:metrics && \ # Stack overflow
hygiene:commit:
description: Run local quality check before commit.
run: |
melos hygiene:format && \
melos hygiene:analyze && \
melos test:fast
# melos hygiene:metrics && \ # Stack overflow
hygiene:clean:
# melos hygiene:clean -- --exclude=.env
description: Clean things very deeply, can be used to establish "pristine checkout" status.
run: git clean -x -d -f -q
hygiene:metrics:
description: |
Run `dart_code_metrics` in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
run: |
melos exec -c 1 --ignore="*test*" --depends-on="dart_code_metrics" -- \
flutter pub run dart_code_metrics:metrics analyze lib
hygiene:deps:
description: |
Run `dependency_validator` in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
run: |
melos exec -c 1 --ignore="*test*" --depends-on="dependency_validator" -- \
flutter pub run dependency_validator
hygiene:analyze:
# We are setting the concurrency to 1 because a higher concurrency can crash
# the analysis server on low performance machines (like GitHub Actions).
description: |
Run `flutter analyze` in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
run: |
melos exec -c 1 --scope="un*" --ignore="un_tool" -- \
flutter analyze . --fatal-infos
hygiene:format:
description: |
Run `dart format` in all packages.
- Note: Exits with non-zero exit code if formatting is needed.
run: |
melos exec -c 1 --ignore="un_tool" -- \
dart format --output=none --set-exit-if-changed .
hygiene:format:fix:
description: |
Fix `dart format` in all packages.
run: |
melos exec -c 1 --ignore="un_tool" -- \
dart format . &&
flutter pub run import_sorter:main
#
# Build
#
build:num:
description: |
Bump build number
For local development, use .env to set variables
BUILD_NUM - build number
run: dart ./packages/un_tool/bin/version_build.dart
build:generate:
description: Run all code generators.
run: |
melos build:runner && \
melos build:splash
build:watch:
description: Run all code generators.
run: |
melos exec --depends-on="build_runner" -- \
flutter pub run build_runner watch --delete-conflicting-outputs
build:runner:
run: |
melos exec --depends-on="build_runner" -c 1 -- \
flutter pub run build_runner build --delete-conflicting-outputs
build:runner:perf:
run: |
flutter pub run build_runner clean && \
flutter pub run build_runner serve .\build\web --track-performance --delete-conflicting-outputs
build:splash:
run: |
melos exec --depends-on="flutter_native_splash" -- \
flutter pub run flutter_native_splash:create
build:doc:
description: Generate documentation for the package.
run: |
melos exec -c 5 --scope="un*" -- \
dart doc . --output=$MELOS_ROOT_PATH/docs/developer/api/ && \
dart ./packages/un_tool/bin/docusaurify.dart
# iOS
build:ios:
description: |
Build ios for given environment. Uses fastlane to build and codesign.
For local development, use .env to set variables
BUILD_ENV - build environment (dev, stg, prd)
run: |
[ ! -f .env ] || export $(grep -v '^#' .env | xargs) && \
echo "Environment variables from .env exported..."
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
export MATCH_GIT_URL=$MELOS_ROOT_PATH/.secrets && \
export MATCH_PASSWORD=$SECRETS_PASSWORD && \
melos setup:build && \
cd $APP_DIR/ios && \
bundle exec fastlane build_$BUILD_ENV
build:ios:pre:
description: Xcode Pre-build command. Requires ENVIRONMENT
run: |
export BUILD_ENV=$FLAVOR && \
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
$FLUTTER_ROOT/bin/dart pub global run melos setup:build
build:ios:dev:
description: Builds ios for development.
run: export BUILD_ENV=dev && melos build:ios
build:ios:stg:
description: Builds ios for development.
run: export BUILD_ENV=stg && melos build:ios
build:ios:prd:
description: Builds ios for production.
run: export BUILD_ENV=prd && melos build:ios
# android
build:and:
description: Build android for given environment.
For local development, use .env to set variables
BUILD_ENV - build environment (dev, stg, prd)
run: |
[ ! -f .env ] || export $(grep -v '^#' .env | xargs) && \
echo "Environment variables from .env exported..."
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
melos setup:build && \
cd $APP_DIR && \
if [ $BUILD_ENV == "dev" ]
then
flutter build apk --debug --flavor=$BUILD_ENV --target=lib/$BUILD_ENV.dart
else
flutter build apk --release --flavor=$BUILD_ENV --target=lib/$BUILD_ENV.dart
fi
build:and:dev:
description: Builds android for development.
run: export BUILD_ENV=dev && melos build:and
build:and:stg:
description: Builds android for staging.
run: export BUILD_ENV=stg && melos build:and
build:and:prd:
description: Builds android for production.
run: export BUILD_ENV=prd && melos build:and
# macos - Flavors are not supported yet
build:mac:pre:
description: Xcode Pre-build command. Requires ENVIRONMENT
run: |
export BUILD_ENV=$FLAVOR && \
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
$FLUTTER_ROOT/bin/dart pub global run melos setup:build
# web
build:web:
description: Build web for given environment.
For local development, use .env to set variables
BUILD_ENV - build environment (dev, stg, prd)
run: |
[ ! -f .env ] || export $(grep -v '^#' .env | xargs) && \
echo "Environment variables from .env exported..."
export APP_DIR=$MELOS_ROOT_PATH/packages/un_app && \
melos setup:build && \
cd $APP_DIR && \
flutter build web --verbose --release --target=lib/$BUILD_ENV.dart
# melos setup:canvaskit && \
build:web:dev:
description: Builds web for development.
run: export BUILD_ENV=dev && melos build:web
build:web:stg:
description: Builds web for staging.
run: export BUILD_ENV=stg && melos build:web
build:web:prd:
description: Builds web for production.
run: export BUILD_ENV=prd && melos build:web
#
# Test
#
test:fast:
description: Flutter tests (fail-fast)
run: |
melos exec -c 1 --dir-exists=test --fail-fast -- \
"flutter test"