-
Notifications
You must be signed in to change notification settings - Fork 1
247 lines (220 loc) · 9.33 KB
/
ci.yml
File metadata and controls
247 lines (220 loc) · 9.33 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
name: CI
on:
push:
branches: [main, develop]
paths-ignore:
- '**.md'
- '.spi.yml'
- 'Sources/**/*.docc/**'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- '.spi.yml'
- 'Sources/**/*.docc/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# ─────────────────────────────────────────────────────────────────────────────
# Environment variables shared across all jobs
# ─────────────────────────────────────────────────────────────────────────────
env:
SWIFT_VERSION: "6.0"
jobs:
# ───────────────────────────────────────────────────────────────────────────
# 1. Build + SQLite tests — macOS and Linux, multiple Swift versions
# No Docker needed — SQLite uses an in-memory database.
# ───────────────────────────────────────────────────────────────────────────
test-sqlite:
name: SQLite — ${{ matrix.os }} / Swift ${{ matrix.swift }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04]
swift: ["5.10", "6.0"]
exclude:
# macOS 15 ships with Swift 6 (Xcode 16); skip redundant 5.10 run
- os: macos-15
swift: "5.10"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift ${{ matrix.swift }}
if: runner.os == 'Linux'
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-${{ matrix.swift }}-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-${{ matrix.swift }}-
- name: Install SQLite (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libsqlite3-dev
- name: Build
run: swift build --configuration debug 2>&1
- name: Run SQLite tests
run: swift test --filter SQLiteNioTests 2>&1
- name: Run Core tests
run: swift test --filter SQLNioCoreTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 2. SQL Server integration tests
# Uses GitHub Actions service container — Linux only.
# ───────────────────────────────────────────────────────────────────────────
test-mssql:
name: SQL Server integration tests
runs-on: ubuntu-24.04
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: "Y"
SA_PASSWORD: "aBCD111!"
MSSQL_PID: Developer
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'aBCD111!' -Q 'SELECT 1' -C"
--health-interval 10s
--health-timeout 5s
--health-retries 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-mssql-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-mssql-
- name: Create test database
run: |
until /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -P 'aBCD111!' -C \
-Q "CREATE DATABASE MSSQLNioTestDb" 2>/dev/null; do
echo "Waiting for SQL Server..."; sleep 3
done
- name: Run MSSQL tests
env:
MSSQL_TEST_HOST: "127.0.0.1"
MSSQL_TEST_PASS: "aBCD111!"
MSSQL_TEST_DB: "MSSQLNioTestDb"
MSSQL_TEST_USER: "sa"
run: swift test --filter MSSQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 3. PostgreSQL integration tests
# ───────────────────────────────────────────────────────────────────────────
test-postgres:
name: PostgreSQL integration tests
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: PostgresNioTestDb
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgPass123
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U pguser"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-pg-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-pg-
- name: Run PostgreSQL tests
env:
PG_TEST_HOST: "127.0.0.1"
PG_TEST_DB: PostgresNioTestDb
PG_TEST_USER: pguser
PG_TEST_PASS: pgPass123
run: swift test --filter PostgresNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 4. MySQL integration tests
# ───────────────────────────────────────────────────────────────────────────
test-mysql:
name: MySQL integration tests
runs-on: ubuntu-24.04
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: MySQLNioTestDb
MYSQL_USER: mysqluser
MYSQL_PASSWORD: mysqlPass123
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -u mysqluser -pmysqlPass123"
--health-interval 5s
--health-timeout 3s
--health-retries 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-mysql-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-mysql-
- name: Run MySQL tests
env:
MYSQL_TEST_HOST: "127.0.0.1"
MYSQL_TEST_DB: MySQLNioTestDb
MYSQL_TEST_USER: mysqluser
MYSQL_TEST_PASS: mysqlPass123
run: swift test --filter MySQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 5. Summary / Required status check
# PRs cannot be merged until all four test jobs pass.
# ───────────────────────────────────────────────────────────────────────────
ci-success:
name: All tests passed
runs-on: ubuntu-24.04
needs: [test-sqlite, test-mssql, test-postgres, test-mysql]
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.test-sqlite.result }}" != "success" || \
"${{ needs.test-mssql.result }}" != "success" || \
"${{ needs.test-postgres.result }}" != "success" || \
"${{ needs.test-mysql.result }}" != "success" ]]; then
echo "One or more test jobs failed."
exit 1
fi
echo "All test jobs passed."