Skip to content

Commit

Permalink
test(ci): use postgres in CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Aug 31, 2021
1 parent 39b27f4 commit 0c8dcc5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/build-and-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ on: [pull_request, workflow_dispatch]
jobs:
build-test:
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:10.10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
with:
Expand All @@ -24,6 +34,13 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn bootstrap
- run: yarn build
- run: yarn test:integration
- name: run integration tests
env:
INCLUDE_POSTGRES_TESTS: true
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
POSTGRES_PORT: 5432
run: yarn test:integration
- run: yarn lint
- run: npx codecov
18 changes: 17 additions & 1 deletion .github/workflows/build-test-publish-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ jobs:
GH_USER: ${{secrets.GH_USER}}
GH_EMAIL: ${{secrets.GH_EMAIL}}
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:10.10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -37,7 +46,14 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn bootstrap
- run: yarn build
- run: yarn test:integration
- name: run integration tests
env:
INCLUDE_POSTGRES_TESTS: true
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
POSTGRES_PORT: 5432
run: yarn test:integration

- name: setup git coordinates
run: |
Expand Down
16 changes: 8 additions & 8 deletions __tests__/shared/dbInitOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export default (testContext: {
database: undefined,
synchronize: false,
migrationsRun: true,
host: 'localhost',
port: 5432,
password: 'test123',
username: 'postgres',
host: process.env.POSTGRES_HOST || 'localhost',
port: process.env.POSTGRES_PORT || 5432,
password: process.env.POSTGRES_PASSWORD || 'test123',
username: process.env.POSTGRES_USER || 'postgres',
},
},
})
Expand All @@ -86,10 +86,10 @@ export default (testContext: {
database: undefined,
synchronize: true,
migrationsRun: false,
host: 'localhost',
port: 5432,
password: 'test123',
username: 'postgres',
host: process.env.POSTGRES_HOST || 'localhost',
port: process.env.POSTGRES_PORT || 5432,
password: process.env.POSTGRES_PASSWORD || 'test123',
username: process.env.POSTGRES_USER || 'postgres',
},
},
})
Expand Down

0 comments on commit 0c8dcc5

Please sign in to comment.