Skip to content

Commit da489c3

Browse files
committed
fixing:github-action:fix-postgres
1 parent 5e225e3 commit da489c3

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,32 @@ jobs:
3636

3737
- name: Install dependencies
3838
run: yarn install
39+
3940

4041
- name: Wait for Postgres to be ready
4142
run: |
4243
for i in {1..10}; do
43-
pg_isready -h localhost -p 5432 && break || sleep 5
44+
pg_isready -h postgres -p 5432 && echo "Postgres is ready!" && exit 0
45+
echo "Waiting for Postgres..."
46+
sleep 5
4447
done
48+
echo "Postgres failed to start"
49+
exit 1
50+
4551
4652
- name: Sync Database
4753
env:
4854
NODE_ENV: test
4955
DB_USERNAME: postgres
5056
DB_PASSWORD: 12345678
5157
DB_NAME: database_services_test
52-
DB_HOST: localhost
58+
DB_HOST: postgres
5359
JWT_SECRET: supersecretkey
5460
JWT_EXPIRES_IN: 1h
5561
run: yarn sync-db
5662

5763
- name: Wait for database to settle
58-
run: sleep 5
64+
run: sleep 10
5965

6066
# - name: Run migrations
6167
# env:
@@ -73,7 +79,7 @@ jobs:
7379
DB_USERNAME: postgres
7480
DB_PASSWORD: 12345678
7581
DB_NAME: database_services_test
76-
DB_HOST: localhost
82+
DB_HOST: postgres
7783
JWT_SECRET: supersecretkey
7884
JWT_EXPIRES_IN: 1h
7985
run: yarn test

src/config/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const config = {
1414
username: process.env.DB_USERNAME || 'postgres',
1515
password: process.env.DB_PASSWORD || '12345678',
1616
database: process.env.DB_NAME || 'database_services_test',
17-
host: process.env.DB_HOST || 'localhost',
17+
host: process.env.CI ? 'postgres' : 'localhost',
1818
dialect: 'postgres',
1919
logging: false,
2020
},

0 commit comments

Comments
 (0)