forked from cardosofelipe/fast-next-template
- Introduced workflow templates for backend (`backend-tests.yml`), frontend (`frontend-tests.yml`), and end-to-end testing (`e2e-tests.yml`), including setup instructions in `.github/workflows/README.md`. - Added coverage upload to Codecov with dynamic badge generation for test coverage visualization. - Updated project `README.md` to replace static badges with placeholders for dynamic CI/CD badges. - Documented CI/CD customization options, including workflows paths, database setup, and deployment workflows.
52 lines
1.2 KiB
Plaintext
52 lines
1.2 KiB
Plaintext
# Frontend Unit Tests CI Pipeline
|
|
#
|
|
# Rename this file to frontend-tests.yml to enable it
|
|
# This will make the frontend test badges dynamic
|
|
#
|
|
# Required repository secrets:
|
|
# - CODECOV_TOKEN (for coverage upload)
|
|
|
|
name: Frontend Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
paths:
|
|
- 'frontend/**'
|
|
- '.github/workflows/frontend-tests.yml'
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
paths:
|
|
- 'frontend/**'
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: './frontend/package-lock.json'
|
|
|
|
- name: Install dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Run unit tests with coverage
|
|
working-directory: ./frontend
|
|
run: npm run test:coverage
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: ./frontend/coverage/coverage-final.json
|
|
flags: frontend
|
|
name: frontend-coverage
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|