Skip to content

update action to v4 #10

update action to v4

update action to v4 #10

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@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v4
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@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v4
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: |
if docker exec -i $(docker ps -q --filter "ancestor=mysql:8.0") mysql -uroot -prootpassword test < ./dbscripts/mysql.sql; then
echo "Database initialized successfully";
else
echo "Database initialization failed";
exit 1;
fi
- 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