Skip to content

Commit

Permalink
testing with pg and Redis containers
Browse files Browse the repository at this point in the history
  • Loading branch information
MarhiievHE committed May 8, 2023
1 parent 267a5e5 commit 67317da
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/test.yml
@@ -1,6 +1,8 @@
name: Testing CI

on: pull_request
on:
- pull_request
- push # not for landing

jobs:
build:
Expand All @@ -9,24 +11,33 @@ jobs:
strategy:
matrix:
node:
- 14
- 16
- 18
- 19
- 20
os:
- ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Start docker containers
run: |
docker-compose -f test-docker-compose.yml up -d pg-example redis-example
sleep 10 # wait for database to be ready
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci

- run: npm test
26 changes: 26 additions & 0 deletions test-docker-compose.yml
@@ -0,0 +1,26 @@
version: '3'

services:
pg-example:
image: postgres:14.1-alpine3.15
container_name: pg-example
environment:
- POSTGRES_USER=marcus
- POSTGRES_PASSWORD=marcus
- POSTGRES_DB=application
volumes:
- ./db/structure.sql:/docker-entrypoint-initdb.d/1.sql
- ./db/data.sql:/docker-entrypoint-initdb.d/2.sql
ports:
- 127.0.0.1:5432:5432
restart: always

redis-example:
image: redis:alpine
container_name: redis-example
ports:
- 127.0.0.1:6379:6379
restart: always
networks:
default:
name: api-example-network

0 comments on commit 67317da

Please sign in to comment.