Sharing Code Quality Best Practices
This repository provides reusable GitHub Actions workflows and guidelines for maintaining high-quality code in backend and frontend projects. It automates linting, formatting, dependency management, builds, and basic tests, ensuring consistent standards across projects.
-
Backend Quality Checks
-
Frontend Quality Checks
- Detects Node.js project type (npm, Yarn, pnpm)
- Dependency installation with caching for faster CI runs
- TypeScript type checks (if applicable)
- Build verification
- ESLint checks, including unused variables and imports
-
Full Stack Quality Check
- Combines backend and frontend checks
- Frontend check can run even if backend fails
- Provides a single entry point to validate the whole project
-
Reusable GitHub Actions Workflows
- Workflows can be triggered via
workflow_callfrom other repositories - Supports push, pull_request, and manual triggers
- Parameterized paths for backend and frontend projects
- Customizable lockfile paths for dependency caching
- Workflows can be triggered via
You can run backend and frontend quality checks individually by calling their respective workflows:
name: Run Backend and Frontend Quality Checks
on:
push:
branches: ["Dev"]
pull_request:
branches: ["Dev"]
workflow_dispatch:
jobs:
backend-quality:
uses: ./.github/workflows/backendQuality.yml
with:
branch: "Dev"
backend_path: "backend"
frontend-quality:
uses: ./.github/workflows/frontendQuality.yml
with:
branch: "Dev"
frontend_path: "Frontend"
lockfile_paths: "Frontend/package-lock.json"
needs: backend-qualityOptional: To run frontend checks regardless of backend result, add:
if: always()If you prefer a single entry point for both backend and frontend checks:
name: Run Full Stack Quality Checks
on:
push:
branches: ["Dev"]
pull_request:
branches: ["Dev"]
workflow_dispatch:
jobs:
call-quality-checker:
uses: ./.github/workflows/codeQualityChecker.yml
with:
branch: "Dev"
backend_path: "backend"
frontend_path: "Frontend"
lockfile_paths: "Frontend/package-lock.json"This workflow internally calls both backend and frontend workflows and ensures consistent full-stack validation.
| Input | Description | Default |
|---|---|---|
branch |
Target branch for code checks | "Dev" |
backend_path |
Path to backend project folder | "backend" |
frontend_path |
Path to frontend project folder | "Frontend" |
lockfile_paths |
Path(s) to lockfiles for caching dependencies | "Frontend/package-lock.json" |
- npm:
package-lock.json - Yarn:
yarn.lock - pnpm:
pnpm-lock.yaml
- Ensures consistent coding standards across projects
- Reduces manual effort for linting, testing, and builds
- Speeds up CI with dependency caching
- Easily extendable to add new quality checks
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-check) - Add or improve workflows
- Open a Pull Request
This repository is licensed under the MIT License. See LICENSE for details.
Do you want me to do that?