-
Notifications
You must be signed in to change notification settings - Fork 8
279 lines (248 loc) · 7.98 KB
/
compatibility.yaml
File metadata and controls
279 lines (248 loc) · 7.98 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
name: compatibility.yaml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ main ]
workflow_dispatch: { }
schedule:
- cron: "0 0 * * *" # daily at midnight UTC
workflow_run:
workflows: ["Release"]
types:
- completed
jobs:
e2e:
name: E2E ${{ matrix.os }}
environment: e2e-${{ matrix.os }}
runs-on: ${{ matrix.os }}
# Skip this job for version bump commits (binary won't exist yet)
if: "!contains(github.event.head_commit.message, 'Release')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
db:
- mysql: 8
- mysql: 5.7
- mysql: 5.6
- postgres: 16
- postgres: 15
- postgres: 14
- postgres: 13
- postgres: 12
# Only run database tests on ubuntu-latest to save CI time
exclude:
- os: macos-latest
db: { mysql: 5.7 }
- os: macos-latest
db: { mysql: 5.6 }
- os: macos-latest
db: { postgres: 15 }
- os: macos-latest
db: { postgres: 14 }
- os: macos-latest
db: { postgres: 13 }
- os: macos-latest
db: { postgres: 12 }
- os: windows-latest
db: { mysql: 5.7 }
- os: windows-latest
db: { mysql: 5.6 }
- os: windows-latest
db: { postgres: 15 }
- os: windows-latest
db: { postgres: 14 }
- os: windows-latest
db: { postgres: 13 }
- os: windows-latest
db: { postgres: 12 }
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Build docker-compose services for integration tests (Linux only)
if: runner.os == 'Linux'
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 5
attempt_delay: 5000
command: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
MYSQL_MIGRATION_FILE: "${{ matrix.db.mysql == '5.6' && 'mysql_migration_5_6.sql' || 'mysql_migration.sql' }}"
- name: Wait for databases to be ready (Linux only)
if: runner.os == 'Linux'
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '10'
- name: Check docker-compose services (Linux only)
if: runner.os == 'Linux'
run: docker ps -a
- name: Install sqlx-ts from npm
working-directory: ./node
run: npm install
- name: Verify sqlx-ts installation
working-directory: ./node
shell: bash
run: |
./sqlx-ts --version
./sqlx-ts --help
- name: Create test directory
shell: bash
run: mkdir -p tests/staging
- name: Add failure.ts test file (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
cat << 'EOF' > tests/staging/failure.ts
import { sql } from 'sqlx-ts'
const selectSql4 = sql`
SELECT itemz.*
FROM items;
`
EOF
- name: Run failure test (Linux only)
if: runner.os == 'Linux'
working-directory: ./node
shell: bash
run: |
set +e
./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "Expected failure, but command succeeded."
exit 1
fi
echo "Command failed as expected with exit code $EXIT_CODE."
- name: Remove failure test file
if: runner.os == 'Linux'
shell: bash
run: rm -f tests/staging/failure.ts
- name: Add happy.ts test file (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
cat << 'EOF' > tests/staging/happy.ts
import { sql } from 'sqlx-ts'
const selectSql4 = sql`
SELECT items.*
FROM items;
`
EOF
- name: Run happy test (Linux only)
if: runner.os == 'Linux'
working-directory: ./node
shell: bash
run: ./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging
- name: Test sqlx-ts on ${{ matrix.os }} (no database)
if: runner.os != 'Linux'
working-directory: ./node
shell: bash
run: |
echo "✅ sqlx-ts successfully installed and runs on ${{ matrix.os }}"
./sqlx-ts --version
./sqlx-ts --help
e2e-linux-distros:
name: E2E linux distro ${{ matrix.distro }}
environment: e2e-linux-distros
runs-on: ubuntu-latest
# Skip this job for version bump commits (binary won't exist yet)
if: "!contains(github.event.head_commit.message, 'Release')"
strategy:
fail-fast: false
matrix:
distro:
- ubuntu:20.04
- ubuntu:22.04
- ubuntu:24.04
- debian:11
- debian:12
- alpine:3.18
- alpine:3.19
- fedora:38
- fedora:39
- archlinux:latest
db:
- mysql: 8
- postgres: 16
# Test fewer combinations to save CI time
exclude:
- distro: ubuntu:20.04
db: { postgres: 16 }
- distro: ubuntu:22.04
db: { postgres: 16 }
- distro: debian:11
db: { postgres: 16 }
- distro: debian:12
db: { mysql: 8 }
- distro: alpine:3.18
db: { postgres: 16 }
- distro: alpine:3.19
db: { mysql: 8 }
- distro: fedora:38
db: { postgres: 16 }
- distro: fedora:39
db: { mysql: 8 }
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Build docker-compose services
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 5
attempt_delay: 5000
command: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
MYSQL_MIGRATION_FILE: "${{ matrix.db.mysql == '5.6' && 'mysql_migration_5_6.sql' || 'mysql_migration.sql' }}"
- name: Wait for databases to be ready
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '10'
- name: Create test file
run: |
mkdir -p tests/staging
cat << 'TESTEOF' > tests/staging/distro-test.ts
import { sql } from 'sqlx-ts'
const selectSql = sql`
SELECT items.*
FROM items;
`
TESTEOF
- name: Test npm install and run in ${{ matrix.distro }} container
run: |
docker run --rm \
--network host \
-v $(pwd):/workspace \
-w /workspace \
${{ matrix.distro }} sh -c '
# Install Node.js based on distro
if command -v apk > /dev/null; then
# Alpine
apk add --no-cache nodejs npm bash
elif command -v apt-get > /dev/null; then
# Debian/Ubuntu
apt-get update && apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
elif command -v dnf > /dev/null; then
# Fedora
dnf install -y nodejs npm
fi
# Install sqlx-ts
cd node
npm install
# Verify installation
./sqlx-ts --version
./sqlx-ts --help
# Run integration test
./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging
echo "✅ sqlx-ts npm package works on ${{ matrix.distro }} with DB"
'