Comprehensive CI/CD automation for the Node.js notes app with testing and documentation workflows.
We have two optimized workflows that provide complete automation:
- Runs unit tests with coverage reporting
- Tests both database backends (CouchDB and MongoDB) with Docker Compose
- Provides fast feedback for code quality
- Generates JSDoc documentation automatically
- Validates documentation quality with coverage analysis
- Deploys to GitHub Pages for public access
- Optimized single-job pipeline for speed and efficiency
Both workflows are designed to be simple, fast, and reliable.
Purpose: Simple, comprehensive testing for every commit.
Two Jobs:
build- Unit tests and coveragedocker-compose-tests- Database integration testing (matrix: CouchDB × MongoDB)
Triggers:
- Push to
mainbranch - Pull requests to
mainbranch
Execution Flow:
build (unit tests + coverage)
↓
docker-compose-tests (parallel: CouchDB + MongoDB)
Purpose: Automated documentation generation, quality control, and deployment.
Single Optimized Job:
docs-pipeline - Complete documentation workflow in one efficient job
Triggers:
- Push to
mainanddevelopbranches - Pull requests to
mainbranch - Release publications
Execution Flow:
Setup (checkout, Node.js 24, npm install)
↓
Generate (JSDoc documentation build)
↓
Quality Check (link validation, coverage analysis)
↓
Deploy (GitHub Pages - main branch only)
Key Features:
- ✅ Optimized performance: Single job eliminates redundant setups
- ✅ Quality gates: Documentation must pass validation before deployment
- ✅ Conditional deployment: Only deploys on main branch pushes
- ✅ Fast execution: ~2-3 minutes vs traditional 4-5 minute multi-job approach
- ✅ Dependencies installation (
npm ci) - ✅ Project build (if build script exists)
- ✅ Unit test execution with coverage
- ✅ Coverage upload to Codecov
- ✅ CouchDB setup with secure credentials
- ✅ MongoDB setup with secure credentials
- ✅ API functionality (health, CRUD operations)
- ✅ Automatic cleanup after tests
- ✅ JSDoc compilation from source code comments
- ✅ README integration into main documentation
- ✅ API reference generation with examples
- ✅ Source code syntax highlighting
- ✅ Documentation coverage analysis (80% threshold)
- ✅ Broken link detection with linkinator
- ✅ JSDoc syntax validation
- ✅ Function/class documentation completeness
- ✅ GitHub Pages deployment with custom domain support
- ✅ Automatic updates on every main branch push
- ✅ Public accessibility for API consumers
- ✅ SEO optimization with proper meta tags
# Secure credential generation for each test run
- name: Configure test credentials
run: |
echo "MONGODB_PASSWORD=ci_test_$(openssl rand -hex 12)" >> $GITHUB_ENVBenefits:
- ✅ No hardcoded credentials in workflows
- ✅ Unique passwords per test run
- ✅ Automatic cleanup prevents credential leakage
Before pushing changes, validate locally:
# Validate workflows and compose files
./validate-ci.sh quick
# Test both databases locally
./test-docker-setups.sh both
# Test individual databases
./test-docker-setups.sh mongodb
./test-docker-setups.sh couchdb
# Test documentation pipeline locally
npm run docs # Generate documentation
node scripts/check-docs-coverage.js # Run quality checks
npm run docs:serve # Preview locally- ✅ GitHub Actions workflow syntax
- ✅ Docker Compose file syntax
- ✅ Environment variable requirements
- ✅ Docker Compose credential validation
- ✅ JSDoc syntax and compilation
- ✅ Documentation coverage thresholds
- ✅ Link validation and integrity
- ✅ API reference completeness
Pull Request/Push:
- Unit tests: ~2-3 minutes
- Docker Compose tests: ~4-6 minutes (parallel)
- Total: ~6-8 minutes
What Runs in Parallel:
- CouchDB and MongoDB tests run simultaneously (matrix strategy)
- Unit tests run first, then Docker Compose tests start
Pull Request:
- Documentation build + quality checks: ~2-3 minutes
- No deployment (PR validation only)
Main Branch Push:
- Documentation build + quality + deployment: ~2-3 minutes
- GitHub Pages live within 1-2 minutes after workflow completion
For Pull Requests:
- Both workflows run in parallel
- Total time: ~6-8 minutes (max of either workflow)
For Main Branch Pushes:
- Testing + Documentation + Deployment
- Total time: ~6-8 minutes (parallel execution)
Simple is Better:
- ✅ Two focused workflows - testing and documentation (single responsibility)
- ✅ Essential automation only - comprehensive testing + documentation
- ✅ Fast feedback for developers
- ✅ Easy to understand and maintain
- ✅ Optimized performance - single-job documentation pipeline
Quality Without Complexity:
- ✅ Automated quality gates for code and documentation
- ✅ Parallel execution where beneficial
- ✅ Conditional deployment based on branch and checks
- ✅ Professional documentation with GitHub Pages integration
No Unnecessary Complexity:
- ❌ No performance testing
- ❌ No security scanning
- ❌ No scheduled runs
- ❌ No multiple test levels
- ❌ No advanced configurations
- ❌ No multi-job documentation workflows (optimized to single job)
1. Unit test failures:
# Run locally first
npm test
npm run test:coverage2. Docker Compose test failures:
# Test locally with proper credentials
export MONGODB_USERNAME="test_user"
export MONGODB_PASSWORD="test_password"
export MONGODB_DATABASE="test_db"
./test-docker-setups.sh mongodb3. Workflow syntax issues:
# Validate before pushing
./validate-ci.sh workflows-only4. Documentation generation failures:
# Test JSDoc compilation locally
npm run docs
# Check for JSDoc syntax errors
npx jsdoc --version5. Documentation coverage failures:
# Run coverage analysis locally
node scripts/check-docs-coverage.js
# Check for missing @param, @returns, @example tags6. GitHub Pages deployment failures:
# Verify documentation builds correctly
npm run docs
ls -la docs/ # Should contain index.html and other files
# Check GitHub Pages settings in repository7. Broken link detection failures:
# Test link validation locally
npm install -g linkinator
linkinator docs/ --recurse --silent --skip "https://www.linkedin.com/in/vadim-starichkov/"- Check workflow syntax:
./validate-ci.sh workflows-only - Test Docker Compose locally:
./test-docker-setups.sh both - Verify credentials setup: Check environment variables are set
- Review container logs: Available in GitHub Actions if tests fail
- Generate documentation locally:
npm run docs - Run quality checks:
node scripts/check-docs-coverage.js - Test local preview:
npm run docs:serve - Check GitHub Pages settings: Repository → Settings → Pages
- Review workflow logs: GitHub Actions → docs.yml workflow
- ✅ Unit tests pass with good coverage
- ✅ CouchDB integration works (API CRUD operations)
- ✅ MongoDB integration works (API CRUD operations)
- ✅ Clean execution (no leftover containers/volumes)
- ✅ Documentation generates successfully from JSDoc comments
- ✅ Quality checks pass (80% coverage threshold)
- ✅ No broken links in generated documentation
- ✅ GitHub Pages deployment succeeds (main branch only)
- ✅ Documentation is publicly accessible and up-to-date
- ✅ Both pipelines complete within expected time frames
- ✅ Parallel execution works without conflicts
- ✅ Quality gates prevent deployment of failing builds
- ✅ Fast feedback for developers on all aspects
Local testing:
# MongoDB
export MONGODB_USERNAME="your_username"
export MONGODB_PASSWORD="your_password"
export MONGODB_DATABASE="your_database"
# CouchDB
export COUCHDB_USERNAME="your_username"
export COUCHDB_PASSWORD="your_password"
export COUCHDB_DATABASE="your_database"In CI:
- Credentials are automatically generated with secure random values
- Each test run gets unique credentials
- No secrets need to be configured in GitHub repository settings
Local development:
# Node.js LTS version (required)
node --version # Should be 24.x
# Documentation generation
npm run docs # Generate docs
npm run docs:serve # Local preview
node scripts/check-docs-coverage.js # Quality checkGitHub Pages setup:
- Repository Settings → Pages
- Source: GitHub Actions
- Custom domain (optional): Configure in repository settings
- Automatic deployment on main branch pushes
Node.js Requirements:
{
"engines": {
"node": ">=20.0.0",
"npm": ">=10.0.0"
}
}Support is maintained for Node.js 20, 22, and 24, with 24 being the primary version used for coverage and documentation.
-
Always test locally first:
# Test code npm test ./validate-ci.sh quick # Test documentation npm run docs node scripts/check-docs-coverage.js
-
Ensure credentials are set when testing Docker Compose locally
-
Keep Docker environment clean after testing
-
Write comprehensive JSDoc comments:
/** * Brief description * @param {type} name - Description * @returns {type} Description * @throws {Error} When error occurs * @example * // Usage example */
-
Check documentation coverage before pushing - aim for 80%+
- Monitor CI execution times - should stay under 10 minutes total
- Review failed builds quickly - logs are available in GitHub Actions
- Keep workflows simple - resist adding complexity
- Monitor documentation quality:
- Check coverage reports in failed builds
- Ensure GitHub Pages deploys successfully
- Review documentation accuracy periodically
- Maintain Node.js LTS compatibility - update when new LTS releases
Developer Friendly:
- Fast feedback (~6-8 minutes total for both pipelines)
- Clear pass/fail status for testing and documentation
- Easy to debug when things go wrong
- Automatic documentation always up-to-date with code
Maintainable:
- Two focused workflows - clear separation of concerns
- Optimized job design - single job for documentation efficiency
- Simple dependencies - no complex conditional logic
- Quality gates prevent bad deployments
Reliable:
- Essential automation only - testing + documentation
- Proven patterns with industry best practices
- Minimal moving parts reduce failure points
- Professional documentation with automated quality control
Cost Effective:
- Efficient use of CI minutes - optimized single-job documentation
- Parallel execution where beneficial
- No redundant operations (eliminated duplicate checkouts/setups)
- Smart conditional deployment (main branch only)
Professional Results:
- Complete test coverage across database backends
- Always up-to-date documentation on GitHub Pages
- Quality-gated deployments ensure reliability
- Public API documentation for consumers
This comprehensive approach ensures that every commit is properly tested AND documented, providing both code quality and professional documentation without overwhelming complexity or long execution times.