Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# QueryPal CI/CD Pipeline

This directory contains the GitHub Actions CI/CD workflows for the QueryPal project.

## Workflows

### `ci.yml` - Continuous Integration

This workflow runs on pushes and pull requests to the `main`, `dev`, and `develop` branches.

**Jobs:**

1. **Backend Tests (Python)**
- Sets up Python 3.12
- Installs dependencies with pip caching
- Runs syntax checks with flake8
- Runs full linting with flake8 (non-blocking warnings)
- Checks code formatting with black
- Runs tests with pytest and coverage
- Uploads coverage to Codecov

2. **Frontend Tests (Node.js)**
- Sets up Node.js 20
- Installs dependencies with npm caching
- Runs tests with coverage using Vitest
- Uploads coverage to Codecov

3. **Build Verification**
- Runs after both test jobs pass
- Builds the frontend application
- Verifies build artifacts are created

**Coverage Reports:**
- Backend and frontend coverage reports are uploaded to Codecov with separate flags
- Coverage failures are non-blocking to allow builds to continue

**Key Features:**
- Parallel execution of frontend and backend tests
- Dependency caching for faster builds
- Comprehensive code quality checks
- Build verification to catch integration issues

## Running Tests Locally

### Backend
```bash
cd backend
pip install -r requirements.txt
flake8 . --statistics
black --check .
PYTHONPATH=. pytest --cov=. --cov-report=term-missing --verbose
```

### Frontend
```bash
cd frontend
npm install
npm run test:coverage
npm run build
```

## Coverage Requirements

The CI pipeline generates coverage reports but does not enforce minimum coverage thresholds. This allows for flexible development while still providing visibility into test coverage.

- Backend: Currently ~49% coverage
- Frontend: Currently ~13% coverage (mainly utilities and tested components)

Coverage reports are available in:
- Backend: `backend/htmlcov/index.html`
- Frontend: `frontend/coverage/index.html`
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI - Test Frontend and Backend

on:
push:
branches: [ main, dev, develop ]
pull_request:
branches: [ main, dev, develop ]
workflow_dispatch:

jobs:
backend-tests:
name: Backend Tests (Python)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint with flake8
working-directory: ./backend
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics

- name: Check code formatting with black
working-directory: ./backend
run: |
black --check .

- name: Run tests with pytest
working-directory: ./backend
run: |
PYTHONPATH=. pytest --cov=. --cov-report=term-missing --cov-report=xml --verbose

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./backend/coverage.xml
flags: backend
name: backend-coverage
fail_ci_if_error: false

frontend-tests:
name: Frontend Tests (Node.js)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js 20
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 tests with coverage
working-directory: ./frontend
run: npm run test:coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./frontend/coverage/coverage-final.json
flags: frontend
name: frontend-coverage
fail_ci_if_error: false

# Optional: Build verification job
build-verification:
name: Build Verification
runs-on: ubuntu-latest
needs: [backend-tests, frontend-tests]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install frontend dependencies
working-directory: ./frontend
run: npm ci

- name: Build frontend
working-directory: ./frontend
run: npm run build

- name: Verify frontend build artifacts
working-directory: ./frontend
run: |
if [ ! -d "dist" ]; then
echo "Frontend build failed - no dist directory found"
exit 1
fi
echo "Frontend build successful - dist directory exists"
ls -la dist/
38 changes: 0 additions & 38 deletions .github/workflows/docker-build-push.yml

This file was deleted.