-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathrun-protocol-matrix.sh
More file actions
executable file
·66 lines (57 loc) · 1.62 KB
/
run-protocol-matrix.sh
File metadata and controls
executable file
·66 lines (57 loc) · 1.62 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
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TABLE_MODE="${ACP_PROTOCOL_MATRIX_TABLE_MODE:-capabilities}"
SKIP_AGENTS="${ACP_PROTOCOL_MATRIX_SKIP_AGENTS:-}"
KEEP_STATE="${ACP_PROTOCOL_MATRIX_KEEP_STATE:-0}"
SANDBOX_DIR="${ACP_PROTOCOL_MATRIX_SANDBOX_DIR:-}"
TEMP_STATE_DIR=""
TEMP_SANDBOX_DIR=""
TEMP_SANDBOX_ROOT="$ROOT/.matrix-sandbox/.tmp"
TEMP_STATE_ROOT="$ROOT/.docker-state/.tmp"
cleanup() {
if [[ -n "$TEMP_SANDBOX_DIR" ]]; then
rm -rf "$TEMP_SANDBOX_DIR"
fi
if [[ -n "$TEMP_STATE_DIR" ]]; then
rm -rf "$TEMP_STATE_DIR"
fi
}
if [[ -z "$SANDBOX_DIR" ]]; then
if [[ "$KEEP_STATE" == "1" ]]; then
SANDBOX_DIR=".matrix-sandbox"
else
mkdir -p "$TEMP_SANDBOX_ROOT"
TEMP_SANDBOX_DIR="$(mktemp -d "$TEMP_SANDBOX_ROOT/protocol-matrix-sandbox.XXXXXX")"
SANDBOX_DIR="${TEMP_SANDBOX_DIR#"$ROOT"/}"
fi
fi
ARGS=(
python3
.github/workflows/protocol_matrix.py
--sandbox-dir
"$SANDBOX_DIR"
--output-dir
.protocol-matrix
--init-timeout
120
--rpc-timeout
5
--table-mode
"$TABLE_MODE"
)
if [[ -n "$SKIP_AGENTS" ]]; then
ARGS+=(--skip-agent "$SKIP_AGENTS")
fi
if [[ -z "${ACP_REGISTRY_STATE_DIR:-}" && "$KEEP_STATE" != "1" ]]; then
mkdir -p "$TEMP_STATE_ROOT"
TEMP_STATE_DIR="$(mktemp -d "$TEMP_STATE_ROOT/protocol-matrix-state.XXXXXX")"
fi
if [[ -n "$TEMP_SANDBOX_DIR" || -n "$TEMP_STATE_DIR" ]]; then
trap cleanup EXIT
fi
if [[ -n "$TEMP_STATE_DIR" ]]; then
export ACP_REGISTRY_STATE_DIR="${TEMP_STATE_DIR#"$ROOT"/}"
fi
"$SCRIPT_DIR/run-registry-docker.sh" "${ARGS[@]}" "$@"