Skip to content

docs(testing): add test infrastructure fixes documentation #1

docs(testing): add test infrastructure fixes documentation

docs(testing): add test infrastructure fixes documentation #1

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: ticketing_user
POSTGRES_PASSWORD: ticketing_password
POSTGRES_DB: ticketing_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
DATABASE_URL: postgresql://ticketing_user:ticketing_password@localhost:5432/ticketing_db
SESSION_SECRET: test-session-secret-for-ci-pipeline-minimum-32-chars
NODE_ENV: test
LOG_LEVEL: error
I18N_DEFAULTLANGUAGE: en
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U ticketing_user; do
echo "Waiting for PostgreSQL..."
sleep 2
done
- name: Run database migrations
run: node scripts/init-db.js
- name: Run tests
run: npm test
- name: Generate coverage report
run: npm run test:coverage
- name: Check coverage thresholds
run: |
# Coverage thresholds are enforced by Jest configuration
# This step will fail if coverage is below 70%
echo "Coverage thresholds checked by Jest"
- name: Upload coverage to Codecov (optional)
if: github.event_name == 'pull_request'
uses: codecov/codecov-action@v3
with:
files: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
continue-on-error: true
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: romeovs/lcov-reporter-action@v0.3.1
with:
lcov-file: ./coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: npm audit --audit-level=moderate
continue-on-error: true
- name: Check for known vulnerabilities
run: npm audit --production --audit-level=high