Repository navigation
129 lines (125 loc) · 6.65 KB
/
Copy pathtest.yml
File metadata and controls
129 lines (125 loc) · 6.65 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
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
name: tests
on:
pull_request:
push:
branches: [main]
jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install pytest "httpx[socks]" truststore ruamel.yaml "opengradient-ohttp>=0.1,<0.2"
- run: pytest tests/ -q
# The real thing: install ghost the way a user does, use it before logging in, and check the engine it built.
engine:
name: engine (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
GHOST_NO_BROWSER: "1"
PYTHONUTF8: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install pytest "httpx[socks]" truststore ruamel.yaml "opengradient-ohttp>=0.1,<0.2"
- name: Install ghost
if: runner.os != 'Windows'
run: set -o pipefail; ./install.sh | tee "$HOME/install.txt"
shell: bash
- name: Install ghost (Windows)
if: runner.os == 'Windows'
shell: powershell
run: .\install.ps1 | Tee-Object -FilePath "$HOME\install.txt"; if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Use it before logging in
shell: bash
run: |
cd "$HOME"
case "$RUNNER_OS" in Windows) ghost() { cmd //c "$(cygpath -w "$HOME/.local/bin/$1.cmd")" "${@:2}"; } ;; *) ghost() { "$HOME/.local/bin/$1" "${@:2}"; } ;; esac
ghost ghost --version | tee version; grep -q "^Ghost v" version
curl -fs http://127.0.0.1:8788/healthz
if grep -E "✓ Starting the background service [0-9]{2,}s" "$HOME/install.txt"; then exit 1; fi # it takes a moment, not half a minute
started=$SECONDS
if ghost ghost -z hi </dev/null >out 2>&1; then exit 1; fi
cat out; grep -q "not logged in" out; test $((SECONDS - started)) -lt 15
if ghost ghost-login --status; then exit 1; fi
if echo df_sk_not_a_real_key | ghost ghost-login --with-api-key; then exit 1; fi
ghost ghost usage
token=$(sed -n 's/^ api_key: \([0-9a-f]\{40\}\).*$/\1/p' "$HOME/.ghost/profiles/uncensored/config.yaml"); test -n "$token"
post() { curl -s -o reply -w '%{http_code}' http://127.0.0.1:8788/v1/chat/completions -H 'content-type: application/json' "$@" \
-d '{"model": "abliteration/abliterated-model-large-v2", "messages": [{"role": "user", "content": "hi"}]}'; }
test "$(post)" = 403 # the bridge answers this ghost only
test "$(post -H "Authorization: Bearer $token")" = 401; cat reply
- name: Log in and use it, against a stand-in for DreamFort
shell: bash
run: |
case "$RUNNER_OS" in Windows) py="$HOME/.ghost/venv/Scripts/python.exe" ;; *) py="$HOME/.ghost/venv/bin/python" ;; esac
"$py" tests/e2e.py
- name: Update over it, with the background gateway running
if: runner.os != 'Windows'
run: |
ghost="$HOME/.local/bin/ghost"
pid() { python -c "import json, pathlib; print(json.loads((pathlib.Path.home() / '.ghost/profiles/uncensored/gateway_state.json').read_text())['pid'])"; }
profile="$HOME/.ghost/profiles/uncensored"; echo "# mine" >> "$profile/SOUL.md"; "$ghost" config set display.show_reasoning true
"$ghost" gateway install --start-now --start-on-login
sleep 15; "$ghost" gateway status; before="$(pid)"; kill -0 "$before"
if ps -o command= -p "$before" | grep -e --idle-exit; then exit 1; fi # it's not the one the chat left running
started=$SECONDS; ./install.sh # nothing new: the engine isn't built again, and the gateway is left alone
grep -q "already this build" "$HOME/.ghost/install.log"; echo "took $((SECONDS - started))s"; test $((SECONDS - started)) -lt 30
test "$(pid)" = "$before"; kill -0 "$before"
GHOST_FORCE=1 GHOST_VERBOSE=1 ./install.sh
sleep 15; "$ghost" gateway status; after="$(pid)"; kill -0 "$after"
if ps -o command= -p "$after" | grep -e --idle-exit; then exit 1; fi
test "$before" != "$after"; if kill -0 "$before" 2>/dev/null; then exit 1; fi
test ! -e "$HOME/.ghost/.restart-gateway"
grep -q "# mine" "$profile/SOUL.md"; grep -q "show_reasoning: true" "$profile/config.yaml"; if ls "$profile"/*.prev*; then exit 1; fi
curl -fs http://127.0.0.1:8788/healthz
- name: Check the engine
shell: bash
# Naming the engine makes these fail, not skip, when it isn't the pinned build.
run: GHOST_ENGINE="$HOME/.ghost-engine" GHOST_HOME="$HOME/.ghost" pytest -q tests/test_engine.py tests/test_fork_engine.py tests/test_migrate_skills.py tests/test_login.py tests/test_launch.py tests/test_install.py
- name: Uninstall
shell: bash
run: |
cd "$HOME"
case "$RUNNER_OS" in Windows) cmd //c "$(cygpath -w "$HOME/.local/bin/ghost.cmd")" uninstall --yes ;; *) "$HOME/.local/bin/ghost" uninstall --yes ;; esac
sleep 3
test ! -e "$HOME/.ghost-engine"; test ! -e "$HOME/.ghost/venv"; test -e "$HOME/.ghost/profiles/uncensored/config.yaml"
(ls "$HOME/.local/bin" 2>/dev/null || true) | tee left # (removed too, if it was only ghost's)
if grep -q "^ghost" left; then exit 1; fi
if curl -fs --max-time 3 http://127.0.0.1:8788/healthz; then exit 1; fi
# A bare machine: no Python, no service manager, and the one-line command rather than a checkout.
bare:
name: one-line install (bare Debian)
runs-on: ubuntu-latest
container: debian:stable-slim
timeout-minutes: 30
env:
GHOST_NO_BROWSER: "1"
steps:
- run: apt-get update -qq && apt-get install -qqy curl git ca-certificates >/dev/null
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install, use and remove it
run: |
export HOME=/root
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git init -q --bare -b main /tmp/released && git push -q /tmp/released HEAD:refs/heads/main
git clone -q /tmp/released "$HOME/.ghost-src"
cd / && bash < "$GITHUB_WORKSPACE/install.sh"
ghost="$HOME/.local/bin/ghost"
"$ghost" --version
if "$ghost" -z hi </dev/null >out 2>&1; then exit 1; fi; cat out; grep -q "not logged in" out
curl -fs http://127.0.0.1:8788/healthz
"$ghost" update
"$ghost" uninstall --yes
test ! -e "$HOME/.ghost-engine" && test ! -e "$ghost" && test ! -e "$HOME/.ghost-src"