This guide explains how to set up and use the CI/CD pipelines for ResCanvas.
- No configuration needed! Workflows are pre-configured in
.github/workflows/ - Push code or create a PR to trigger automatic testing
- View results in the "Actions" tab on GitHub
# Run all tests (optimized for speed)
./scripts/run_all_tests_parallel.sh
# Fast mode (skip coverage)
./scripts/run_all_tests_parallel.sh --fast
# Original sequential script (more stable)
./scripts/run_all_tests_unified.shTriggers:
- Push to
main,develop, orintegration_testsbranches - Pull requests to
mainordevelop - Manual dispatch
What it does:
- Runs backend tests on Python 3.10 & 3.11
- Runs frontend unit tests on Node 20.x & 22.x
- Runs full E2E test suite with Playwright
- Generates coverage reports
- Uploads test artifacts
- Posts summary to PRs
Duration: ~10-15 minutes
Use when:
- Merging to main branch
- Need full test coverage
- Release validation
Triggers:
- Push to any branch (except
main) - Pull request opened/updated
What it does:
- Runs unit tests only (no E2E)
- Lint and format checks
- Build validation
- Fast feedback
Duration: ~5-8 minutes
Use when:
- Developing features
- Need fast feedback
- Pre-commit validation
The workflows use these environment variables (automatically configured):
NODE_VERSION: '20.x' # Node.js version
PYTHON_VERSION: '3.10' # Python version
API_BASE: http://localhost:10010
APP_BASE: http://localhost:3000Both workflows automatically start:
- Redis (port 6379)
- MongoDB (port 27017)
Required GitHub secrets (set in repository settings):
# Currently no secrets required for testing
# Future: Add these for deployment
DEPLOY_KEY=...
CODECOV_TOKEN=...- Go to repository β Actions tab
- Click on workflow run
- View detailed logs and test results
Automated comments show:
- Test pass/fail status
- π Coverage changes
- π Links to detailed reports
Available for 30 days:
- Backend coverage reports
- Frontend coverage reports
- Playwright HTML reports
- Test failure screenshots/videos
Download:
- Go to workflow run
- Scroll to "Artifacts" section
- Click to download
| Python Version | OS | Tests Run |
|---|---|---|
| 3.10 | Ubuntu Latest | Unit + Integration + E2E |
| 3.11 | Ubuntu Latest | Unit + Integration + E2E |
| Node Version | OS | Tests Run |
|---|---|---|
| 20.x | Ubuntu Latest | Jest unit tests |
| 22.x | Ubuntu Latest | Jest unit tests |
| Browser | OS | Tests Run |
|---|---|---|
| Chromium | Ubuntu Latest | All Playwright tests |
Frontend E2E (Playwright):
workers: process.env.CI ? 2 : 4- CI uses 2 workers (stable)
- Local uses up to 4 workers (faster)
Frontend Unit (Jest):
npm test -- --maxWorkers=4- Parallel by default
- Scales with CPU cores
Backend (Pytest):
pytest -n auto # Optional parallel mode- Sequential by default (shared state)
- Can enable parallel with
-n auto
Workflows cache:
- Python pip packages
- Node modules
- Playwright browsers
Benefits:
- 50% faster subsequent runs
- Reduced bandwidth usage
# View logs in GitHub UI
Actions β Failed workflow β Click on failed job β View logs# For E2E failures
1. Download "playwright-failures" artifact
2. Extract and view screenshots/videos
3. Open trace files with: npx playwright show-trace trace.zip# Run same test locally
cd frontend
npx playwright test tests/e2e/errors.spec.js --debug
# Or run full suite
./scripts/run_all_tests_parallel.sh# In workflow logs, check:
- Backend startup logs
- Frontend build logs
- Service health checksFor main and develop branches:
-
Require status checks to pass:
- Backend Tests (Python 3.10)
- Frontend Unit Tests (Node 20.x)
- Frontend E2E Tests
- Test Summary
-
Require branches to be up to date
-
Require pull request reviews: 1 approval
-
Dismiss stale reviews on push
# Via GitHub UI:
Settings β Branches β Add branch protection rule
# Or via GitHub CLI:
gh api repos/:owner/:repo/branches/main/protection -X PUT -f required_status_checks='{"strict":true,"contexts":["Backend Tests","Frontend E2E Tests"]}'To enable Codecov:
- Sign up at codecov.io
- Add repository
- Add
CODECOV_TOKENto GitHub secrets - Coverage automatically uploaded on test runs
# Backend
cd backend
pytest --cov=. --cov-report=html
open htmlcov/index.html
# Frontend
cd frontend
npm test -- --coverage
open coverage/lcov-report/index.htmlAdd to README.md:
[](https://github.com/ResilientApp/ResCanvas/actions)
[](https://github.com/ResilientApp/ResCanvas/actions)on:
push:
paths:
- 'backend/**'
- 'frontend/**'
- '.github/workflows/**'Add to commit message:
git commit -m "docs: update README [skip ci]"# Via GitHub UI: Actions β Select workflow β Run workflow
# Via CLI:
gh workflow run ci-tests.yml- Mock external APIs
- Use fixtures for data
- Minimize database operations
- No shared state between tests
- Clean up after each test
- Use unique identifiers
# Before pushing
./scripts/run_all_tests_parallel.sh
# Quick pre-commit check
pytest tests/unit/ -q
npm test -- --watchAll=false- Quick Check: For work-in-progress
- Full Suite: Before merging
- Track workflow duration
- Optimize slow tests
- Review flaky test patterns
Solution:
# Check if required status checks exist
gh api repos/:owner/:repo/branches/main/protection
# Update branch protection if neededCauses:
- Timing differences
- Environment variables
- Service versions
Debug:
# Match CI environment locally
export CI=true
./scripts/run_all_tests_parallel.sh --ciOptimize:
- Enable caching (already done)
- Run quick check on PRs
- Use fail-fast for faster feedback
- Parallelize more tests
Solutions:
// Increase timeouts
timeout: 60000
// Add retries
retries: 2
// Better waits
await page.waitForLoadState('networkidle')When adding new tests:
- Ensure they pass locally
- Check they work in parallel (if applicable)
- Update documentation if needed
- Test in CI before merging
For CI/CD issues:
- Check workflow logs
- Review this guide
- Check GitHub Actions status
- Open an issue with workflow run link