This project uses GitHub Actions to automate code quality checks, testing, and build verification on every pull request and push.
Triggers: On push to main/develop and all pull requests
Purpose: Validates code quality, runs tests, and verifies builds
Jobs:
-
Linting (
lint)- Runs on Node 20.x and 22.x
- Executes ESLint checks
- Verifies code formatting with Prettier
- Fails if violations found
-
Build (
build)- Runs on Node 20.x and 22.x
- Installs dependencies
- Generates Prisma client
- Compiles TypeScript
- Uploads build artifacts
-
Tests (
test)- Runs on Node 20.x and 22.x
- Provides PostgreSQL 16 and Redis 7 services
- Runs test suite with coverage
- Uploads coverage reports
-
Docker Build Check (
docker-build)- Validates Dockerfile builds successfully
- Uses build cache for efficiency
- No Docker image push
-
CI Status (
ci-status)- Final status check
- Aggregates all job results
- Prevents merge if any job fails
Triggers: On push, pull requests, and daily schedule (2 AM UTC)
Purpose: Analyzes code quality and security vulnerabilities
Jobs:
-
Code Quality Analysis (
code-quality)- Lists dependencies
- Checks for unused packages
-
Dependency Security Scan (
dependency-check)- Runs
npm auditfor production dependencies - Runs full
npm auditincluding dev dependencies - Reports vulnerabilities (non-blocking)
- Runs
-
TypeScript Type Checking (
type-check)- Strict TypeScript validation
- Ensures no type errors
Before pushing, run these checks locally to catch issues early:
# Format code
npm run format
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Build application
npm run build
# Generate Prisma client
npm run prisma:generate
# Run tests (when implemented)
npm testInstall a pre-commit hook to run linting and formatting automatically:
# Create pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/sh
npm run lint:fix
npm run format
EOF
# Make it executable
chmod +x .git/hooks/pre-commit| Script | Purpose |
|---|---|
npm run build |
Compile TypeScript to JavaScript |
npm run lint |
Check code with ESLint |
npm run lint:fix |
Fix linting issues automatically |
npm run format |
Format code with Prettier |
npm run format:check |
Check if code matches Prettier rules |
npm test |
Run test suite |
npm run test:ci |
Run tests in CI mode with coverage |
npm run prisma:generate |
Generate Prisma client |
Before a pull request can be merged, all of the following must pass:
✅ Linting - No ESLint violations
✅ Formatting - Code matches Prettier rules
✅ Build - TypeScript compilation succeeds
✅ Tests - All tests pass
✅ Docker Build - Dockerfile builds without errors
A PR template is provided at .github/PULL_REQUEST_TEMPLATE.md to guide contributors. It includes:
- Change description
- Type of change
- Related issues
- Testing checklist
- Code quality checklist
Ensure dependencies are installed:
npm ciMake sure you're on the same Node version as CI (check .github/workflows/ci.yml):
node --version # Should be v20.x or v22.x
nvm use 22 # Switch to Node 22Fix automatically:
npm run lint:fixFormat entire codebase:
npm run formatRegenerate Prisma client:
npm run prisma:generateCheck if services (PostgreSQL, Redis) are running:
docker-compose up -d postgres redis
npm testAdd this to your README to show CI status:
[](https://github.com/sentinel-security-productions/Sentinel/actions/workflows/ci.yml)
[](https://github.com/sentinel-security-productions/Sentinel/actions/workflows/code-quality.yml)- Main CI:
.github/workflows/ci.yml - Code Quality:
.github/workflows/code-quality.yml - PR Template:
.github/PULL_REQUEST_TEMPLATE.md
CI jobs use the following environment variables:
| Variable | Value | Purpose |
|---|---|---|
DATABASE_URL |
postgresql://test_user:test_password@localhost:5432/test_db |
Test database connection |
REDIS_URL |
redis://localhost:6379 |
Test Redis connection |
- Workflows use GitHub Actions cache for npm dependencies
- Docker builds use layer caching to speed up subsequent runs
- Node matrix (20.x and 22.x) tests compatibility
- Parallel job execution reduces total pipeline time
Edit .github/workflows/*.yml and update:
matrix:
node-version: [20.x, 22.x] # Update hereKeep ESLint, Prettier, and TypeScript packages up to date:
npm update @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint prettierCreate new workflow files in .github/workflows/ following the same pattern.
- Implement tests: Update
testscript inpackage.json - Configure coverage reporting: Add coverage thresholds
- Setup branch protection rules: Require CI to pass before merge
- Add SARIF reports: For security scanning results
- Integrate with external services: CodeCov, SonarQube, etc.
For issues with CI:
- Check workflow logs in GitHub Actions tab
- Review this documentation
- Test locally with same Node version
- Open an issue with workflow logs attached