-
Notifications
You must be signed in to change notification settings - Fork 0
366 lines (340 loc) Β· 14.1 KB
/
Copy pathci.yml
File metadata and controls
366 lines (340 loc) Β· 14.1 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
name: π§ͺ CI β Lint & Health
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
ci:
name: Node ${{ matrix.node }} on ubuntu-latest
runs-on: ubuntu-latest
strategy:
matrix:
node: ['20', '22']
fail-fast: false
steps:
- name: β¬οΈ Checkout
uses: actions/checkout@v4
- name: π’ Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# ββ Shell syntax checks ββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π Shell syntax check (bash -n)
run: |
set -euo pipefail
FAIL=0
for f in \
setup.sh \
setup-termux-widget.sh \
install-termux.sh \
update.sh \
start.sh \
doctor.sh \
bin/isotope; do
if [ -f "$f" ]; then
if bash -n "$f" 2>/dev/null; then
echo "β
$f"
else
echo "β $f β syntax error"
bash -n "$f" || true
FAIL=1
fi
else
echo "β οΈ $f β not found (skipping)"
fi
done
[ "$FAIL" -eq 0 ] || exit 1
- name: π ShellCheck
run: |
set -euo pipefail
if ! command -v shellcheck >/dev/null 2>&1; then
echo "Installing shellcheck..."
sudo apt-get install -y shellcheck >/dev/null 2>&1
fi
echo "shellcheck $(shellcheck --version | head -2 | tail -1)"
FAIL=0
for f in \
setup.sh \
setup-termux-widget.sh \
install-termux.sh \
update.sh \
start.sh \
doctor.sh \
bin/isotope; do
if [ -f "$f" ]; then
# SC1090: can't follow sourced file β expected in this codebase
# SC1091: not following include β expected
# SC2148: no shebang for sourced files β not applicable
if shellcheck -x -e SC1090,SC1091 "$f"; then
echo "β
$f"
else
echo "β οΈ $f β shellcheck warnings (non-fatal for now)"
fi
else
echo "β οΈ $f β not found (skipping)"
fi
done
# ShellCheck is advisory in CI for now β uncomment to make it block:
# [ "$FAIL" -eq 0 ] || exit 1
# ββ Node syntax ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: β
Node.js syntax checks
run: |
set -euo pipefail
files=(
server.mjs
server/backup-manager.mjs
public/sync/backup-normalizer.js
public/sync/local-data-adapter.js
scripts/storage-backup-lib.mjs
scripts/validate-backup-files.mjs
scripts/repair-user-backup.mjs
scripts/prove-new-browser-restore.mjs
scripts/validate-storage-cleanup.mjs
scripts/verify-supabase-security.mjs
scripts/validate-docs.mjs
scripts/compare-remote-assets.mjs
)
for f in "${files[@]}"; do
node --check "$f"
echo "β
$f"
done
- name: π§ͺ Backup normalizer safety smoke
run: |
set -euo pipefail
node --input-type=module <<'NODE'
import assert from 'node:assert/strict';
import {
normalizeAnyBackup,
isBackupRich,
isBackupEmpty,
compareBackupCandidates,
mergeBackupData,
} from './public/sync/backup-normalizer.js';
const rich = normalizeAnyBackup({
version: 1,
source: 'isotopeai',
exportedAt: '2026-06-01T00:00:00.000Z',
data: {
profile: { name: 'rich' },
timerState: null,
tasks: [{ id: 'task-1', updatedAt: '2026-06-01T00:00:00.000Z' }],
sessions: [{ id: 'session-1', updatedAt: '2026-06-01T00:00:00.000Z' }],
subjects: [{ id: 'subject-1', updatedAt: '2026-06-01T00:00:00.000Z' }],
habits: [],
dailyLogs: [],
tests: [],
exams: [],
mockTests: [],
},
}, { source_path: 'imports/latest.json' });
const emptyNewer = normalizeAnyBackup({
schema_version: 1,
exported_at: '2026-06-11T00:00:00.000Z',
profile_data: { name: 'empty' },
backup_data: {
profile: { name: 'empty' },
tasks: [],
sessions: [],
subjects: [],
habits: [],
dailyLogs: [],
tests: [],
exams: [],
mockTests: [],
},
}, { source_path: 'cloud-snapshot/latest.json' });
assert.equal(isBackupRich(rich), true);
assert.equal(isBackupEmpty(emptyNewer), true);
assert.equal(compareBackupCandidates(
{ normalized: rich, exported_at: rich.exported_at, size_bytes: rich.size },
{ normalized: emptyNewer, exported_at: emptyNewer.exported_at, size_bytes: emptyNewer.size },
), 1, 'rich backup must beat newer empty backup');
const merged = mergeBackupData(emptyNewer, rich);
assert.equal(merged.tasks.length, 1);
assert.equal(merged.sessions.length, 1);
assert.equal(merged.subjects.length, 1);
console.log('β
backup normalizer protects rich data from empty overwrite');
NODE
# ββ Required files βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π Required files present
run: |
set -euo pipefail
FAIL=0
REQUIRED=(
server.mjs
package.json
setup.sh
setup.bat
install.ps1
install-termux.sh
setup-termux-widget.sh
update.sh
update.bat
start.sh
start.bat
doctor.sh
doctor.bat
bin/isotope
bin/isotope.bat
isotope-complete.sql
community-patch-v4.sql
sql/006_security_policy_cleanup.sql
sql/backup_manifests.sql
sql/verify-security.sql
.env.example
README.md
ADMIN.md
CHANGELOG.md
TERMUX_WIDGET.md
docs/sync-system.md
docs/storage-backup-system.md
docs/supabase-connection-map.md
public/sync/backup-normalizer.js
public/sync/local-data-adapter.js
scripts/validate-backup-files.mjs
scripts/repair-user-backup.mjs
scripts/prove-new-browser-restore.mjs
scripts/validate-storage-cleanup.mjs
scripts/verify-supabase-security.mjs
scripts/compare-remote-assets.mjs
server/backup-manager.mjs
)
for f in "${REQUIRED[@]}"; do
if [ -f "$f" ]; then
echo "β
$f"
else
echo "β $f β MISSING"
FAIL=1
fi
done
[ "$FAIL" -eq 0 ] || exit 1
# ββ No hardcoded secrets βββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π No hardcoded secrets
run: |
set -euo pipefail
if git ls-files --error-unmatch .env >/dev/null 2>&1; then
echo "β .env is tracked; remove it before release"
exit 1
fi
if git grep -nE 'SUPABASE_SERVICE_ROLE_KEY[[:space:]]*=[[:space:]]*eyJ|SUPABASE_ACCESS_TOKEN[[:space:]]*=[[:space:]]*sbp_|ADMIN_SECRET[[:space:]]*=[[:space:]]*[A-Za-z0-9_-]{24,}' -- \
':!*.md' ':!.env.example' ':!public/assets/**'; then
echo "β Hardcoded private secret detected!"
exit 1
fi
echo "β
No hardcoded secrets"
# ββ Schema stats βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π Schema file stats
run: |
set -euo pipefail
for f in isotope-complete.sql community-patch-v4.sql sql/006_security_policy_cleanup.sql sql/backup_manifests.sql sql/verify-security.sql performance-patch.sql; do
if [ -f "$f" ]; then
echo "=== $f ==="
echo " Size : $(wc -c < "$f") bytes"
echo " Lines : $(wc -l < "$f")"
echo " Tables : $(awk '/CREATE TABLE/{n++} END{print n+0}' "$f")"
echo " Funcs : $(awk '/CREATE OR REPLACE FUNCTION/{n++} END{print n+0}' "$f")"
echo " Policies: $(awk '/CREATE POLICY/{n++} END{print n+0}' "$f")"
else
echo "β οΈ $f not found β skipping"
fi
done
# ββ Termux simulation βββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π± Termux simulation β platform detection
run: |
set -euo pipefail
echo "Checking Termux scripts without running installers..."
bash -n setup.sh
bash -n install-termux.sh
bash -n setup-termux-widget.sh
bash -n bin/isotope
grep -q 'TERMUX_VERSION' setup.sh install-termux.sh
echo "β
Termux scripts parse and contain Termux detection"
# ββ Smoke test ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π Smoke test β server starts and responds
run: |
set -uo pipefail
SUPABASE_URL=https://placeholder.supabase.co \
SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiYW5vbiJ9.signature \
SESSION_SECRET=ci_smoke_test_secret_not_real \
ADMIN_SECRET=ci_admin_placeholder \
NODE_ENV=test \
PORT=3099 \
node server.mjs &
SERVER_PID=$!
echo "Server PID: $SERVER_PID β polling /__isotope/ping..."
STATUS="000"
for i in $(seq 1 40); do
sleep 0.5
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
http://127.0.0.1:3099/__isotope/ping 2>/dev/null || echo "000")
if [ "$STATUS" = "200" ]; then
echo " HTTP $STATUS after ${i} attempts"
break
fi
printf ' Attempt %d: waiting...\n' "$i"
done
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
echo "Final health status: $STATUS"
if [ "$STATUS" != "200" ]; then
echo "β Server ping did not return 200 (got: $STATUS)"
exit 1
fi
echo "β
Server started and ping returned HTTP 200"
# ββ Release zip simulation ββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π¦ Release zip β build + verify extract
run: |
set -euo pipefail
VERSION="$(node -e "process.stdout.write(require('./package.json').version)")"
echo "Building release zip for v$VERSION..."
zip -qr "isotope-v${VERSION}-ci-test.zip" . \
--exclude ".git/*" \
--exclude "node_modules/*" \
--exclude ".env" \
--exclude "*.log" \
--exclude ".github/*" \
--exclude "screenshots/*" \
--exclude "*.zip"
echo "Archive: $(wc -c < "isotope-v${VERSION}-ci-test.zip") bytes"
# Extract to a fresh dir and check required files are present
TMPDIR="$(mktemp -d)"
unzip -q "isotope-v${VERSION}-ci-test.zip" -d "$TMPDIR"
echo "Verifying extracted release..."
FAIL=0
for f in server.mjs package.json setup.sh install-termux.sh bin/isotope .env.example public/sync/backup-normalizer.js public/sync/local-data-adapter.js server/backup-manager.mjs scripts/prove-new-browser-restore.mjs sql/backup_manifests.sql docs/sync-system.md docs/storage-backup-system.md docs/supabase-connection-map.md; do
if [ -f "$TMPDIR/$f" ]; then
echo " β
$f"
else
echo " β $f β missing from zip"
FAIL=1
fi
done
rm -rf "$TMPDIR" "isotope-v${VERSION}-ci-test.zip"
[ "$FAIL" -eq 0 ] || exit 1
echo "β
Release zip contains all required files"
# ββ Docs validation ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π Docs + README validation
run: |
set -euo pipefail
node scripts/validate-docs.mjs || {
echo "β οΈ Docs validation had errors β see output above"
exit 1
}
# ββ Upload logs on failure ββββββββββββββββββββββββββββββββββββββββββββββββ
- name: π€ Upload CI logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ci-logs-node${{ matrix.node }}-${{ github.run_id }}
path: |
~/.isotope/logs/
/tmp/isotope-ci-*.log
if-no-files-found: ignore
retention-days: 7