Skip to content

Commit 93fc382

Browse files
committed
Refactor CI configuration to streamline database environment variables and simplify DATABASE_URL assignment
1 parent 906a6d8 commit 93fc382

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
pull_request:
77
branches: [ master ]
88

9-
# ------------------------------------------------------------
10-
# Matrix definition – all DB‑specific fields live here
11-
# ------------------------------------------------------------
129
jobs:
1310
test:
1411
strategy:
@@ -23,8 +20,6 @@ jobs:
2320
db: postgresql
2421
ruby_image: ruby:3.2
2522
db_image: postgres:15
26-
db_env:
27-
POSTGRES_PASSWORD: postgres
2823
db_ports:
2924
- 5432:5432
3025
db_options: >-
@@ -37,8 +32,6 @@ jobs:
3732
db: postgresql
3833
ruby_image: ruby:3.2
3934
db_image: postgres:15
40-
db_env:
41-
POSTGRES_PASSWORD: postgres
4235
db_ports:
4336
- 5432:5432
4437
db_options: >-
@@ -52,9 +45,6 @@ jobs:
5245
db: mysql
5346
ruby_image: ruby:3.2
5447
db_image: mysql:8
55-
db_env:
56-
MYSQL_ROOT_PASSWORD: root
57-
MYSQL_DATABASE: test
5848
db_ports:
5949
- 3306:3306
6050
db_options: >-
@@ -67,9 +57,6 @@ jobs:
6757
db: mysql
6858
ruby_image: ruby:3.2
6959
db_image: mysql:8
70-
db_env:
71-
MYSQL_ROOT_PASSWORD: root
72-
MYSQL_DATABASE: test
7360
db_ports:
7461
- 3306:3306
7562
db_options: >-
@@ -87,17 +74,17 @@ jobs:
8774
services:
8875
db:
8976
image: ${{ matrix.db_image }}
90-
env: ${{ matrix.db_env }}
77+
env:
78+
POSTGRES_PASSWORD: ${{ matrix.db == 'postgresql' && 'postgres' || '' }}
79+
MYSQL_ROOT_PASSWORD: ${{ matrix.db == 'mysql' && 'root' || '' }}
80+
MYSQL_DATABASE: ${{ matrix.db == 'mysql' && 'test' || '' }}
9181
ports:
9282
- ${{ matrix.db_ports[0] }}
9383
options: ${{ matrix.db_options }}
9484

9585
env:
9686
RAILS_VERSION: ${{ matrix.rails }}
97-
DATABASE_URL: >-
98-
${{ matrix.db == 'sqlite3' && 'sqlite3::memory:' ||
99-
matrix.db == 'postgresql' && 'postgresql://postgres:postgres@localhost:5432/test' ||
100-
matrix.db == 'mysql' && 'mysql2://root:root@localhost:3306/test' }}
87+
DATABASE_URL: ${{ matrix.db == 'sqlite3' && 'sqlite3::memory:' || matrix.db == 'postgresql' && 'postgresql://postgres:postgres@localhost:5432/test' || 'mysql2://root:root@localhost:3306/test' }}
10188

10289
steps:
10390
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)