Skip to content

Commit b4c4478

Browse files
vkuttypCopilot
andcommitted
ci: merge all tests into 2 jobs to eliminate 3x redundant compilation
Before: 5 jobs (SQLite×2 + MSSQL + PG + MySQL) each compiling the full package independently → ~8 min wall-time. After: 2 jobs — macOS SQLite (~1 min) + one Linux job that builds once then runs all 5 test suites with --skip-build → target ~3-4 min. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 56350c9 commit b4c4478

1 file changed

Lines changed: 40 additions & 116 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,33 @@ env:
2727

2828
jobs:
2929
# ───────────────────────────────────────────────────────────────────────────
30-
# 1. Build + SQLite tests — macOS and Linux, multiple Swift versions
31-
# No Docker needed — SQLite uses an in-memory database.
30+
# 1. SQLite + Core tests — macOS (Swift pre-installed, ~1 min)
3231
# ───────────────────────────────────────────────────────────────────────────
33-
test-sqlite:
34-
name: SQLite — ${{ matrix.os }} / Swift ${{ matrix.swift }}
35-
runs-on: ${{ matrix.os }}
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
os: [macos-15, ubuntu-24.04]
40-
swift: ["6.0"]
32+
test-sqlite-macos:
33+
name: SQLite — macOS / Swift ${{ env.SWIFT_VERSION }}
34+
runs-on: macos-15
4135
steps:
42-
- name: Checkout
43-
uses: actions/checkout@v4
44-
45-
- name: Setup Swift ${{ matrix.swift }}
46-
if: runner.os == 'Linux'
47-
uses: swift-actions/setup-swift@v2
48-
with:
49-
swift-version: ${{ matrix.swift }}
50-
36+
- uses: actions/checkout@v4
5137
- name: Cache SPM
5238
uses: actions/cache@v4
5339
with:
5440
path: .build
55-
key: ${{ runner.os }}-spm-${{ matrix.swift }}-${{ hashFiles('Package.resolved') }}
56-
restore-keys: |
57-
${{ runner.os }}-spm-${{ matrix.swift }}-
58-
59-
- name: Install SQLite (Linux)
60-
if: runner.os == 'Linux'
61-
run: sudo apt-get install -y libsqlite3-dev
62-
63-
- name: Build
64-
run: swift build --configuration debug 2>&1
65-
66-
- name: Run SQLite tests
67-
run: swift test --filter SQLiteNioTests 2>&1
68-
69-
- name: Run Core tests
70-
run: swift test --filter SQLNioCoreTests 2>&1
41+
key: macos-spm-${{ env.SWIFT_VERSION }}-${{ hashFiles('Package.resolved') }}
42+
restore-keys: macos-spm-${{ env.SWIFT_VERSION }}-
43+
- run: swift test --filter SQLiteNioTests 2>&1
44+
- run: swift test --filter SQLNioCoreTests --skip-build 2>&1
7145

7246
# ───────────────────────────────────────────────────────────────────────────
73-
# 2. SQL Server integration tests
74-
# Connects to Mac via frpc tunnel on VPS (no service container).
47+
# 2. All integration tests in one Linux job — build once, test all three DBs
48+
# Connects to vps.marivil.com (Docker containers, always up).
7549
# ───────────────────────────────────────────────────────────────────────────
76-
test-mssql:
77-
name: SQL Server integration tests
50+
test-integration:
51+
name: Integration tests (MSSQL · PostgreSQL · MySQL · SQLite/Linux)
7852
runs-on: ubuntu-24.04
7953
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v4
54+
- uses: actions/checkout@v4
8255

83-
- name: Setup Swift
56+
- name: Setup Swift ${{ env.SWIFT_VERSION }}
8457
uses: swift-actions/setup-swift@v2
8558
with:
8659
swift-version: ${{ env.SWIFT_VERSION }}
@@ -92,104 +65,55 @@ jobs:
9265
uses: actions/cache@v4
9366
with:
9467
path: .build
95-
key: ${{ runner.os }}-spm-mssql-${{ hashFiles('Package.resolved') }}
96-
restore-keys: |
97-
${{ runner.os }}-spm-mssql-
98-
99-
- name: Run MSSQL tests
100-
env:
101-
MSSQL_TEST_HOST: ${{ secrets.DB_HOST }}
102-
MSSQL_TEST_PASS: ${{ secrets.MSSQL_TEST_PASS }}
103-
MSSQL_TEST_DB: "MSSQLNioTestDb"
104-
MSSQL_TEST_USER: "sa"
105-
run: swift test --filter MSSQLNioTests 2>&1
68+
key: linux-spm-${{ env.SWIFT_VERSION }}-${{ hashFiles('Package.resolved') }}
69+
restore-keys: linux-spm-${{ env.SWIFT_VERSION }}-
10670

107-
# ───────────────────────────────────────────────────────────────────────────
108-
# 3. PostgreSQL integration tests
109-
# Connects to Mac via frpc tunnel on VPS (no service container).
110-
# ───────────────────────────────────────────────────────────────────────────
111-
test-postgres:
112-
name: PostgreSQL integration tests
113-
runs-on: ubuntu-24.04
114-
steps:
115-
- name: Checkout
116-
uses: actions/checkout@v4
71+
- name: Build
72+
run: swift build --configuration debug 2>&1
11773

118-
- name: Setup Swift
119-
uses: swift-actions/setup-swift@v2
120-
with:
121-
swift-version: ${{ env.SWIFT_VERSION }}
74+
- name: SQLite tests
75+
run: swift test --filter SQLiteNioTests --skip-build 2>&1
12276

123-
- name: Install SQLite
124-
run: sudo apt-get install -y libsqlite3-dev
77+
- name: SQLite Core tests
78+
run: swift test --filter SQLNioCoreTests --skip-build 2>&1
12579

126-
- name: Cache SPM
127-
uses: actions/cache@v4
128-
with:
129-
path: .build
130-
key: ${{ runner.os }}-spm-pg-${{ hashFiles('Package.resolved') }}
131-
restore-keys: |
132-
${{ runner.os }}-spm-pg-
80+
- name: MSSQL tests
81+
env:
82+
MSSQL_TEST_HOST: ${{ secrets.MSSQL_TEST_HOST }}
83+
MSSQL_TEST_PASS: ${{ secrets.MSSQL_TEST_PASS }}
84+
MSSQL_TEST_DB: MSSQLNioTestDb
85+
MSSQL_TEST_USER: sa
86+
run: swift test --filter MSSQLNioTests --skip-build 2>&1
13387

134-
- name: Run PostgreSQL tests
88+
- name: PostgreSQL tests
13589
env:
136-
PG_TEST_HOST: ${{ secrets.DB_HOST }}
90+
PG_TEST_HOST: ${{ secrets.PG_TEST_HOST }}
13791
PG_TEST_DB: PostgresNioTestDb
13892
PG_TEST_USER: pguser
13993
PG_TEST_PASS: ${{ secrets.PG_TEST_PASS }}
140-
run: swift test --filter PostgresNioTests 2>&1
141-
142-
# ───────────────────────────────────────────────────────────────────────────
143-
# 4. MySQL integration tests
144-
# Connects to Mac via frpc tunnel on VPS (no service container).
145-
# ───────────────────────────────────────────────────────────────────────────
146-
test-mysql:
147-
name: MySQL integration tests
148-
runs-on: ubuntu-24.04
149-
steps:
150-
- name: Checkout
151-
uses: actions/checkout@v4
152-
153-
- name: Setup Swift
154-
uses: swift-actions/setup-swift@v2
155-
with:
156-
swift-version: ${{ env.SWIFT_VERSION }}
157-
158-
- name: Install SQLite
159-
run: sudo apt-get install -y libsqlite3-dev
160-
161-
- name: Cache SPM
162-
uses: actions/cache@v4
163-
with:
164-
path: .build
165-
key: ${{ runner.os }}-spm-mysql-${{ hashFiles('Package.resolved') }}
166-
restore-keys: |
167-
${{ runner.os }}-spm-mysql-
94+
run: swift test --filter PostgresNioTests --skip-build 2>&1
16895

169-
- name: Run MySQL tests
96+
- name: MySQL tests
17097
env:
171-
MYSQL_TEST_HOST: ${{ secrets.DB_HOST }}
98+
MYSQL_TEST_HOST: ${{ secrets.MYSQL_TEST_HOST }}
17299
MYSQL_TEST_DB: MySQLNioTestDb
173100
MYSQL_TEST_USER: mysqluser
174101
MYSQL_TEST_PASS: ${{ secrets.MYSQL_TEST_PASS }}
175-
run: swift test --filter MySQLNioTests 2>&1
102+
run: swift test --filter MySQLNioTests --skip-build 2>&1
176103

177104
# ───────────────────────────────────────────────────────────────────────────
178-
# 5. Summary / Required status check
179-
# PRs cannot be merged until all four test jobs pass.
105+
# 3. Summary / Required status check
180106
# ───────────────────────────────────────────────────────────────────────────
181107
ci-success:
182108
name: All tests passed
183109
runs-on: ubuntu-24.04
184-
needs: [test-sqlite, test-mssql, test-postgres, test-mysql]
110+
needs: [test-sqlite-macos, test-integration]
185111
if: always()
186112
steps:
187113
- name: Check results
188114
run: |
189-
if [[ "${{ needs.test-sqlite.result }}" != "success" || \
190-
"${{ needs.test-mssql.result }}" != "success" || \
191-
"${{ needs.test-postgres.result }}" != "success" || \
192-
"${{ needs.test-mysql.result }}" != "success" ]]; then
115+
if [[ "${{ needs.test-sqlite-macos.result }}" != "success" || \
116+
"${{ needs.test-integration.result }}" != "success" ]]; then
193117
echo "One or more test jobs failed."
194118
exit 1
195119
fi

0 commit comments

Comments
 (0)