Last active
October 15, 2024 16:33
-
-
Save RizkyRajitha/ca945c55ab09bcc2c7c150b2fed7db13 to your computer and use it in GitHub Desktop.
GitHub action workflow for test , using PostgreSQL database service container .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Running Tests | |
on: [push] | |
jobs: | |
Test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_DB: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
# run steps required in the workflow | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js 14.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- name: Install dependencies | |
run: npm install | |
- name: migrate database | |
run: node migrate.js | |
env: | |
DBURL: "postgres://postgres:postgres@localhost:5432/postgres" | |
- name: Run the mock tests function | |
run: node getuser.js | |
env: | |
DBURL: postgres://postgres:postgres@localhost:5432/postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment