-
Notifications
You must be signed in to change notification settings - Fork 0
/
codemagic.yaml
125 lines (124 loc) · 3.23 KB
/
codemagic.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
# Has a separate flows for develop branch (automatic builds),
# Merge Request (automatic builds) and main branch Release builds (manual builds).
definitions:
artifacts: &androidArtifacts # Section def
- emulator.log
- app/build/reports
- app/build/outputs/androidTest-results
- app/build/outputs/logs
- app/build/outputs/**/*.apk
- app/build/outputs/**/*.aab
- app/build/outputs/**/mapping.txt
debug-emails: &debugEmails
release-emails: &releaseEmails
scripts:
# Local setup
- &stepLocalSetup
name: Set up local properties and permissons
script: |
chmod +x gradlew
echo "sdk.dir=$ANDROID_SDK_ROOT" > "$FCI_BUILD_DIR/local.properties"
# Run checkCode
- &stepCheckCode
name: Check code style and formatting
script: ./gradlew checkCode
# Build DEBUG
- &stepBuildDebug
name: Build Android
script: ./gradlew clean buildAllDebug
# Build RELEASE
- &stepBuildRelease
name: Build Android
script: ./gradlew clean buildAllRelease
# Start emulator
- &stepStartEmulator
name: Launch emulator
script: |
cd $ANDROID_HOME/tools
emulator -avd emulator &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
# Stop emulator
- &stepStopEmulator
name: Stop emulator
script: |
cd $ANDROID_HOME/tools
adb emu kill
# Run tests
- &stepRunTests
name: Test Android
script: |
./gradlew connectedAndroidTest
result=$?
adb logcat -d > emulator.log
if [ $result -eq 0 ]
then
echo "Tests executed successfully"
else
echo "Tests failed"
exit 1
fi
# Flows
workflows:
play-store-release-builds:
name: Play Store Release builds
instance_type: linux_x2
scripts:
- name: Check 'main' branch
script: if [ "$FCI_BRANCH" != "main" ]; then exit 1; fi
- *stepLocalSetup
- *stepCheckCode
- *stepStartEmulator
- *stepRunTests
- *stepStopEmulator
- *stepBuildRelease
publishing:
email:
recipients: *releaseEmails
artifacts: *androidArtifacts
develop-builds:
name: Dev builds
instance_type: linux_x2
triggering:
events:
- push
- pull_request
branch_patterns:
- pattern: 'develop'
include: true
source: true
scripts:
- *stepLocalSetup
- *stepCheckCode
- *stepStartEmulator
- *stepRunTests
- *stepStopEmulator
- *stepBuildDebug
artifacts: *androidArtifacts
publishing:
email:
recipients: *debugEmails
merge-requests:
name: Merge requests
instance_type: linux_x2
triggering:
events:
- pull_request
branch_patterns:
- pattern: 'develop'
include: true
source: false
cancel_previous_builds: true
scripts:
- *stepLocalSetup
- *stepCheckCode
- *stepStartEmulator
- *stepRunTests
- *stepStopEmulator
- *stepBuildDebug
publishing:
email:
recipients: *debugEmails
notify:
success: false