Skip to content

Instantly share code, notes, and snippets.

@RizkyRajitha
Last active February 18, 2024 06:17
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RizkyRajitha/ca945c55ab09bcc2c7c150b2fed7db13 to your computer and use it in GitHub Desktop.
Save RizkyRajitha/ca945c55ab09bcc2c7c150b2fed7db13 to your computer and use it in GitHub Desktop.
GitHub action workflow for test , using PostgreSQL database service container .
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