Skip to content

feat: optimize test suite performance and add comprehensive test util… #6

feat: optimize test suite performance and add comprehensive test util…

feat: optimize test suite performance and add comprehensive test util… #6

Workflow file for this run

name: Test Suite
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: testpassword
MYSQL_DATABASE: nt_taxoffice_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Wait for MySQL
run: |
until mysqladmin ping -h 127.0.0.1 -P 3306 -u root -ptestpassword --silent; do
echo 'Waiting for MySQL...'
sleep 2
done
echo 'MySQL is ready!'
- name: Initialize test database
run: npm run test:db:init
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: testpassword
DB_NAME: nt_taxoffice_test
- name: Run unit tests
run: npm run test:unit
env:
NODE_ENV: test
SESSION_SECRET: test-secret-key-for-ci
GMAIL_USER: test@example.com
GMAIL_APP_PASSWORD: test-password
ADMIN_EMAIL: admin@example.com
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: testpassword
DB_NAME: nt_taxoffice_test
- name: Run integration tests
run: npm run test:integration
env:
NODE_ENV: test
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: testpassword
DB_NAME: nt_taxoffice_test
SESSION_SECRET: test-secret-key-for-ci
GMAIL_USER: test@example.com
GMAIL_APP_PASSWORD: test-password
ADMIN_EMAIL: admin@example.com
- name: Run coverage report
run: npm run test:coverage
env:
NODE_ENV: test
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: testpassword
DB_NAME: nt_taxoffice_test
SESSION_SECRET: test-secret-key-for-ci
GMAIL_USER: test@example.com
GMAIL_APP_PASSWORD: test-password
ADMIN_EMAIL: admin@example.com
- name: Upload coverage to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 30