-
Notifications
You must be signed in to change notification settings - Fork 3
231 lines (200 loc) · 9.43 KB
/
Copy pathci.yml
File metadata and controls
231 lines (200 loc) · 9.43 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
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: ["6.0"]
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
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-mssql:
name: SQL Server integration tests
runs-on: ubuntu-24.04
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: Install sqlcmd
run: |
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
| sudo gpg --batch --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] \
https://packages.microsoft.com/ubuntu/24.04/prod noble main" \
| sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update -q
sudo ACCEPT_EULA=Y apt-get install -y sqlcmd
- 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: |
sqlcmd -S "${{ secrets.DB_HOST }},1433" -U sa \
-P "${{ secrets.MSSQL_TEST_PASS }}" \
--trust-server-certificate \
-Q "IF DB_ID('MSSQLNioTestDb') IS NULL CREATE DATABASE MSSQLNioTestDb"
- name: Seed SQL Server database
run: |
sqlcmd -S "${{ secrets.DB_HOST }},1433" -U sa \
-P "${{ secrets.MSSQL_TEST_PASS }}" \
--trust-server-certificate \
-i Tests/Resources/mssql_seed.sql
- name: Run MSSQL tests
env:
MSSQL_TEST_HOST: ${{ secrets.DB_HOST }}
MSSQL_TEST_PASS: ${{ secrets.MSSQL_TEST_PASS }}
MSSQL_TEST_DB: "MSSQLNioTestDb"
MSSQL_TEST_USER: "sa"
run: swift test --filter MSSQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 3. PostgreSQL integration tests
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-postgres:
name: PostgreSQL integration tests
runs-on: ubuntu-24.04
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 and psql
run: sudo apt-get install -y libsqlite3-dev postgresql-client
- 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: Seed PostgreSQL database
run: |
PGPASSWORD="${{ secrets.PG_TEST_PASS }}" psql \
-h "${{ secrets.DB_HOST }}" -U pguser -d PostgresNioTestDb \
-f Tests/Resources/postgres_seed.sql
- name: Run PostgreSQL tests
env:
PG_TEST_HOST: ${{ secrets.DB_HOST }}
PG_TEST_DB: PostgresNioTestDb
PG_TEST_USER: pguser
PG_TEST_PASS: ${{ secrets.PG_TEST_PASS }}
run: swift test --filter PostgresNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 4. MySQL integration tests
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-mysql:
name: MySQL integration tests
runs-on: ubuntu-24.04
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 and mysql client
run: sudo apt-get install -y libsqlite3-dev default-mysql-client
- 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: Seed MySQL database
run: |
mysql -h "${{ secrets.DB_HOST }}" \
-u mysqluser -p"${{ secrets.MYSQL_TEST_PASS }}" \
MySQLNioTestDb < Tests/Resources/mysql_seed.sql
- name: Run MySQL tests
env:
MYSQL_TEST_HOST: ${{ secrets.DB_HOST }}
MYSQL_TEST_DB: MySQLNioTestDb
MYSQL_TEST_USER: mysqluser
MYSQL_TEST_PASS: ${{ secrets.MYSQL_TEST_PASS }}
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."