-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
280 lines (227 loc) · 9.58 KB
/
justfile
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
build:
#!/usr/bin/env bash
# (alexander) we still need to run direnv reload here, so
# think if we ned this here
# Make sure all submodules are up to date
# git submodule sync
# git submodule update --init --recursive
# Build CodeTracer once, so we can run the user-setup command
# TODO: alexander think more about this command
# cd src
# tup build-debug
# build-debug/codetracer user-setup
# Start building continuously
cd src
tup build-debug
tup monitor -a
cd ../
# start webpack
node_modules/.bin/webpack --watch --progress & # building frontend_bundle.js
# Start the JavaScript and CSS hot-reloading server
# TODO browser-sync is currently missing
# node build-debug/browsersync_serv.js &
build-once:
#!/usr/bin/env bash
# We have to make the dist directory here, because it's missing on a fresh check out
# It will be created by the webpack command below, but we have an a chicken and egg
# problem because the Tupfiles refer to it.
mkdir public/dist
cd src
tup build-debug
cd ..
# Build frontend_bundle.js in the dist folder
node_modules/.bin/webpack --progress
# We need to execute another tup run because webpack may have created some new files
# that tup will discover
cd src
tup build-debug
build-docs *LOCALHOST:
#!/usr/bin/env bash
cd docs/experimental-documentation/
nix-shell --run "./generate-html.sh {{LOCALHOST}}"
build-deb-package file_sizes_report="false":
#!/usr/bin/env bash
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-bundle.html
# TODO: We should pin the revison of the bundlers repo by adding it to our
# development flake.
nix bundle --bundler github:NixOS/bundlers#toDEB --print-build-logs ".?submodules=1#codetracer"
# TODO Can we change this and use in the command above?
# `nix bundle` doesn't seem to have parameters controlling this and right now
# it selects these names by default. The appearance of the version number in
# the filename is particularly problematic because it means that this script
# will be broken after each upgrade.
OUT_DIR=deb-single-codetracer-bin-codetracer/
DEB_PACKAGE_NAME=codetracer-bin-codetracer_1.0_amd64.deb
if [[ "{{file_sizes_report}}" == "true" ]]; then
REPORT_FILE="codetracer-deb-file-sizes-report.txt"
echo Generating file sizes report...
dpkg -c $OUT_DIR/$DEB_PACKAGE_NAME > "$REPORT_FILE"
echo $REPORT_FILE written!
echo You can load the produced file in Excel/LibreOffice by treating it as a fixed-width CSV file.
fi
build-nix-app-image:
#!/usr/bin/env bash
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-bundle.html
# TODO: We should pin the revison of the bundlers repo by adding it to our
# development flake.
nix bundle --bundler github:ralismark/nix-appimage --print-build-logs ".?submodules=1#codetracer"
build-macos-app:
bash non-nix-build/build.sh
build-app-image:
./appimage-scripts/build_appimage.sh
tester := "src/build-debug/bin/tester"
test-ui headless="0":
#!/usr/bin/env bash
set -e
if [[ "{{headless}}" == "0" ]]; then
{{tester}} ui
else
xvfb-run {{tester}} ui
fi
test headless="0":
{{tester}} build
just test-ui {{headless}}
{{tester}} rr-gdb-scripts
{{tester}} core
make-quick-mr name message:
# EXPECTS changes to be manually added with `git add`
# before running!
git checkout -b {{name}} || true # ok if already existing
git commit -m "{{message}}"
git push -u origin {{name}} -o merge_request.create -o merge_request.target=master
# if we decide to use glab
# https://docs.gitlab.com/ee/integration/glab/
# glab mr create -t "{{message}}" --description "" --web
clean-logs:
rm -rf /tmp/codetracer/*
archive-logs pid_or_current_or_last:
export pid=$(just pid {{pid_or_current_or_last}}) ; \
zip -r codetracer-logs-{{pid_or_current_or_last}}.zip /tmp/codetracer/run-${pid}
log-file pid_or_current_or_last kind process="default" instance_index="0":
# first argument can be either `current`, `last` or a pid number
# `kind` can be one of
# task_process, scripts, index, rr_gdb_raw or dispatcher
if [[ "{{kind}}" == "dispatcher" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "task_process" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "scripts" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "index" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "frontend" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "virtualization" ]]; then \
export ext="log"; \
elif [[ "{{kind}}" == "db-backend" ]]; then \
export ext="log"; \
else \
export ext="txt"; \
fi; \
if [[ "{{process}}" == "default" ]]; then \
export actual_process={{kind}}; \
else \
export actual_process={{process}}; \
fi; \
export pid=$(just pid {{pid_or_current_or_last}}); \
if [[ "{{kind}}" == "workers" ]]; then \
echo "/tmp/codetracer/run-${pid}/processes.txt"; \
else \
echo "/tmp/codetracer/run-${pid}/{{kind}}_${actual_process}_{{instance_index}}.${ext}"; \
fi;
log pid_or_current_or_last kind process="default" instance_index="0":
export log_file_path=$(just log-file {{pid_or_current_or_last}} {{kind}} {{process}} {{instance_index}}); \
vim \
-c ":term ++open cat ${log_file_path}" \
-c "wincmd j" -c "q"
# (move to non-terminal pane down and close it)
tail pid_or_current_or_last kind process="default" instance_index="0":
export log_file_path=$(just log-file {{pid_or_current_or_last}} {{kind}} {{process}} {{instance_index}}); \
tail -f ${log_file_path}
build-nix:
nix build --print-build-logs '.?submodules=1#codetracer' --show-trace --keep-failed
cachix-push-nix-package:
cachix push metacraft-labs-codetracer $(nix build --print-out-paths ".?submodules=1#codetracer")
cachix-push-devshell:
cachix push metacraft-labs-codetracer $(nix build --print-out-paths .#devShells.x86_64-linux.default)
reset-db:
rm -rf ~/.local/share/codetracer/trace_index.db
clear-local-traces:
rm -rf ~/.local/share/codetracer
pid pid_or_current_or_last:
# argument can be either `current`, `last` or a pid number
if [[ "{{pid_or_current_or_last}}" == "current" ]]; then \
echo $(ps aux | grep src/build-debug/codetracer | head -n 1 | awk '{print $2}') ; \
elif [[ "{{pid_or_current_or_last}}" == "last" ]]; then \
echo $(cat /tmp/codetracer/last-start-pid) ; \
else \
echo {{pid_or_current_or_last}} ; \
fi
log-task pid_or_current_or_last task-id:
# argument can be either `current`, `last` or a pid number
export pid=$(just pid {{pid_or_current_or_last}}) ; \
python3 src/tools/log_task.py ${pid} {{task-id}}
log-event pid_or_current_or_last event-id:
# argument can be either `current`, `last` or a pid number
export pid=$(just pid {{pid_or_current_or_last}}) ; \
cat /tmp/codetracer/run-${pid}/events/{{event-id}}.json
log-result pid_or_current_or_last task-id:
# argument can be either `current`, `last` or a pid number
export pid=$(just pid {{pid_or_current_or_last}}) ; \
cat /tmp/codetracer/run-${pid}/results/{{task-id}}.json
log-args pid_or_current_or_last task-id:
# argument can be either `current`, `last` or a pid number
export pid=$(just pid {{pid_or_current_or_last}}) ; \
cat /tmp/codetracer/run-${pid}/args/{{task-id}}.json
# " (artiffical comment to fix syntax highlighting)
test-valid-trace trace_dir:
cd src/db-backend && \
env CODETRACER_VALID_TEST_TRACE_DIR={{trace_dir}} cargo test test_valid_trace
# no need to cd back: i assume and manual use shows
# just probably runs this in a subshell(or at least it doesn't seem to affect
# our callsite)
stop:
killall -9 virtualization-layers db-backend node .electron-wrapped || true
reset-config:
rm --force ~/.config/codetracer/.config.yaml && \
mkdir -p ~/.config/codetracer/ && \
cp -r config/default_config.yaml ~/.config/codetracer/.config.yaml
reset-layout:
rm --force ~/.config/codetracer/default_layout.json && \
mkdir -p ~/.config/codetracer/ && \
cp -r config/default_layout.json ~/.config/codetracer/default_layout.json
# originally by Pavel/Dimo in ci.sh
test-nimsuggest:
#!/usr/bin/env bash
if echo quit | nimsuggest --v4 src/lsp.nim; then
echo "OK: nimsuggest starts without an error for src/lsp.nim"
else
echo "ERROR: nimsuggest NOT WORKING for src/lsp.nim"
echo " suggestion: often this is because of adding chronicles log statements"
echo " with distinct types, or maybe object containing distinct types"
echo " like \`debug \"message\", taskId\`"
echo " or other kinds of problems with args"
echo " --"
echo " changing to \`taskId=taskId.string\` seems to be a workaround"
echo " if it's an object, changing to \`obj=obj.repr\` seems to maybe help"
exit 1
fi
# ===========================
# trace folder helpers
trace-folder program_pattern:
ct trace-metadata --program={{program_pattern}} | jq --raw-output .outputFolder # no quotes around string, important for tree
trace-folder-for-id trace_id:
ct trace-metadata --id={{trace_id}} | jq --raw-output .outputFolder # no quotes around string, important for tree
tree-trace-folder program_pattern:
tree $(just trace-folder {{program_pattern}})
tree-trace-folder-for-id trace_id:
tree $(just trace-folder-for-id {{trace_id}})
ls-trace-folder program_pattern:
ls -alh $(just trace-folder {{program_pattern}})
ls-trace-folder-for-id trace_id:
ls -alh $(just trace-folder-for-id {{trace_id}})
# we can't have a `just cd..` command, as just recipes seem to run as child processes,
# so they can't change the current directory
# https://github.com/casey/just/issues/1261#issuecomment-1177155928
# end of trace folder helpers
# ===========================