-
Notifications
You must be signed in to change notification settings - Fork 268
/
config.yml
162 lines (154 loc) · 5.34 KB
/
config.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
cache_version_keys: &cache_version_keys
CACHE_VERSION_OF_PROJECT_DEPS: v2
CACHE_VERSION_OF_DANGER_CACHE: v1
cache_keys:
gradle_cache:
primary: &primary_key_of_gradle_cache gradle-cache-{{ checksum "~/CACHE_VERSION_OF_PROJECT_DEPS" }}}-{{ checksum "~/project_hash.txt" }}
keys: &all_keys_of_gradle_cache
- *primary_key_of_gradle_cache
- gradle-cache-{{ checksum "~/CACHE_VERSION_OF_PROJECT_DEPS" }}-
danger_cache:
primary: &primary_key_of_danger_cache danger-cache-{{ checksum "~/CACHE_VERSION_OF_DANGER_CACHE" }}-{{ checksum "~/danger_cache" }}
keys: &all_keys_of_danger_cache
- *primary_key_of_danger_cache
- danger-cache-{{ checksum "~/CACHE_VERSION_OF_DANGER_CACHE" }}-
docker_env:
android_defaults: &android_defaults
working_directory: ~/conference-app-2019
docker:
- image: circleci/android:api-28-alpha
environment:
<<: *cache_version_keys
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError" -Dorg.gradle.daemon=false'
go_defaults: &go_defaults
working_directory: ~/conference-app-2019
docker:
- image: jmatsu/dpg:v0.3.0
shared_build_steps:
- run: &init_bash
name: Source the bash source
command: |
echo "export REPOSITORY_ROOT=$(git rev-parse --show-toplevel)" >> $BASH_ENV
echo "source $CIRCLE_WORKING_DIRECTORY/scripts/bash.source" >> $BASH_ENV
source $BASH_ENV
init_ci_stuff
- run: &download_dpg
name: Download a binary file of dpg
command: |
cd $(eval echo $CIRCLE_WORKING_DIRECTORY)/scripts
curl -sL "https://raw.githubusercontent.com/jmatsu/dpg/master/install.bash" | bash
dpg -v
version: 2
jobs:
assemble_apk:
<<: *android_defaults
steps:
- checkout
- run: *init_bash
- restore_cache: &restore_gradle_cache
keys: *all_keys_of_gradle_cache
- run: &download_all_dependencies
name: Download Dependencies
command: retry_command ./gradlew androidDependenciesExtra getDependencies
- save_cache: &save_gradle_cache
paths:
- ~/.android
- ~/.gradle
- .gradle
key: *primary_key_of_gradle_cache
- run:
name: Assemble apk
command: |
./gradlew clean assembleDebug --offline
- store_artifacts:
path: frontend/android/build/outputs/apk
- run: *download_dpg
- run:
name: Upload an apk and create a distribution by app-manage procedure.
command: |
apk_path=$(find frontend/android/build/outputs/apk -name "*.apk" | head -1)
dpg procedure app-manage on-feature-branch --app "$apk_path" --android | parse_dg_response
- restore_cache: &restore_danger_cache
keys: *all_keys_of_danger_cache
- run: &bundle_install_for_danger
name: Bundle install for Danger
command: |
cd scripts/danger
bundle check || bundle install --clean
when: always
- save_cache: &save_danger_cache
paths:
- ./scripts/danger/vendor/bundle
key: *primary_key_of_danger_cache
- run:
name: Compare apks with the latest production apk
command: |
if download_latest_apk "$PWD/latest.apk"; then
# find first
export BUILT_APK_FILE_PATH="$PWD/$(find frontend/android/build/outputs/apk -name "*.apk" | head -1)"
export OLD_BUILT_APK_FILE_PATH="$PWD/latest.apk"
if [[ -f "$BUILT_APK_FILE_PATH" ]] && [[ -f "$OLD_BUILT_APK_FILE_PATH" ]]; then
danger_compare_apks
else
echo "Cannot find apks" 1>&2
fi
fi
vital_check:
<<: *android_defaults
steps:
- checkout
- run: *init_bash
- restore_cache: *restore_gradle_cache
- run: *download_all_dependencies
- save_cache: *save_gradle_cache
- run: ./gradlew testDebugUnitTest lintDebug ktlint --continue --offline
- run:
name: Merge junit report files
command: |
merge_all_junit_files
cp "$MERGED_JUNIT_RESULT_FILE" build/all-junit.xml
when: always
- store_test_results:
path: build/all-junit.xml
when: always
- restore_cache: *restore_danger_cache
- run: *bundle_install_for_danger
- run:
name: Report lint results else
command: danger_assertions
when: always
- save_cache: *save_danger_cache
destroy_distribution:
<<: *go_defaults
steps:
- checkout
- run:
name: Destroy the associated distribution by app-manage procedure.
command: |
./scripts/destroy_distribution
placeholder:
<<: *go_defaults
steps:
- run: echo Hello
workflows_filter:
only_production_ready: &only_production_ready
filters:
branches:
only: /release/
except_production_ready: &except_production_ready
filters:
branches:
ignore: /release/
workflows:
version: 2
staging_or_feature:
jobs:
- assemble_apk: *except_production_ready
- vital_check: *except_production_ready
- destroy_distribution:
filters:
branches:
only: /master/
production_ready:
jobs:
- placeholder: *only_production_ready