-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJustfile
More file actions
208 lines (170 loc) · 6.42 KB
/
Copy pathJustfile
File metadata and controls
208 lines (170 loc) · 6.42 KB
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
set dotenv-load
set dotenv-filename := ".env"
set windows-shell := ["sh", "-cu"]
gradle := "./gradlew"
ndk_ver := "28.1.13356709"
default:
@just list
list:
@printf "%s\n" \
"list" \
"init" \
"compile" \
"run [docker]" \
"build [TASK]" \
"release" \
"install" \
"test" \
"test file PATTERN" \
"test android" \
"test lane LANE" \
"lint" \
"lint baseline" \
"format" \
"translations pull" \
"translations push source" \
"translations push all" \
"e2e [network|no geo|TASK] [TASK]" \
"changelog [all|next|hotfix]" \
"clean"
init:
#!/usr/bin/env sh
set -eu
if [ -e .env ]; then
echo ".env already exists"
exit 0
fi
cp .env.example .env
echo "Created .env"
compile:
{{ gradle }} compileDevDebugKotlin
run mode="" logs="":
#!/usr/bin/env sh
set -eu
app_id="to.bitkit.dev"
app_dir="app/build/outputs/apk/dev/debug"
mode="{{ mode }}"
logs="{{ logs }}"
attach_logs=false
if [ "$mode" = "logs" ]; then
attach_logs=true
mode=""
fi
if [ -n "$logs" ]; then
if [ "$logs" != "logs" ]; then
echo "usage: just run [docker] [logs]" >&2
exit 1
fi
attach_logs=true
fi
if [ -n "$mode" ] && [ "$mode" != "docker" ]; then
echo "usage: just run [docker] [logs]" >&2
exit 1
fi
if ! command -v adb >/dev/null 2>&1; then
echo "adb is required to run the app." >&2
exit 1
fi
if [ -n "${ANDROID_SERIAL:-}" ]; then
device_id="$ANDROID_SERIAL"
else
echo "Looking for connected Android devices..."
device_id="$(
adb devices -l \
| awk 'NR > 1 && $2 == "device" && $1 !~ /^emulator-/ { print $1; exit }'
)"
if [ -z "$device_id" ]; then
device_id="$(
adb devices -l \
| awk 'NR > 1 && $2 == "device" { print $1; exit }'
)"
fi
fi
if [ -z "$device_id" ]; then
echo "No connected Android device found." >&2
exit 1
fi
device_name="$(
adb -s "$device_id" shell getprop ro.product.model 2>/dev/null \
| tr -d '\r' \
|| true
)"
if [ -z "$device_name" ]; then
device_name="$device_id"
fi
echo "Using $device_name ($device_id)"
build_env=""
if [ "$mode" = "docker" ]; then
echo "Forwarding bitkit-docker ports via adb reverse..."
adb -s "$device_id" reverse tcp:60001 tcp:60001 # local Electrum
adb -s "$device_id" reverse tcp:6288 tcp:6288 # local homegate
adb -s "$device_id" reverse tcp:9735 tcp:9735 # local lnd peer
adb -s "$device_id" reverse tcp:3000 tcp:3000 # local lnurl-server
build_env="E2E=true"
fi
echo "Building Debug app..."
env $build_env {{ gradle }} assembleDevDebug
app_path="$(
find "$app_dir" -maxdepth 1 -name '*-universal.apk' -type f \
| sort \
| tail -n 1
)"
if [ -z "$app_path" ]; then
app_path="$(
find "$app_dir" -maxdepth 1 -name '*.apk' -type f \
| sort \
| tail -n 1
)"
fi
if [ -z "$app_path" ]; then
echo "No APK found in $app_dir." >&2
exit 1
fi
echo "Installing $app_path..."
adb -s "$device_id" install -r "$app_path"
echo "Launching $app_id..."
adb -s "$device_id" shell am force-stop "$app_id"
adb -s "$device_id" shell monkey -p "$app_id" -c android.intent.category.LAUNCHER 1 >/dev/null
if [ "$attach_logs" != "true" ]; then
echo "Launched $app_id"
exit 0
fi
pid="$(
adb -s "$device_id" shell pidof -s "$app_id" 2>/dev/null \
| tr -d '\r' \
|| true
)"
if [ -z "$pid" ]; then
echo "Launched $app_id"
exit 0
fi
echo "Streaming logs for $app_id (pid $pid). Press Ctrl-C to stop."
adb -s "$device_id" logcat --pid "$pid"
build task="assembleDevDebug":
{{ gradle }} {{ task }}
release:
#!/usr/bin/env sh
set -eu
symbols_dir="app/build/outputs/native-debug-symbols/mainnetRelease"
rm -f "$symbols_dir"/native-debug-symbols*.zip
NDK_VERSION={{ ndk_ver }} {{ gradle }} assembleMainnetRelease bundleMainnetRelease
NDK_VERSION={{ ndk_ver }} {{ gradle }} :app:syncNativeDebugSymbolArtifacts
scripts/create-native-debug-symbols.sh
symbols="$(find "$symbols_dir" -maxdepth 1 -name 'native-debug-symbols-*.zip' -type f | sort | tail -n 1)"
echo "Attach this exact file to GitHub releases, upload it to Play Console for this release, and verify Play lists it: $symbols"
install:
{{ gradle }} installDevDebug
test target="" value="":
{{ if target == "" { gradle + " testDevDebugUnitTest" } else if target == "android" { gradle + " connectedDevDebugAndroidTest" } else if target == "file" { if value == "" { error("usage: just test file PATTERN") } else { gradle + " testDevDebugUnitTest --tests '" + value + "'" } } else if target == "lane" { if value == "" { error("usage: just test lane LANE") } else { gradle + " connectedDevDebug" + value + "AndroidTest" } } else { error("usage: just test [file PATTERN|android|lane LANE]") } }}
lint target="":
{{ if target == "" { gradle + " detekt --rerun-tasks" } else if target == "baseline" { gradle + " detektBaseline --rerun-tasks" } else { error("usage: just lint [baseline]") } }}
format:
{{ gradle }} detekt --auto-correct --rerun-tasks
translations action value="":
{{ if action == "pull" { "./scripts/pull-translations.sh" } else if action == "push" { if value == "source" { "tx push --source" } else if value == "all" { "./scripts/push-translations.sh" } else { error("usage: just translations pull|push source|push all") } } else { error("usage: just translations pull|push source|push all") } }}
e2e mode="" value="" task="assembleDevRelease":
{{ if mode == "" { "E2E=true " + gradle + " " + task } else if mode == "network" { "E2E=true E2E_BACKEND=network " + gradle + " " + if value == "" { task } else { value } } else if mode == "no" { if value == "geo" { "GEO=false E2E=true " + gradle + " " + task } else { error("usage: just e2e no geo [TASK]") } } else { "E2E=true " + gradle + " " + mode } }}
changelog target="all":
./scripts/preview-changelog.sh --target {{ target }}
clean:
{{ gradle }} clean