This directory contains GitHub Actions workflows for automated testing, quality assurance, and deployment of the myWorld Travel API backend.
The backend CI/CD pipeline implements a robust continuous integration and deployment strategy that ensures code quality, maintains test coverage, and automates production deployments.
Purpose: Automated testing and deployment pipeline for the backend application.
Triggers:
- ✅ Push to
mainbranch - ✅ Pull requests targeting
mainbranch
Pipeline Architecture: Two-stage pipeline with CI (always runs) and CD (conditional deployment)
Runs on: ubuntu-latest
Purpose: Validates code quality through comprehensive testing with coverage analysis.
- Fetches the latest code from the repository using GitHub Actions checkout v6
- Configures Node.js v20 runtime
- Enables npm dependency caching for faster subsequent runs (~30-50% faster with cache hits)
- Performs clean install (
npm ci) for reproducible builds - Ensures exact dependency versions from
package-lock.json
- Executes all unit and integration tests (599 tests)
- Generates comprehensive coverage report
- Enforces coverage thresholds:
- Statements: ≥80% (Current: 91.48%)
- Branches: ≥80% (Current: 86.18%)
- Functions: ≥80% (Current: 94.14%)
- Lines: ≥80% (Current: 91.77%)
- Build fails if coverage drops below thresholds
- Stores coverage reports as workflow artifacts
- Accessible from GitHub Actions UI
- Retained for 7 days for review and auditing
For the CI stage to pass:
- ✅ All 599 tests must pass
- ✅ Code coverage must meet ≥80% thresholds
- ✅ No build errors or dependency issues
Runs on: ubuntu-latest
Depends on: ci-unit-tests (must pass first)
Conditional Execution: Only runs if:
- ✅ Event is a push to
mainbranch - ✅ CI tests passed successfully
- ✅ Not a pull request
- Deploys application to Render hosting platform
- Waits for deployment completion before proceeding
- Uses GitHub secrets for secure authentication
- Preserves cache for faster deployments
Required Secrets:
RENDER_API_KEY: Render API authentication keyRENDER_SERVICE_ID: Unique identifier for backend service
- Verifies deployment was successful
- Checks
/healthendpoint for healthy status - Retries up to 5 times with 10-second delays
- Fails deployment if health check doesn't return
"healthy"
- Production URL:
https://myworld-backend-8u7h.onrender.com - Health Check:
https://myworld-backend-8u7h.onrender.com/health - API Documentation:
https://myworld-backend-8u7h.onrender.com/api-docs
The workflow uses minimal permissions for security:
permissions:
contents: readConfigure these secrets in GitHub repository settings (Settings → Secrets and variables → Actions):
| Secret Name | Description | How to Obtain |
|---|---|---|
RENDER_API_KEY |
Render API authentication key | Render Dashboard → Account Settings → API Keys |
RENDER_SERVICE_ID |
Unique identifier for backend service | Found in Render service URL or settings |
- Prevents concurrent runs on the same branch/PR
- Cancels older runs when new commits are pushed
- Saves CI minutes and resources
GitHub Actions Dashboard:
- Navigate to:
Repository → Actions tab - View all workflow runs, their status, and logs
- Direct link
- Go to workflow run in GitHub Actions
- Scroll to Artifacts section at the bottom
- Download
coverage-reportartifact - Extract and open
index.htmlin browser
| Status | Description | Next Steps |
|---|---|---|
| ✅ Success | All tests passed, coverage met, deployment successful | No action needed |
| ❌ Test Failure | One or more tests failed | Review test logs, fix failing tests |
| ❌ Coverage Failure | Coverage below 80% threshold | Add tests to increase coverage |
| ❌ Deployment Failure | Deployment or health check failed | Check Render logs |
| 🟡 Skipped | CD skipped (PR or test failure) | Merge PR or fix tests first |
Possible Causes:
- Environment variable differences
- Timing issues with async code
- Node.js version mismatch
Solution:
# Test with same Node.js version
nvm use 20
npm run test:coverageCause: New code added without sufficient test coverage
Solution:
# Identify uncovered code
npm run test:coverage
# Open coverage/index.html to see specific lines
# Add tests for uncovered codePossible Causes:
- Invalid Render secrets
- Render service issues
- Health check endpoint not responding
Solutions:
- Verify secrets in GitHub settings
- Check Render dashboard for service status
- Test health endpoint manually:
curl https://myworld-backend-8u7h.onrender.com/health
| Stage | Duration | Notes |
|---|---|---|
| Checkout | ~1-2s | Fast with shallow clone |
| Node.js Setup | ~1-2s | Faster with cache hit |
| Dependencies Install | ~1-2s | Significantly faster with cache |
| Test Execution | ~45s | 599 tests with coverage |
| Total CI Time | ~1 min | With cache hits |
| Deployment | ~7 min | Render deployment time |
| Health Check | ~10s | With retries |
| Total CD Time | ~7.5 min | After CI passes |
Total Pipeline Duration (Push to Main): ~8.5 minutes
- Backend README - Main project documentation
- Testing Documentation - Comprehensive test guide
- GitHub Actions Documentation - Official docs
- Render Documentation - Render hosting platform