Skip to content

Commit 568e35c

Browse files
committed
Fix db name
1 parent 36e2b31 commit 568e35c

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

.env.testing.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
DATABASE_HOST=localhost
1+
# DATABASE_HOST=localhost
22
# DATABASE_PORT - unused
3-
# CI uses a hard-coded range 6000-6007,
3+
# CI uses a hard-coded range 6000-6007 of ports and corresponding hosts,
44
# locally it discovers running containers
55
# and launches dbs as needed.
66
DATABASE_NAME=spi_test

.github/workflows/ci.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ jobs:
4343
run: cp .env.testing.template .env.testing && swift test --filter AnalyzerTests
4444
env:
4545
COLLECTION_SIGNING_PRIVATE_KEY: ${{ secrets.COLLECTION_SIGNING_PRIVATE_KEY }}
46-
DATABASE_HOST: postgres
47-
DATABASE_PORT: '5432'
4846
services:
4947
# Make sure the ports expose here (6000-60007) align with the ports
5048
# hard-coded in DatabasePool.runningDatabases().
51-
db-0:
49+
db-6000:
5250
image: postgres:16-alpine
5351
env:
5452
POSTGRES_DB: spi_test
@@ -61,7 +59,7 @@ jobs:
6159
--health-interval 10s
6260
--health-timeout 5s
6361
--health-retries 5
64-
db-1:
62+
db-6001:
6563
image: postgres:16-alpine
6664
env:
6765
POSTGRES_DB: spi_test
@@ -74,7 +72,7 @@ jobs:
7472
--health-interval 10s
7573
--health-timeout 5s
7674
--health-retries 5
77-
db-2:
75+
db-6002:
7876
image: postgres:16-alpine
7977
env:
8078
POSTGRES_DB: spi_test
@@ -87,7 +85,7 @@ jobs:
8785
--health-interval 10s
8886
--health-timeout 5s
8987
--health-retries 5
90-
db-3:
88+
db-6003:
9189
image: postgres:16-alpine
9290
env:
9391
POSTGRES_DB: spi_test
@@ -100,7 +98,7 @@ jobs:
10098
--health-interval 10s
10199
--health-timeout 5s
102100
--health-retries 5
103-
db-4:
101+
db-6004:
104102
image: postgres:16-alpine
105103
env:
106104
POSTGRES_DB: spi_test
@@ -113,7 +111,7 @@ jobs:
113111
--health-interval 10s
114112
--health-timeout 5s
115113
--health-retries 5
116-
db-5:
114+
db-6005:
117115
image: postgres:16-alpine
118116
env:
119117
POSTGRES_DB: spi_test
@@ -126,7 +124,7 @@ jobs:
126124
--health-interval 10s
127125
--health-timeout 5s
128126
--health-retries 5
129-
db-6:
127+
db-6006:
130128
image: postgres:16-alpine
131129
env:
132130
POSTGRES_DB: spi_test
@@ -139,7 +137,7 @@ jobs:
139137
--health-interval 10s
140138
--health-timeout 5s
141139
--health-retries 5
142-
db-7:
140+
db-6007:
143141
image: postgres:16-alpine
144142
env:
145143
POSTGRES_DB: spi_test

Tests/AppTests/Helpers/DatabasePool.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ extension DatabasePool.Database {
168168
// Ensure DATABASE_HOST is from a restricted set db hostnames and nothing else.
169169
// This is safeguard against accidental inheritance of setup in QueryPerformanceTests
170170
// and to ensure the database resetting cannot impact any other network hosts.
171-
self.host = Environment.get("DATABASE_HOST")!
171+
if isRunningInCI() {
172+
self.host = "db-\(port)"
173+
} else {
174+
self.host = Environment.get("DATABASE_HOST")!
175+
}
172176
precondition(["localhost", "postgres", "host.docker.internal"].contains(host),
173177
"DATABASE_HOST must be a local db, was: \(host)")
174178
self.port = port

0 commit comments

Comments
 (0)