Automated code quality enforcement for your pull requests. Never merge substandard code again!
A GitHub Action that enforces code quality standards on every pull request. Supports Node.js, Java, and Spring Boot projects. Blocks merges if code doesn't meet quality thresholds.
| Feature | Description |
|---|---|
| ๐ Multi-Language Support | Node.js, Java, Spring Boot |
| ๐ Coverage Checking | Ensures minimum code coverage percentage |
| ๐ Linting Enforcement | ESLint (Node.js), Checkstyle (Java) |
| โ Type Checking | TypeScript (Node.js), Compilation (Java) |
| ๐ฎ Auto-Detection | Automatically detects project type |
| ๐ฌ PR Comments | Posts detailed results directly on PRs |
| ๐ฅ Check Status | Integrates with branch protection rules |
When a PR fails quality gates:
โ Code Quality Gate FAILED
### Coverage
โ Coverage: 45% (threshold: 70%)
### Linting
โ
No linting errors found
### Type Checking
โ TypeScript errors found: 3 error(s)
Please fix the issues above before merging.
When a PR passes:
โ
Code Quality Gate PASSED
### Coverage
โ
Coverage: 85% (threshold: 70%)
### Linting
โ
No linting errors found
### Type Checking
โ
No TypeScript errors found
All quality gates passed! ๐
Create .github/workflows/quality-gate.yml:
name: Code Quality Gate
on:
pull_request:
branches: [main, develop]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run test:coverage
- name: Run quality gate
uses: tahseen137/code-quality-gate-bot@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
project-type: nodejs
coverage-threshold: 70name: Code Quality Gate
on:
pull_request:
branches: [main, develop]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Run tests with coverage
run: mvn clean test jacoco:report
- name: Run quality gate
uses: tahseen137/code-quality-gate-bot@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
project-type: springboot
coverage-threshold: 70
coverage-report-path: target/site/jacoco/jacoco.xmlEnsure your package.json has these scripts:
{
"scripts": {
"test:coverage": "jest --coverage",
"lint": "eslint src --ext .ts",
"type-check": "tsc --noEmit"
}
}Add Jacoco plugin to pom.xml:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>- Go to Settings โ Branches
- Click Add rule for your main branch
- Check Require status checks to pass before merging
- Search for and select Code Quality Gate
Now PRs cannot be merged until quality gates pass! ๐
| Input | Required | Default | Description |
|---|---|---|---|
github-token |
Yes | - | GitHub token for API access |
project-type |
No | auto |
Project type: nodejs, java, springboot, or auto |
coverage-threshold |
No | 70 |
Minimum code coverage percentage |
coverage-report-path |
No | auto | Path to coverage report (auto-detected if not provided) |
| Project Type | Default Path |
|---|---|
| Node.js | coverage/coverage-final.json |
| Java/Spring Boot | target/site/jacoco/jacoco.xml |
| Language | Linting | Type Check | Coverage |
|---|---|---|---|
| Node.js/TypeScript | ESLint | TypeScript | Jest/Vitest |
| Java | Checkstyle | Maven/Gradle | Jacoco |
| Spring Boot | Checkstyle | Maven/Gradle | Jacoco |
# Install dependencies
npm install
# Build the project
npm run build
# Run linting
npm run lint
# Type check
npm run type-check- Python support (pytest)
- Go support
- Rust support
- Configuration file (.quality-gate.yml)
- Slack/Discord notifications
- Custom linting rules
- Ignore patterns
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with:
Made with โค๏ธ by Tahseen-ur Rahman