Repository navigation
169 lines (158 loc) · 6.21 KB
/
Copy pathci.yml
File metadata and controls
169 lines (158 loc) · 6.21 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# The installer is shell, so the matrix is the point: it is the only thing
# that catches a path assumption which happens to hold on the maintainer's
# machine. Windows matters most here, because Git Bash has no install(1) and
# no /usr/bin/opencode.
test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- name: Linux x86_64
os: ubuntu-latest
- name: Linux aarch64
os: ubuntu-24.04-arm
- name: macOS arm64
os: macos-latest
- name: macOS x86_64
os: macos-15-intel
- name: Windows (Git Bash)
os: windows-latest
steps:
- uses: actions/checkout@v4
# Git Bash exposes `python`, not `python3`. Shim it so the suite can use
# one name everywhere.
- name: Shim python3 on Windows
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p "$HOME/bin"
printf '#!/bin/sh\nexec python "$@"\n' >"$HOME/bin/python3"
chmod +x "$HOME/bin/python3"
echo "$HOME/bin" >>"$GITHUB_PATH"
- name: Toolchain versions
shell: bash
run: |
bash --version | head -1
python3 --version
command -v curl || echo "note: no curl, the bootstrap test will skip"
- name: shellcheck
shell: bash
run: |
if ! command -v shellcheck >/dev/null; then
echo "shellcheck unavailable, skipping"
exit 0
fi
shellcheck -S warning install.sh bin/ai-sync hooks/*.sh tests/run-tests.sh
- name: Run test suite
shell: bash
run: bash tests/run-tests.sh
# A device with neither tool installed is the case the installer's fallbacks
# exist for, and it cannot be simulated on a runner that already has both.
bare:
name: No tools installed (degraded paths)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install without opencode or claude present
shell: bash
run: |
# A HOME with no .opencode and no .claude, and a PATH with neither
# binary. Must exit 0, warn, and skip the wrapper.
fake="$(mktemp -d)"
mkdir -p "$fake/bin"
out="$(env -i HOME="$fake" PATH="$fake/bin:/usr/bin:/bin" \
bash install.sh 2>&1)" || {
echo "installer failed on a bare device:"; echo "$out"; exit 1;
}
echo "$out"
grep -q "no real opencode found" <<<"$out" || {
echo "expected a warning about the missing opencode binary"; exit 1; }
grep -q "skipping wrapper" <<<"$out" || {
echo "expected the wrapper to be skipped"; exit 1; }
# Which directory it lands in depends on PATH order -- the installer
# takes the first writable entry -- so look for it rather than
# assuming ~/.local/bin.
find "$fake" -type f -name ai-sync | grep -q . || {
echo "ai-sync should still install"; exit 1; }
find "$fake" -type f -name opencode | grep -q . && {
echo "wrapper must not be installed without a binary to wrap"; exit 1; }
echo "bare device handled correctly"
# Real aarch64 Android userspace. This is the closest CI can get to the
# Termux/iOS leg: same aarch64 Linux userland, same bionic-not-glibc and
# missing-coreutils assumptions. Marked non-blocking because the image needs
# network access for pkg, which is outside our control.
#
# Note: the image is termux/termux-docker, not termux/termux-user, which does
# not exist on Docker Hub and fails the job with a confusing pull error.
termux:
name: Termux userland (aarch64, best effort)
runs-on: ubuntu-24.04-arm
timeout-minutes: 25
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Run the suite inside a Termux rootfs
shell: bash
run: |
set -euo pipefail
docker run --rm --platform linux/arm64 \
-v "$PWD:/work" -w /work \
termux/termux-docker:latest \
bash -lc '
set -e
export HOME=/data/data/com.termux/files/home
mkdir -p "$HOME"
pkg update -y
# termux-exec provides libtermux-exec, the shebang rewriter.
# Without it a #!/usr/bin/env bash script cannot be exec"d at
# all, which takes out the installer'"'"'s own wrapper. This is
# the same prerequisite docs/claude-code-transcript-format.md
# §11 and hooks/install-termux-shell-shim.sh describe.
pkg install -y python termux-exec
# Two assertions exec the installed wrapper directly. Inside this
# container the shebang rewriter is not active for a directly
# exec'"'"'d script, so #!/usr/bin/env bash cannot resolve and env
# reports the script as missing. Container-specific, covered on
# the other four legs; this keeps the leg red on any *new* failure
# instead of permanently red on a known divergence.
export AISYNC_SKIP_WRAPPER_EXEC=1
bash tests/run-tests.sh
'
python:
name: Module sanity (no installer)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Compile and import
run: |
python3 -m py_compile src/*.py
python3 - <<'PY'
import sys
sys.path.insert(0, "src")
import aisync, oc2cc, cc2oc
# Store paths must be derived, never absolute literals.
for path in (aisync.STATE_DIR, oc2cc.DB, cc2oc.LEDGER):
assert path.startswith("/"), path
assert "/home/" not in path or path.count("/home/") == 1, path
print("modules import cleanly; store paths:", oc2cc.DB)
PY