This repository uses automated code review via GitHub Actions to ensure code quality, security, and build integrity.
The code review workflow (code-review.yml) automatically runs when:
- A pull request is opened or updated targeting the
mainbranch - Code is pushed directly to the
mainbranch
This stage validates the code quality and ensures the application builds successfully:
- Dependency Installation: Installs all client dependencies using
npm ci - Prettier Format Check: Validates code formatting against Prettier rules
- Build Verification: Ensures the React application builds without errors
- Test Execution: Runs all client-side tests (if available)
- Dependency Installation: Installs all server dependencies using
npm ci - Syntax Validation: Checks for JavaScript syntax errors
- Dependency Audit: Validates package.json dependencies
This stage identifies potential security vulnerabilities:
- CodeQL Analysis: Performs advanced security and quality analysis on JavaScript code
- Dependency Audit (Client): Scans client dependencies for known vulnerabilities
- Dependency Audit (Server): Scans server dependencies for known vulnerabilities
This stage ensures Docker images can be built successfully:
- Client Docker Build: Validates the client Dockerfile
- Server Docker Build: Validates the server Dockerfile
- Docker Compose Check: Verifies docker-compose.yaml configuration
Provides an overall summary of all checks and reports the final status.
You can add the following badge to your README.md to show the workflow status:
Some checks are currently set to continue-on-error: true, which means they report issues but don't block the workflow:
- Prettier formatting check: Allows formatting violations (remove flag once codebase is fully formatted)
- Client tests: Allows test failures (remove flag once all tests pass consistently)
- Package validation: Allows dependency warnings (remove flag once dependencies are resolved)
- npm audit: Allows security vulnerabilities (remove flag once critical issues are resolved)
These flags are in place to avoid blocking the workflow on pre-existing issues. As you improve the codebase:
- Fix the underlying issues (formatting, tests, dependencies, vulnerabilities)
- Remove the corresponding
continue-on-error: trueflag from.github/workflows/code-review.yml - Enforce strict checks for new code
If the Prettier check fails, run the following to format your code:
cd client
npx prettier --write "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}"If the build fails, check the error logs in the GitHub Actions tab. Common issues include:
- Missing environment variables
- Dependency conflicts
- Syntax errors
If security vulnerabilities are detected:
- Review the CodeQL alerts in the Security tab
- Run
npm audit fixin the affected directory (client or server) - Update vulnerable dependencies
If Docker builds fail:
- Test locally with
docker build -t test ./clientordocker build -t test ./server - Ensure all required files are present and not in .dockerignore
- Check Dockerfile syntax and paths
Before pushing code, you can run these checks locally:
# Client checks
cd client
npm ci
npx prettier --check "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}"
npm run build
npm test
# Server checks
cd server
npm ci
node -c index.js
npm audit
# Docker checks
docker build -t edtech-client:test ./client
docker build -t edtech-server:test ./server
docker-compose configThe workflow uses:
- Node.js version: 18.x
- Runner: ubuntu-latest
- Permissions: Read access to code, write access for security events
This workflow is part of the CI/CD pipeline mentioned in the README. It ensures that:
- All code changes are reviewed automatically
- Security vulnerabilities are caught early
- Build integrity is maintained
- Code quality standards are enforced
Potential improvements to the code review workflow:
- Add ESLint configuration and checks
- Implement code coverage reporting
- Add performance testing
- Integrate automated PR comments with review results
- Add deployment preview for approved PRs