Skip to content

CI implementation

CI implementation #6

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
test:
runs-on: ubuntu-latest
needs: build
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: test
ports:
- 3307:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Wait for MySQL to be healthy
run: |
while ! docker exec -t $(docker ps -q --filter "ancestor=mysql:8.0") mysqladmin ping --silent; do sleep 1; done
- name: Initialize database
run: |
docker exec -i $(docker ps -q --filter "ancestor=mysql:8.0") mysql -uroot -prootpassword test < ./dbscripts/mysql.sql
- name: Run tests
env:
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_HOST: 127.0.0.1
MYSQL_PASSWORD: rootpassword
MYSQL_URL: mysql://root:[email protected]:3307/test
MYSQL_PORT: 3307
NODE_ENV: test
run: npm test