Skip to content

Add comprehensive testing infrastructure with CI/CD workflows and validation pipelines - Complete implementation with CTRF test reporting and E2E test fixes #24

Add comprehensive testing infrastructure with CI/CD workflows and validation pipelines - Complete implementation with CTRF test reporting and E2E test fixes

Add comprehensive testing infrastructure with CI/CD workflows and validation pipelines - Complete implementation with CTRF test reporting and E2E test fixes #24

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
NODE_VERSION: '20'
jobs:
lint-and-build:
name: Lint and Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
- name: Build project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist/
retention-days: 7
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: lint-and-build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test:unit
- name: Publish Unit Test Results
uses: ctrf-io/github-test-reporter@v1
if: always()
with:
report-path: vitest-ctrf/report.json
- name: Upload test coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 7
mock-server-tests:
name: Mock Server Integration Tests
runs-on: ubuntu-latest
needs: lint-and-build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install jq for JSON parsing
run: sudo apt-get update && sudo apt-get install -y jq
- name: Start mock server
run: npm run mock-server &
env:
CI: true
- name: Wait for server to be ready
run: |
timeout 30 bash -c 'until curl -f http://localhost:3001/health; do sleep 1; done'
- name: Run endpoint tests
run: ./test-endpoints.sh
- name: Test validator against mock endpoints
run: npm run test:integration
- name: Publish Integration Test Results
uses: ctrf-io/github-test-reporter@v1
if: always()
with:
report-path: vitest-ctrf/report.json
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
needs: lint-and-build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install jq for JSON parsing
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get Playwright version
id: playwright-version
run: echo "version=$(npm ls @playwright/test --json | jq -r '.dependencies."@playwright/test".version')" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
~/.cache/npm
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
restore-keys: |
playwright-${{ runner.os }}-
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Install Playwright system dependencies only
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Start mock server for E2E tests
run: npm run mock-server &
env:
CI: true
- name: Start dev server for E2E tests
run: npm run dev &
env:
CI: true
- name: Wait for servers to be ready
run: |
timeout 30 bash -c 'until curl -f http://localhost:3001/health; do sleep 1; done'
timeout 30 bash -c 'until curl -f http://localhost:3000; do sleep 1; done'
- name: Run Playwright tests
run: npm run test:e2e
- name: Publish E2E Test Results
uses: ctrf-io/github-test-reporter@v1
if: always()
with:
report-path: ctrf/ctrf-report.json
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run security audit
run: npm audit --audit-level=high
- name: Check for known vulnerabilities
run: npm audit --audit-level=moderate --json > audit-results.json || true
- name: Upload audit results
uses: actions/upload-artifact@v4
if: always()
with:
name: security-audit
path: audit-results.json
retention-days: 30