-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·101 lines (90 loc) · 2.88 KB
/
bootstrap.sh
File metadata and controls
executable file
·101 lines (90 loc) · 2.88 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
#!/usr/bin/env bash
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap
repo_root=$(git rev-parse --show-toplevel)
export BB=${BB:-$repo_root/barretenberg/cpp/build/bin/bb}
export NARGO=${NARGO:-$repo_root/noir/noir-repo/target/release/nargo}
export TRANSPILER=${TRANSPILER:-$repo_root/avm-transpiler/target/release/avm-transpiler}
export BB_HASH=${BB_HASH:-$($repo_root/barretenberg/cpp/bootstrap.sh hash)}
# We search the docs/*.md files to find included code, and use those as our rebuild dependencies.
# We prefix the results with ^ to make them "not a file", otherwise they'd be interpreted as pattern files.
hash=$(
cache_content_hash \
.rebuild_patterns \
$(find docs docs-developers docs-operate docs-participate developer_versioned_docs network_versioned_docs -type f -name "*.md*" -exec grep '^#include_code' {} \; | \
awk '{ gsub("^/", "", $3); print "^" $3 }' | sort -u)
)
if semver check $REF_NAME; then
# Ensure that released versions don't use cache from non-released versions (they will have incorrect links to master)
hash+=$REF_NAME
export COMMIT_TAG=$REF_NAME
fi
function build_docs {
if [ "${CI:-0}" -eq 1 ] && [ $(arch) == arm64 ]; then
echo "Not building docs for arm64 in CI."
return
fi
echo_header "build docs"
npm_install_deps
if cache_download docs-$hash.tar.gz; then
return
fi
denoise "yarn build"
cache_upload docs-$hash.tar.gz build
}
function test_cmds {
if [ "${CI:-0}" -eq 1 ] && [ $(arch) == arm64 ]; then
# Not running docs tests for arm64 in CI.
return
fi
local test_hash=$hash
echo "$test_hash cd docs && yarn spellcheck"
# Delegate to examples for their test commands
(cd examples && ./bootstrap.sh test_cmds)
}
function test {
echo_header "docs test"
test_cmds | parallelize
}
function check_references {
if [[ "${GITHUB_EVENT_NAME:-}" != "merge_group" ]]; then
echo "Skipping doc reference check (only runs in merge queue)."
return
fi
echo_header "Check doc references"
if ! ./scripts/check_doc_references.sh docs; then
echo "⚠ Doc reference check failed (non-blocking)."
if [[ -n "${SLACK_BOT_TOKEN:-}" ]]; then
curl -s -X POST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-type: application/json" \
-d "{\"channel\": \"#devrel-docs-updates\", \"text\": \"⚠️ Doc reference check script failed for ref \`${GITHUB_REF_NAME:-unknown}\`. Check CI logs.\"}" \
> /dev/null 2>&1 || true
fi
fi
}
function build_examples {
echo_header "Building examples"
(cd examples && ./bootstrap.sh "$@")
}
case "$cmd" in
"ci")
build_examples
build_docs
test
check_references
;;
"")
build_examples
build_docs
check_references
;;
"hash")
echo "$hash"
;;
"compile")
build_examples compile "$@"
;;
*)
default_cmd_handler "$@"
;;
esac