1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Run continuous build tasks.
|
4 | #
|
5 | # Usage:
|
6 | # soil/worker.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | REPO_ROOT=$(cd "$(dirname $0)/.."; pwd) # tsv-lib.sh uses this
|
13 | readonly REPO_ROOT
|
14 |
|
15 | source soil/common.sh
|
16 | source test/tsv-lib.sh
|
17 |
|
18 | py-all-and-ninja() {
|
19 | ### baseline for most tasks
|
20 |
|
21 | build/py.sh all
|
22 | ./NINJA-config.sh
|
23 | }
|
24 |
|
25 | ninja-config() {
|
26 | ./NINJA-config.sh
|
27 | }
|
28 |
|
29 | dummy-tasks() {
|
30 | ### Print tasks that execute quickly
|
31 |
|
32 | # (task_name, script, action, result_html)
|
33 | cat <<EOF
|
34 | os-info soil/diagnose.sh os-info -
|
35 | dump-env soil/diagnose.sh dump-env -
|
36 | EOF
|
37 | }
|
38 |
|
39 | raw-vm-tasks() {
|
40 | # The perf tool depends on a specific version of a kernel, so run it outside
|
41 | # a container.
|
42 |
|
43 | # (task_name, script, action, result_html)
|
44 | cat <<EOF
|
45 | os-info soil/diagnose.sh os-info -
|
46 | dump-env soil/diagnose.sh dump-env -
|
47 | perf-install benchmarks/perf.sh soil-install -
|
48 | wait-for-tarball soil/wait.sh for-cpp-tarball -
|
49 | test-install-tar devtools/release-native.sh test-install-tar -
|
50 | perf-profiles benchmarks/perf.sh soil-run _tmp/perf/index.html
|
51 | EOF
|
52 | }
|
53 |
|
54 | # Oh there is a large list of pre-installed software
|
55 | # https://github.com/actions/runner-images#available-images
|
56 | # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md
|
57 | # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
|
58 | #
|
59 | # 1. System deps for building wedges - ninja, cmake, libreadline-dev, etc.
|
60 | # 2. fetch wedges - re2c, cmark, python2, python3, MyPy, pyflakes
|
61 | # - Python 3.10 desired for "pea"
|
62 | # 3. build them
|
63 | # 4. build Oils with them
|
64 |
|
65 | dev-setup-for() {
|
66 | local distro=$1
|
67 | # (task_name, script, action, result_html)
|
68 |
|
69 | cat <<EOF
|
70 | os-info soil/diagnose.sh os-info -
|
71 | dump-env soil/diagnose.sh dump-env -
|
72 | wedge-deps build/deps.sh wedge-deps-$distro -
|
73 | fetch build/deps.sh fetch -
|
74 | install-wedges build/deps.sh install-wedges-soil _build/wedge/logs/index.html
|
75 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
76 | smoke-test build/dev-setup-test.sh smoke-test -
|
77 | wedge-report build/deps.sh wedge-report -
|
78 | EOF
|
79 | }
|
80 |
|
81 | spec-bin-for() {
|
82 | local distro=$1
|
83 | cat <<EOF
|
84 | os-info soil/diagnose.sh os-info -
|
85 | dump-env soil/diagnose.sh dump-env -
|
86 | wedge-deps build/deps.sh wedge-deps-$distro -
|
87 | fetch build/deps.sh fetch -
|
88 | spec-bin build/deps.sh install-spec-bin-fast _build/wedge/logs/index.html
|
89 | EOF
|
90 | }
|
91 |
|
92 | dev-setup-debian-tasks() {
|
93 | # (task_name, script, action, result_html)
|
94 |
|
95 | dev-setup-for debian
|
96 | }
|
97 |
|
98 | dev-setup-fedora-tasks() {
|
99 | # (task_name, script, action, result_html)
|
100 |
|
101 | dev-setup-for fedora
|
102 | }
|
103 |
|
104 | dev-setup-alpine-tasks() {
|
105 | # (task_name, script, action, result_html)
|
106 |
|
107 | dev-setup-for alpine
|
108 | }
|
109 |
|
110 | pea-tasks() {
|
111 | ### Print tasks for the 'pea' build
|
112 |
|
113 | # We need a later version of Python 3 / MyPy both to type check and
|
114 | # to parse
|
115 |
|
116 | # Run py-source so we can type check generated code
|
117 | # We need to type check more than we translate
|
118 |
|
119 | # (task_name, script, action, result_html)
|
120 | cat <<EOF
|
121 | os-info soil/diagnose.sh os-info -
|
122 | dump-env soil/diagnose.sh dump-env -
|
123 | py-source build/py.sh py-source -
|
124 | typecheck pea/TEST.sh check-with-latest-mypy -
|
125 | parse-all pea/TEST.sh parse-all -
|
126 | EOF
|
127 |
|
128 | # Moved this to cpp-small, because it depends on py-all-and-ninja
|
129 | # run-tests pea/TEST.sh run-tests -
|
130 | }
|
131 |
|
132 | dev-minimal-tasks() {
|
133 | ### Print tasks for the 'dev-minimal' build
|
134 |
|
135 | # repo overview is suggested by README.md
|
136 |
|
137 | # (task_name, script, action, result_html)
|
138 | cat <<EOF
|
139 | os-info soil/diagnose.sh os-info -
|
140 | dump-env soil/diagnose.sh dump-env -
|
141 | build-minimal build/py.sh minimal -
|
142 | repo-overview metrics/source-code.sh overview -
|
143 | lint test/lint.sh soil-run -
|
144 | asdl-types asdl/TEST.sh check-types -
|
145 | oil-types devtools/types.sh soil-run -
|
146 | unit test/unit.sh minimal _test/py-unit/
|
147 | lossless test/lossless.sh soil-run -
|
148 | parse-errors test/parse-errors.sh soil-run-py -
|
149 | runtime-errors test/runtime-errors.sh soil-run-py -
|
150 | ysh-parse-errors test/ysh-parse-errors.sh soil-run-py -
|
151 | ysh-runtime-errors test/ysh-runtime-errors.sh soil-run-py -
|
152 | ysh-every-string test/ysh-every-string.sh soil-run-py -
|
153 | ysh-large ysh/run.sh soil-run -
|
154 | j8-errors data_lang/j8-errors.sh soil-run-py -
|
155 | link-busybox-ash test/spec-bin.sh link-busybox-ash -
|
156 | osh-minimal test/spec-py.sh osh-minimal _tmp/spec/osh-minimal/index.html
|
157 | headless client/run.sh soil-run-py -
|
158 | stdlib-test stdlib/TEST.sh soil-run -
|
159 | EOF
|
160 | }
|
161 |
|
162 | interactive-tasks() {
|
163 | ### Print tasks for the 'interactive' build
|
164 |
|
165 | # TODO: also run interactive suite with osh-cpp
|
166 |
|
167 | # TODO: Why does the needs-terminal suite hang in Docker? It doesn't hang in an interactive Docker session.
|
168 | #
|
169 | # needs-terminal test/spec-py.sh needs-terminal-all _tmp/spec/needs-terminal-py/index.html
|
170 | #
|
171 | # https://oilshell.zulipchat.com/#narrow/stream/121539-oil-dev/topic/Spec.20Tests.20for.20Interactive.20Parsing
|
172 |
|
173 | cat <<EOF
|
174 | os-info soil/diagnose.sh os-info -
|
175 | dump-env soil/diagnose.sh dump-env -
|
176 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
177 | interactive-osh test/spec-py.sh interactive-osh _tmp/spec/interactive-osh/index.html
|
178 | nohup test/nohup.sh soil-run -
|
179 | process-table test/process-table.sh soil-run _tmp/process-table/index.html
|
180 | stateful test/stateful.sh soil-run _tmp/spec/stateful/index.html
|
181 | EOF
|
182 |
|
183 | }
|
184 |
|
185 | wild-tasks() {
|
186 | ### Print tasks for the 'wild' build
|
187 |
|
188 | # (task_name, script, action, result_html)
|
189 | cat <<EOF
|
190 | os-info soil/diagnose.sh os-info -
|
191 | dump-env soil/diagnose.sh dump-env -
|
192 | wait-for-tarball soil/wait.sh for-cpp-tarball -
|
193 | test-tar devtools/release-native.sh test-tar -
|
194 | linecount metrics/tarball.sh linecount-oils-cpp -
|
195 | wild test/wild.sh soil-run _tmp/wild-www/index.html
|
196 | EOF
|
197 | }
|
198 |
|
199 | benchmarks-tasks() {
|
200 | # (task_name, script, action, result_html)
|
201 |
|
202 | cat <<EOF
|
203 | os-info soil/diagnose.sh os-info -
|
204 | dump-env soil/diagnose.sh dump-env -
|
205 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
206 | dev-shell-test build/dev-shell-test.sh soil-run -
|
207 | id-test benchmarks/id-test.sh soil-run -
|
208 | osh-parser benchmarks/osh-parser.sh soil-run _tmp/osh-parser/index.html
|
209 | osh-runtime benchmarks/osh-runtime.sh soil-run _tmp/osh-runtime/index.html
|
210 | vm-baseline benchmarks/vm-baseline.sh soil-run _tmp/vm-baseline/index.html
|
211 | compute benchmarks/compute.sh soil-run _tmp/compute/index.html
|
212 | gc benchmarks/gc.sh soil-run _tmp/gc/index.html
|
213 | mycpp-benchmarks benchmarks/mycpp.sh soil-run _tmp/mycpp-examples/index.html
|
214 | EOF
|
215 | }
|
216 |
|
217 | bloaty-tasks() {
|
218 | cat <<EOF
|
219 | os-info soil/diagnose.sh os-info -
|
220 | dump-env soil/diagnose.sh dump-env -
|
221 | wait-for-tarball soil/wait.sh for-cpp-tarball -
|
222 | test-tar devtools/release-native.sh test-tar -
|
223 | native-code metrics/native-code.sh oils-for-unix _tmp/metrics/oils-for-unix/
|
224 | EOF
|
225 | }
|
226 |
|
227 | benchmarks2-tasks() {
|
228 | # Note: id-test doesn't run in 'other-tests' because 'gawk' isn't in that image
|
229 | cat <<EOF
|
230 | os-info soil/diagnose.sh os-info -
|
231 | dump-env soil/diagnose.sh dump-env -
|
232 | wait-for-tarball soil/wait.sh for-cpp-tarball -
|
233 | test-tar devtools/release-native.sh test-tar -
|
234 | uftrace benchmarks/uftrace.sh soil-run _tmp/uftrace/index.html
|
235 | gc-cachegrind benchmarks/gc-cachegrind.sh soil-run _tmp/gc-cachegrind/index.html
|
236 | EOF
|
237 | }
|
238 |
|
239 | cpp-spec-tasks() {
|
240 | # (task_name, script, action, result_html)
|
241 |
|
242 | cat <<EOF
|
243 | os-info soil/diagnose.sh os-info -
|
244 | dump-env soil/diagnose.sh dump-env -
|
245 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
246 | oils-cpp-smoke build/native.sh soil-run -
|
247 | osh-all test/spec-cpp.sh osh-all _tmp/spec/osh-cpp/compare.html
|
248 | ysh-all test/spec-cpp.sh ysh-all _tmp/spec/ysh-cpp/compare.html
|
249 | ysh-py test/spec-py.sh ysh-all-serial _tmp/spec/ysh-py/index.html
|
250 | EOF
|
251 | }
|
252 |
|
253 | cpp-tarball-tasks() {
|
254 |
|
255 | # Note: build-times task requires _build/oils.sh
|
256 | # It's a bit redundant with test-tar
|
257 |
|
258 | cat <<EOF
|
259 | os-info soil/diagnose.sh os-info -
|
260 | dump-env soil/diagnose.sh dump-env -
|
261 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
262 | oils-cpp-smoke build/native.sh soil-run -
|
263 | make-tar devtools/release-native.sh make-tar _release/oils-for-unix.tar
|
264 | xshar-hello devtools/xshar.sh soil-run-hello _release/hello-xshar.xshar
|
265 | xshar-test-oils devtools/xshar.sh soil-run-test-oils _release/test-oils.xshar
|
266 | build-times build/native.sh measure-build-times -
|
267 | EOF
|
268 |
|
269 | # build-times is a good enough test
|
270 | # test-tar devtools/release-native.sh test-tar -
|
271 | #
|
272 | # Note: tarball is deployed outside the container
|
273 |
|
274 | }
|
275 |
|
276 | cpp-small-tasks() {
|
277 |
|
278 | # yaks could be moved to pea/ image once it has python2-dev
|
279 | cat <<EOF
|
280 | os-info soil/diagnose.sh os-info -
|
281 | dump-env soil/diagnose.sh dump-env -
|
282 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
283 | py-unit test/unit.sh all _test/py-unit/
|
284 | yaks yaks/TEST.sh soil-run -
|
285 | pea pea/TEST.sh run-tests -
|
286 | oils-cpp-smoke build/native.sh soil-run -
|
287 | cpp-unit test/cpp-unit.sh soil-run _test/-wwz-index
|
288 | headless client/run.sh soil-run-cpp -
|
289 | asan test/asan.sh soil-run -
|
290 | ltrace test/ltrace.sh soil-run -
|
291 | micro-syntax doctools/micro-syntax.sh soil-run -
|
292 | src-tree doctools/src-tree.sh soil-run _tmp/src-tree-www/index.html
|
293 | line-counts metrics/source-code.sh write-reports _tmp/metrics/line-counts/-wwz-index
|
294 | preprocessed metrics/source-code.sh preprocessed _tmp/metrics/preprocessed/-wwz-index
|
295 | mycpp-examples mycpp/TEST.sh soil-run _test/-wwz-index
|
296 | parse-errors test/parse-errors.sh soil-run-cpp -
|
297 | runtime-errors test/runtime-errors.sh soil-run-cpp -
|
298 | ysh-parse-errors test/ysh-parse-errors.sh soil-run-cpp -
|
299 | ysh-runtime-errors test/ysh-runtime-errors.sh soil-run-cpp -
|
300 | ysh-every-string test/ysh-every-string.sh soil-run-cpp -
|
301 | ysh-large ysh/run.sh soil-run-cpp -
|
302 | j8-errors data_lang/j8-errors.sh soil-run-cpp -
|
303 | houston-fp demo/houston-fp/run.sh soil-run -
|
304 | souffle-smoke-test test/souffle-smoke.sh soil-run -
|
305 | EOF
|
306 | }
|
307 |
|
308 | cpp-coverage-tasks() {
|
309 | # dep notes: hnode_asdl.h required by expr_asdl.h in mycpp/examples
|
310 |
|
311 | # TODO: make this work
|
312 | #tar-compile benchmarks/ovm-build.sh soil-run -
|
313 | cat <<EOF
|
314 | os-info soil/diagnose.sh os-info -
|
315 | dump-env soil/diagnose.sh dump-env -
|
316 | py-all-and-ninja soil/worker.sh py-all-and-ninja -
|
317 | extract-clang deps/from-binary.sh extract-clang-in-container -
|
318 | mycpp-unit-coverage mycpp/TEST.sh unit-test-coverage _test/clang-coverage/mycpp/html/index.html
|
319 | mycpp-examples-coverage mycpp/TEST.sh examples-coverage _test/clang-coverage/mycpp/examples/html/index.html
|
320 | cpp-coverage cpp/TEST.sh coverage _test/clang-coverage/cpp/html/index.html
|
321 | unified-coverage test/coverage.sh unified-report _test/clang-coverage/unified/html/index.html
|
322 | compare-gcc-clang metrics/native-code.sh compare-gcc-clang _tmp/metrics/compare-gcc-clang.txt
|
323 | EOF
|
324 | }
|
325 |
|
326 | ovm-tarball-tasks() {
|
327 | ### Print tasks for the 'ovm-tarball' build
|
328 |
|
329 | # notes:
|
330 | # - py-all needed to crawl dependencies to make tarball.
|
331 |
|
332 | # (task_name, script, action, result_html)
|
333 | cat <<EOF
|
334 | os-info soil/diagnose.sh os-info -
|
335 | dump-env soil/diagnose.sh dump-env -
|
336 | py-all build/py.sh all -
|
337 | make-tarball devtools/release.sh py-tarball _release/oil.tar
|
338 | ysh-ovm-tarball test/spec-py.sh ysh-ovm-tarball _tmp/spec/ysh-py/index.html
|
339 | syscall test/syscall.sh soil-run _tmp/syscall/-wwz-index
|
340 | osh-spec test/spec-py.sh osh-all-serial _tmp/spec/osh-py/index.html
|
341 | gold test/gold.sh soil-run -
|
342 | osh-usage test/osh-usage.sh soil-run -
|
343 | tools-deps test/tools-deps.sh soil-run -
|
344 | docs build/doc.sh soil-run _release/VERSION/index.html
|
345 | doc-metrics echo no-op _release/VERSION/doc/metrics.txt
|
346 | EOF
|
347 | # doc-metrics is a no-op, just for the link. Because soil-run just runs the
|
348 | # release, which creates metrics.
|
349 |
|
350 | }
|
351 |
|
352 | # Reuse ovm-tarball container
|
353 | app-tests-tasks() {
|
354 |
|
355 | cat <<EOF
|
356 | os-info soil/diagnose.sh os-info -
|
357 | dump-env soil/diagnose.sh dump-env -
|
358 | py-all build/py.sh all -
|
359 | ble-clone test/ble.sh clone -
|
360 | ble-build test/ble.sh build -
|
361 | ble-bash-suite test/ble.sh bash-suite -
|
362 | ble-test-osh-py test/ble.sh run-tests-osh-py -
|
363 | wait-for-tarball soil/wait.sh for-cpp-tarball -
|
364 | test-tar devtools/release-native.sh test-tar -
|
365 | ble-test-osh-cpp test/ble.sh run-tests-osh-cpp -
|
366 | EOF
|
367 |
|
368 | # This doesn't work
|
369 | # ble-test-osh-bash test/ble.sh run-tests-osh-bash -
|
370 | }
|
371 |
|
372 | # TODO: Most of these should be Ninja tasks.
|
373 | # Other tests:
|
374 | # find-test, xargs-test, pgen2-test, web/table/csv2html-test.sh
|
375 | # Probably should start using a shell test framework too.
|
376 | other-tests-tasks() {
|
377 | cat <<EOF
|
378 | os-info soil/diagnose.sh os-info -
|
379 | dump-env soil/diagnose.sh dump-env -
|
380 | build-minimal build/py.sh minimal -
|
381 | configure-test ./configure-test.sh soil_run -
|
382 | time-test benchmarks/time-test.sh soil-run -
|
383 | tsv-lib-test test/tsv-lib-test.sh soil-run -
|
384 | ysh-ify test/ysh-ify.sh soil-run -
|
385 | R-test devtools/R-test.sh soil-run -
|
386 | xargs-test test/other.sh xargs-test -
|
387 | csv2html-test test/other.sh csv2html-test -
|
388 | oil-python-symbols metrics/source-code.sh oil-python-symbols -
|
389 | opyc test/opyc.sh soil-run -
|
390 | opy-count-lines opy/soil.sh count-lines -
|
391 | test-gold opy/soil.sh test-gold -
|
392 | build-oil-repo opy/soil.sh build-oil-repo -
|
393 | regtest-compile opy/soil.sh regtest-compile -
|
394 | EOF
|
395 |
|
396 | # TODO: add this back after fixing transitive test enumeration problem
|
397 | # We shouldn't use
|
398 |
|
399 | # web-remote-test soil/web-remote-test.sh soil-run -
|
400 | }
|
401 |
|
402 | tests-todo() {
|
403 | ### More tests to add
|
404 | find . -name '_*' -a -prune -o -name '*-test.sh' -a -print
|
405 |
|
406 | # pgen2/pgen2-test.sh seems mostly broken
|
407 | }
|
408 |
|
409 | # Redefinition for quicker cloud debugging
|
410 | maybe-merge-tasks() {
|
411 | cat <<EOF
|
412 | os-info soil/diagnose.sh os-info -
|
413 | dump-env soil/diagnose.sh dump-env -
|
414 | maybe-merge soil/maybe-merge.sh soil-run -
|
415 | EOF
|
416 | }
|
417 |
|
418 | run-tasks() {
|
419 | ### Run the tasks on stdin and write _tmp/soil/INDEX.tsv.
|
420 | local job_name=$1
|
421 | local out_dir=$2 # should already exist
|
422 | local tty=$3
|
423 |
|
424 | mkdir -p $out_dir/logs
|
425 |
|
426 | # So we can run benchmarks/time_.py.
|
427 | # 2023-02-28: Images like soil-wild based off the new soil-common no longer
|
428 | # have 'cc'. Instead they use a wedge.
|
429 | if command -v cc > /dev/null; then
|
430 | build/py.sh time-helper
|
431 | else
|
432 | echo 'test time-tsv3'
|
433 | time-tsv3 -o /tmp/echo.tsv --append -- echo hi
|
434 |
|
435 | echo '/tmp/echo.tsv:'
|
436 | cat /tmp/echo.tsv
|
437 | fi
|
438 |
|
439 | # For the later deploy step to pick up
|
440 | date +%s > $out_dir/task-run-start-time.txt
|
441 |
|
442 | # This data can go on the dashboard index
|
443 | local tsv=$out_dir/INDEX.tsv
|
444 | rm -f $tsv
|
445 |
|
446 | local status
|
447 | local max_status=0
|
448 |
|
449 | while read task_name script action result_html; do
|
450 | log "--- task: $task_name ---"
|
451 |
|
452 | local log_path=$out_dir/logs/$task_name.txt
|
453 |
|
454 | # 15 minutes per task
|
455 | # One of the longest tasks is test/spec-cpp, which takes around 420 seconds
|
456 | # TODO: should have a configurable timeout
|
457 | local -a timeout=(timeout 900)
|
458 | local stdin_tty=''
|
459 |
|
460 | case $script in
|
461 | test/process-table.sh)
|
462 | # Workaround for weird interaction, see
|
463 | # $ test/process-table.sh timeout-issue
|
464 | timeout=()
|
465 | ;;
|
466 | test/nohup.sh)
|
467 | # Only run test/nohup.sh with TTY. For some reason build/py.sh all hangs
|
468 | # with $tty?
|
469 | stdin_tty=$tty
|
470 | ;;
|
471 | esac
|
472 |
|
473 | local -a argv=(
|
474 | time-tsv3 -o $tsv --append
|
475 | --field $task_name --field $script --field $action
|
476 | --field $result_html --
|
477 | "${timeout[@]}" "$script" "$action"
|
478 | )
|
479 |
|
480 | # Run task and save status
|
481 | set +o errexit
|
482 | if test -n "$stdin_tty"; then
|
483 | # explicitly connect TTY, e.g. for soil/interactive
|
484 | "${argv[@]}" > $log_path 2>&1 < $stdin_tty
|
485 | else
|
486 | # Temporary fix: build/doc.sh soil-run reads from stdin!
|
487 | "${argv[@]}" > $log_path 2>&1 < /dev/null
|
488 | fi
|
489 | status=$?
|
490 | set -o errexit
|
491 |
|
492 | if test "$status" -gt "$max_status"; then
|
493 | max_status=$status
|
494 | fi
|
495 |
|
496 | # Show the last line
|
497 | echo
|
498 | tsv-row status elapsed task script action result_html
|
499 | tail -n 1 $tsv
|
500 | echo
|
501 | log "status=$status max_status=$max_status"
|
502 | done
|
503 |
|
504 | log '--- done ---'
|
505 | ls -l $out_dir
|
506 | wc -l $out_dir/logs/*
|
507 |
|
508 | # This suppressed the deployment of logs, which we don't want. So all our
|
509 | # Travis builds succeed? But then we can't use their failure notifications
|
510 | # (which might be OK).
|
511 | if false; then
|
512 | # exit with the maximum exit code.
|
513 | awk '
|
514 | BEGIN { max = 0 }
|
515 | { if ($1 > max) { max = $1 } }
|
516 | END { exit(max) }
|
517 | ' $tsv
|
518 | fi
|
519 |
|
520 | # To fail later. Important: this dir persists across jobs; it's NOT removed
|
521 | # by 'host-shim.sh job-reset'.
|
522 | mkdir -p _soil-jobs
|
523 |
|
524 | # Hack: Assign job_id and write it to the status file. Other jobs can poll
|
525 | # for completion of this job and access its resources.
|
526 |
|
527 | local job_id
|
528 | job_id="$(date +%Y-%m-%d__%H-%M-%S)"
|
529 |
|
530 | # e.g. _soil-jobs/dummy.status.txt
|
531 | echo "$max_status $job_id" > _soil-jobs/$job_name.status.txt
|
532 | }
|
533 |
|
534 | save-metadata() {
|
535 | ### Write metadata files to be saved as JSON
|
536 |
|
537 | # NOTE: host-shim.sh also writes image-pull-time.txt
|
538 |
|
539 | local job_name=$1
|
540 | local meta_dir=$2
|
541 |
|
542 | echo "$job_name" > $meta_dir/job-name.txt
|
543 |
|
544 | # command to show current branch
|
545 | # This does NOT work in detached HEAD! Travis puts the branch in an env
|
546 | # variable, but sr.ht doesn't.
|
547 | # git rev-parse --abbrev-ref HEAD > $meta_dir/git-branch.txt
|
548 |
|
549 | git log -n 1 --pretty='format:%H' > $meta_dir/commit-hash.txt
|
550 |
|
551 | # ISO 8601 format
|
552 | # Note: this can get confused with rebases. Two different commits can have
|
553 | # the same date.
|
554 | git log -n 1 --pretty='format:%aI' > $meta_dir/commit-date.txt
|
555 |
|
556 | git log -n 1 --pretty='format:%s' > $meta_dir/commit-line.txt # "subject"
|
557 | }
|
558 |
|
559 | disable-git-errors() {
|
560 |
|
561 | # 2023-02: The build started failing because of the permissions we set in
|
562 | # soil/host-shim.sh mount-perms.
|
563 | #
|
564 | # The issue is that the guest needs to be able to write to the Docker mount
|
565 | # of the repo. I think it may have been related to podman vs. Docker.
|
566 | # Should check if mount-perms is necessary in both places.
|
567 | #
|
568 | # git fails unless we have this workaround.
|
569 |
|
570 | # https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor
|
571 |
|
572 | # https://github.blog/2022-04-12-git-security-vulnerability-announced/
|
573 |
|
574 | #git config --global --add safe.directory '*'
|
575 |
|
576 | git config --global --add safe.directory /home/uke/oil
|
577 | }
|
578 |
|
579 | job-main() {
|
580 | local job_name=$1
|
581 |
|
582 | local out_dir=_tmp/soil
|
583 |
|
584 | # Report for debugging
|
585 | export EXTRA_MYCPP_ARGS='--stack-roots-warn 16'
|
586 |
|
587 | log-context 'job-main'
|
588 | mkdir -v -p $out_dir
|
589 | ls -l -d $out_dir
|
590 |
|
591 | disable-git-errors
|
592 |
|
593 | save-metadata $job_name $out_dir
|
594 |
|
595 | local captured
|
596 |
|
597 | set +o errexit
|
598 | captured=$(tty)
|
599 | status=$?
|
600 | set -o errexit
|
601 |
|
602 | if test $status -eq 0; then
|
603 | echo "TTY = $captured"
|
604 | local tty=$captured
|
605 | else
|
606 | echo "captured = $captured"
|
607 | local tty='' # clear the output
|
608 | fi
|
609 | echo
|
610 |
|
611 | ${job_name}-tasks | run-tasks $job_name $out_dir "$tty"
|
612 | }
|
613 |
|
614 | JOB-dummy() { job-main 'dummy'; }
|
615 | JOB-raw-vm() { job-main 'raw-vm'; }
|
616 | JOB-dev-setup-debian() { job-main 'dev-setup-debian'; }
|
617 | JOB-dev-setup-fedora() { job-main 'dev-setup-fedora'; }
|
618 | JOB-dev-setup-alpine() { job-main 'dev-setup-alpine'; }
|
619 |
|
620 | JOB-dev-minimal() { job-main 'dev-minimal'; }
|
621 | JOB-interactive() { job-main 'interactive'; }
|
622 |
|
623 | JOB-other-tests() { job-main 'other-tests'; }
|
624 |
|
625 | JOB-pea() { job-main 'pea'; }
|
626 |
|
627 | JOB-ovm-tarball() { job-main 'ovm-tarball'; }
|
628 | JOB-app-tests() { job-main 'app-tests'; }
|
629 |
|
630 | JOB-cpp-coverage() { job-main 'cpp-coverage'; }
|
631 | JOB-cpp-small() { job-main 'cpp-small'; }
|
632 | JOB-cpp-tarball() { job-main 'cpp-tarball'; }
|
633 | JOB-cpp-spec() { job-main 'cpp-spec'; }
|
634 |
|
635 | JOB-bloaty() { job-main 'bloaty'; }
|
636 | JOB-benchmarks() { job-main 'benchmarks'; }
|
637 | JOB-benchmarks2() { job-main 'benchmarks2'; }
|
638 |
|
639 | JOB-wild() { job-main 'wild'; }
|
640 |
|
641 | JOB-maybe-merge() { job-main 'maybe-merge'; }
|
642 |
|
643 | list-jobs() {
|
644 | # dev-setup-fedora for Fedora, disable
|
645 | compgen -A function | grep -- '^JOB-' | sed 's/^JOB-//g' | egrep -v 'maybe-merge|dev-setup-fedora|dev-setup-alpine'
|
646 | }
|
647 |
|
648 | "$@"
|