Skip to content

Commit 8c274d4

Browse files
yeung-wahJordan-Nelson
authored andcommitted
chore: add canary workflow (#1656)
* chore: add canary workflow * Removing IPHONEOS_DEPLOYMENT_TARGET from build_settings
1 parent 9086650 commit 8c274d4

File tree

5 files changed

+456
-21
lines changed

5 files changed

+456
-21
lines changed

.circleci/config.yml

Lines changed: 225 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,186 @@
11
version: 2.1
22

3+
orbs:
4+
# Using inline orb for now
5+
getting-started-smoke-test:
6+
orbs:
7+
macos: circleci/[email protected]
8+
android: circleci/[email protected]
9+
flutter-orb: circleci/[email protected]
10+
11+
executors:
12+
mac-executor:
13+
macos:
14+
xcode: 13.2.1
15+
resource_class: large
16+
17+
android-executor:
18+
machine:
19+
image: android:202102-01
20+
resource_class: large
21+
22+
commands:
23+
run-with-retry:
24+
description: Run command with retry
25+
parameters:
26+
label:
27+
description: Display name
28+
type: string
29+
command:
30+
description: Command to run
31+
type: string
32+
retry-count:
33+
description: Number of retry
34+
type: integer
35+
default: 3
36+
sleep:
37+
description: Wait duration until next retry
38+
type: integer
39+
default: 5
40+
no_output_timeout:
41+
description: Elapsed time the command can run without output
42+
type: string
43+
default: 10m
44+
steps:
45+
- run:
46+
name: << parameters.label >>
47+
command: |
48+
retry() {
49+
MAX_RETRY=<< parameters.retry-count >>
50+
n=0
51+
until [ $n -ge $MAX_RETRY ]
52+
do
53+
<< parameters.command >> && break
54+
n=$[$n+1]
55+
sleep << parameters.sleep >>
56+
done
57+
if [ $n -ge $MAX_RETRY ]; then
58+
echo "failed: ${@}" >&2
59+
exit 1
60+
fi
61+
}
62+
retry
63+
no_output_timeout: << parameters.no_output_timeout >>
64+
install-flutter:
65+
description: Install Flutter and set up paths.
66+
parameters:
67+
flutter_branch:
68+
description: Flutter branch or version tag.
69+
type: string
70+
default: stable
71+
steps:
72+
- run:
73+
name: Set up Flutter
74+
command: |
75+
echo 'export FLUTTER_HOME=${HOME}/sdks/flutter' >> $BASH_ENV
76+
echo 'export FLUTTER_BRANCH=<< parameters.flutter_branch >>' >> $BASH_ENV
77+
echo 'export FLUTTER_ROOT=${FLUTTER_HOME}' >> $BASH_ENV
78+
echo 'export PATH=${PATH}:${FLUTTER_HOME}/bin:${FLUTTER_HOME}/bin/cache/dart-sdk/bin:${HOME}/.pub-cache/bin:${FLUTTER_HOME}/.pub-cache/bin' >> $BASH_ENV
79+
source $BASH_ENV
80+
git clone --branch ${FLUTTER_BRANCH} https://github.com/flutter/flutter.git ${FLUTTER_HOME}
81+
(yes || true) | flutter doctor --android-licenses && flutter doctor
82+
flutter precache
83+
setup-amplify-flutter-project:
84+
description: Setup Amplify project
85+
steps:
86+
- run-with-retry:
87+
label: Setting up dependences
88+
command: flutter pub add amplify_flutter && flutter pub add amplify_datastore && flutter pub add amplify_storage_s3 && flutter pub add amplify_analytics_pinpoint && flutter pub add amplify_auth_cognito && flutter pub add amplify_api
89+
no_output_timeout: 5m
90+
- run:
91+
name: Adding integration_test package
92+
command: 'sed -i -e "s/dev_dependencies:/dev_dependencies:\n integration_test:\n sdk: flutter/" ./pubspec.yaml && cat ./pubspec.yaml'
93+
- run:
94+
name: Update outdated dependences
95+
command: flutter pub upgrade --major-versions
96+
- run:
97+
name: Adding amplifyconfig file
98+
command: mv canaries/dummy_amplifyconfiguration.dart canaries/amplifyconfiguration.dart && cp canaries/amplifyconfiguration.dart amplified_todo/lib
99+
working_directory: ~/flutter-canaries/
100+
- run:
101+
name: Adding test code
102+
command: cp canaries/main.dart amplified_todo/lib && cp -r canaries/integration_test amplified_todo/integration_test && cp -r canaries/models amplified_todo/lib/models
103+
working_directory: ~/flutter-canaries/
104+
105+
jobs:
106+
flutter-android:
107+
parameters:
108+
flutter-version:
109+
type: string
110+
executor:
111+
name: android/android-machine
112+
resource-class: large
113+
tag: 2021.10.1
114+
working_directory: ~/flutter-canaries/amplified_todo
115+
steps:
116+
- checkout:
117+
path: ~/flutter-canaries
118+
- install-flutter:
119+
flutter_branch: << parameters.flutter-version >>
120+
- run:
121+
name: Setting up project
122+
command: cd ../ && flutter create amplified_todo
123+
- run:
124+
name: Update Android version
125+
command: sed -i -e "s/minSdkVersion .*/minSdkVersion 21/" ./android/app/build.gradle && cat ./android/app/build.gradle
126+
- setup-amplify-flutter-project
127+
- flutter-orb/install_android_gradle:
128+
app-dir: ./
129+
- android/create-avd:
130+
avd-name: flutter
131+
install: true
132+
system-image: system-images;android-29;default;x86
133+
- android/start-emulator:
134+
avd-name: flutter
135+
post-emulator-launch-assemble-command: ls -lrt
136+
restore-gradle-cache-find-args: ./android -name 'build.gradle'
137+
- run-with-retry:
138+
label: Run Flutter Build
139+
command: flutter build apk --debug
140+
no_output_timeout: 20m
141+
- run-with-retry:
142+
label: Run Flutter Tests
143+
command: flutter test integration_test
144+
no_output_timeout: 1h
145+
retry-count: 5
146+
147+
flutter-ios:
148+
parameters:
149+
flutter-version:
150+
type: string
151+
executor: mac-executor
152+
working_directory: ~/flutter-canaries/amplified_todo
153+
steps:
154+
- checkout:
155+
path: ~/flutter-canaries
156+
- run:
157+
name: Install gnu-sed
158+
command: brew install gnu-sed
159+
- macos/preboot-simulator:
160+
device: iPhone 13
161+
version: "15.2"
162+
- install-flutter:
163+
flutter_branch: << parameters.flutter-version >>
164+
- run:
165+
name: Setting up project
166+
command: cd ../ && flutter create amplified_todo
167+
- setup-amplify-flutter-project
168+
- run:
169+
name: Removing IPHONEOS_DEPLOYMENT_TARGET from build_settings
170+
command: cd ios && gsed -i "/flutter_additional_ios_build_settings(target)/ a \ target.build_configurations.each do |config|\n config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'\n end" Podfile
171+
- run:
172+
name: Update ios version
173+
command: sed -i -e "s/# platform .*/platform :ios, '13.0'/" ./ios/Podfile && cat ./ios/Podfile
174+
- run-with-retry:
175+
label: Run Flutter Build
176+
command: flutter build ios --debug --simulator
177+
no_output_timeout: 20m
178+
- run-with-retry:
179+
label: Run Flutter Tests
180+
command: flutter test integration_test
181+
no_output_timeout: 20m
182+
183+
3184
executors:
4185
docker-executor:
5186
docker:
@@ -50,6 +231,7 @@ commands:
50231
name: Install tuneup
51232
command: |
52233
flutter pub global activate tuneup
234+
53235
jobs:
54236
format_flutter:
55237
executor: docker-executor
@@ -198,10 +380,16 @@ releasable_branches: &releasable_branches
198380

199381
workflows:
200382
test_deploy:
383+
# Tells CircleCI to skip this workflow when the pipeline is triggered by the scheduled source,
384+
# i.e. when the canaries workflow executes
385+
# https://circleci.com/docs/2.0/scheduled-pipelines/#workflows-filtering
386+
when:
387+
not:
388+
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
201389
jobs:
202390
- format_flutter
203391
- analyze_flutter
204-
# TODO: Enable pub_analysis after https://github.com/dart-lang/pana/issues/1020 is
392+
# TODO: Enable pub_analysis after https://github.com/dart-lang/pana/issues/1020 is
205393
# resolved or these are updated to run against unpub
206394
# - pub_analysis:
207395
# matrix:
@@ -222,36 +410,52 @@ workflows:
222410
parameters:
223411
plugin:
224412
[
225-
"amplify_analytics_pinpoint",
226-
"amplify_api",
227-
"amplify_auth_cognito",
228-
"amplify_authenticator",
229-
"amplify_core",
230-
"amplify_datastore",
231-
"amplify_datastore_plugin_interface",
232-
"amplify_flutter",
233-
"amplify_storage_s3"
413+
"amplify_analytics_pinpoint",
414+
"amplify_api",
415+
"amplify_auth_cognito",
416+
"amplify_authenticator",
417+
"amplify_core",
418+
"amplify_datastore",
419+
"amplify_datastore_plugin_interface",
420+
"amplify_flutter",
421+
"amplify_storage_s3"
234422
]
235423
- unit_test_android:
236424
matrix:
237425
parameters:
238426
plugin:
239427
[
240-
"amplify_analytics_pinpoint",
241-
"amplify_api",
242-
"amplify_auth_cognito",
243-
"amplify_core",
244-
"amplify_datastore",
245-
"amplify_flutter",
428+
"amplify_analytics_pinpoint",
429+
"amplify_api",
430+
"amplify_auth_cognito",
431+
"amplify_core",
432+
"amplify_datastore",
433+
"amplify_flutter",
246434
]
247435
- unit_test_ios:
248436
matrix:
249437
parameters:
250438
plugin:
251439
[
252-
"amplify_analytics_pinpoint",
253-
"amplify_api",
254-
"amplify_auth_cognito",
255-
"amplify_datastore",
256-
"amplify_flutter",
440+
"amplify_analytics_pinpoint",
441+
"amplify_api",
442+
"amplify_auth_cognito",
443+
"amplify_datastore",
444+
"amplify_flutter",
257445
]
446+
# Scheduled smoke test workflow
447+
# Jobs are pulled from the getting-started-smoke-test inline orb defined above
448+
canaries:
449+
when:
450+
and:
451+
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
452+
- equal: [ "Canaries", << pipeline.schedule.name >> ]
453+
jobs:
454+
- getting-started-smoke-test/flutter-android:
455+
matrix:
456+
parameters:
457+
flutter-version: [ "stable", "beta" ]
458+
- getting-started-smoke-test/flutter-ios:
459+
matrix:
460+
parameters:
461+
flutter-version: [ "stable", "beta" ]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const amplifyconfig = ''' {
2+
"UserAgent": "aws-amplify-cli/2.0",
3+
"Version": "1.0"
4+
}''';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:integration_test/integration_test.dart';
3+
4+
import 'package:amplified_todo/main.dart' as app;
5+
6+
void main() {
7+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
8+
9+
group('end-to-end test', () {
10+
testWidgets('tap on the floating action button, verify counter',
11+
(tester) async {
12+
app.main();
13+
await tester.pumpAndSettle();
14+
15+
// Verify the counter starts at 0.
16+
expect(find.text('0'), findsOneWidget);
17+
18+
// Finds the floating action button to tap on.
19+
final Finder fab = find.byTooltip('Increment');
20+
21+
// Emulate a tap on the floating action button.
22+
await tester.tap(fab);
23+
24+
// Trigger a frame.
25+
await tester.pumpAndSettle();
26+
27+
// Verify the counter increments by 1.
28+
expect(find.text('1'), findsOneWidget);
29+
});
30+
});
31+
}

0 commit comments

Comments
 (0)