1 | # Common functions for soil/
|
2 |
|
3 | # Include guard.
|
4 | test -n "${__SOIL_COMMON_SH:-}" && return
|
5 | readonly __SOIL_COMMON_SH=1
|
6 |
|
7 | log() {
|
8 | echo "$@" 1>&2
|
9 | }
|
10 |
|
11 | log-context() {
|
12 | local label=$1
|
13 |
|
14 | log ''
|
15 | log "$label: running as user '$(whoami)' on host '$(hostname)' in dir $PWD"
|
16 | log ''
|
17 | }
|
18 |
|
19 | dump-env() {
|
20 | env | grep -v '^encrypted_' | sort
|
21 | }
|
22 |
|
23 | if true; then
|
24 | readonly SOIL_USER='travis_admin'
|
25 | readonly SOIL_HOST='ci.oilshell.org'
|
26 | readonly SOIL_HOST_DIR=~/ci.oilshell.org # used on server
|
27 | readonly SOIL_REMOTE_DIR=ci.oilshell.org # used on client
|
28 | elif false; then
|
29 | readonly SOIL_USER='oils'
|
30 | readonly SOIL_HOST='mb.oils.pub'
|
31 | # Extra level
|
32 | readonly SOIL_HOST_DIR=~/www/mb.oils.pub # used on server
|
33 | readonly SOIL_REMOTE_DIR=www/mb.oils.pub # used on client
|
34 | else
|
35 | readonly SOIL_USER='oils'
|
36 | readonly SOIL_HOST='op.oils.pub'
|
37 | readonly SOIL_HOST_DIR=~/op.oils.pub # used on server
|
38 | readonly SOIL_REMOTE_DIR=op.oils.pub # used on client
|
39 | fi
|
40 |
|
41 | readonly SOIL_USER_HOST="$SOIL_USER@$SOIL_HOST"
|
42 |
|
43 | readonly WWUP_URL="https://$SOIL_HOST/uuu/wwup.cgi"
|
44 |
|
45 | html-head() {
|
46 | # TODO: Shebang line should change too
|
47 | PYTHONPATH=. python3 doctools/html_head.py "$@"
|
48 | }
|
49 |
|
50 | # NOTE: soil-html-head and table-sort-html-head are distinct, because they
|
51 | # collide with <td> styling and so forth
|
52 |
|
53 | soil-html-head() {
|
54 | local title="$1"
|
55 | local web_base_url=${2:-'/web'}
|
56 |
|
57 | html-head --title "$title" \
|
58 | "$web_base_url/base.css?cache=0" "$web_base_url/soil.css?cache=0"
|
59 | }
|
60 |
|
61 | table-sort-html-head() {
|
62 | local title="$1"
|
63 | local web_base_url=${2:-'/web'}
|
64 |
|
65 | html-head --title "$title" \
|
66 | "$web_base_url/base.css?cache=0" \
|
67 | "$web_base_url/ajax.js?cache=0" \
|
68 | "$web_base_url/table/table-sort.css?cache=0" "$web_base_url/table/table-sort.js?cache=0"
|
69 | }
|
70 |
|
71 | git-commit-dir() {
|
72 | local prefix=$1
|
73 |
|
74 | # written by save-metadata in soil/worker.sh
|
75 | local commit_hash
|
76 | commit_hash=$(cat _tmp/soil/commit-hash.txt)
|
77 |
|
78 | local git_commit_dir="$SOIL_REMOTE_DIR/code/${prefix}jobs/git-$commit_hash"
|
79 |
|
80 | echo $git_commit_dir
|
81 | }
|
82 |
|
83 | git-commit-url() {
|
84 | local prefix=$1
|
85 |
|
86 | # written by save-metadata in soil/worker.sh
|
87 | local commit_hash
|
88 | commit_hash=$(cat _tmp/soil/commit-hash.txt)
|
89 |
|
90 | # https:// not working on Github Actions because of cert issues?
|
91 | local url="https://$SOIL_HOST/code/${prefix}jobs/git-$commit_hash"
|
92 |
|
93 | echo $url
|
94 | }
|