-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (124 loc) · 4.31 KB
/
Copy pathci.yml
File metadata and controls
139 lines (124 loc) · 4.31 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
name: Cross-Session Memory CI
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
jobs:
test:
name: Test (PostgreSQL ${{ matrix.postgres-version }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
postgres-version: [14, 16]
env:
DATABASE_URL: postgresql://postgres:test@localhost:5432/opencode_memory
CSM_DATABASE_URL: postgresql://postgres:test@localhost:5432/opencode_memory
CSM_PG_BIN: /usr/lib/postgresql/${{ matrix.postgres-version }}/bin
PGHOST: localhost
PGPORT: "5432"
PGUSER: postgres
PGPASSWORD: test
PGDATABASE: opencode_memory
services:
postgres:
image: pgvector/pgvector:0.8.2-pg${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: test
POSTGRES_DB: opencode_memory
options: >-
--health-cmd "pg_isready -U postgres -d opencode_memory"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@9f698171ed81b15d1823a05fc7211befd50c8ae0 # v6.0.3
- name: Setup Node.js
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '22.22.2'
- name: Install dependencies
run: npm ci
- name: Install PostgreSQL client tools
run: |
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl --fail --silent --show-error \
-o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
https://www.postgresql.org/media/keys/ACCC4CF8.asc
. /etc/os-release
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
| sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null
sudo apt-get update
sudo apt-get install -y postgresql-client-${{ matrix.postgres-version }}
- name: Wait for PostgreSQL
run: |
set -euo pipefail
ready=false
for attempt in $(seq 1 60); do
if pg_isready \
-h "$PGHOST" \
-p "$PGPORT" \
-U "$PGUSER" \
-d "$PGDATABASE" >/dev/null 2>&1; then
ready=true
echo "PostgreSQL is ready after ${attempt} attempt(s)"
break
fi
echo "PostgreSQL readiness attempt ${attempt}/60 failed"
sleep 1
done
if [ "$ready" != true ]; then
echo "PostgreSQL did not become ready" >&2
exit 1
fi
psql \
-v ON_ERROR_STOP=1 \
-h "$PGHOST" \
-p "$PGPORT" \
-U "$PGUSER" \
-d "$PGDATABASE" \
-c 'SELECT current_user, current_database(), version();'
- name: Typecheck
run: npm run typecheck
- name: Build
run: npm run build
- name: Initialize database schema
run: |
set -euo pipefail
npm run db:setup 2>&1 | tee db.setup.log
- name: Lint source
run: npm run lint:src
- name: Run tests
run: |
set -euo pipefail
npm run test 2>&1 | tee test.log
- name: Database diagnostics on failure
if: failure()
run: |
echo "=== PostgreSQL identity ==="
psql -v ON_ERROR_STOP=1 -c 'SELECT current_user, current_database(), version();' || true
echo "=== Tables ==="
psql -v ON_ERROR_STOP=1 -c '\dt' || true
echo "=== Schema migration ledger ==="
psql -v ON_ERROR_STOP=1 -c 'SELECT * FROM schema_migrations ORDER BY applied_at, id;' || true
echo "=== Test log tail ==="
tail -n 500 test.log || true
- name: Run isolated backup and restore drill
run: npm run drill:backup-restore
- name: Upload CI logs
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ci-logs-pg${{ matrix.postgres-version }}
path: |
db.setup.log
test.log
if-no-files-found: warn
retention-days: 7