Skip to content

Commit 792f9f5

Browse files
authored
Merge pull request #66 from DevSecNinja/copilot/implement-automated-tagging-strategy
2 parents 9f7481c + b015f58 commit 792f9f5

5 files changed

Lines changed: 287 additions & 1 deletion

File tree

.github/LABELING.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Automated Labeling Strategy
2+
3+
This repository uses automated labeling for Pull Requests and Issues to improve organization and make it easier to identify the scope of changes.
4+
5+
## Pull Request Labels
6+
7+
PRs are automatically labeled based on the files changed:
8+
9+
- **frontend** - Changes to Next.js/TypeScript frontend code in `frontend/` directory
10+
- **backend** - Changes to Python/FastAPI backend code in `backend/` directory
11+
- **dependencies** - Updates to dependencies (package.json, requirements.txt, etc.)
12+
- **ci/cd** - Changes to GitHub Actions workflows or CI/CD scripts
13+
- **documentation** - Changes to Markdown documentation files
14+
- **docker** - Changes to Docker configuration files (Dockerfile, docker-compose.yml)
15+
- **tests** - Changes to test files or test configuration
16+
- **configuration** - Changes to configuration files (linters, git config, etc.)
17+
18+
### How It Works
19+
20+
The PR labeler runs automatically when a PR is:
21+
- Opened
22+
- Updated (new commits pushed)
23+
- Reopened
24+
25+
It uses the `.github/labeler.yml` configuration to match file paths to labels. The `sync-labels` option ensures labels are updated as the PR evolves.
26+
27+
## Issue Labels
28+
29+
Issues are automatically labeled based on keywords in the title and body:
30+
31+
- **frontend** - Keywords: frontend, ui, interface, next.js, react, typescript, css, tailwind
32+
- **backend** - Keywords: backend, api, fastapi, python, database, sqlite, endpoint, service
33+
- **docker** - Keywords: docker, container, image, dockerfile, docker-compose
34+
- **ci/cd** - Keywords: ci/cd, workflow, github actions, deployment, pipeline
35+
- **documentation** - Keywords: documentation, readme, docs, guide, tutorial
36+
- **bug** - Keywords: bug, error, crash, fail, broken, issue, problem, not working
37+
- **enhancement** - Keywords: feature, enhancement, improvement, add, new, request, suggestion
38+
- **security** - Keywords: security, vulnerability, cve, exploit, unsafe
39+
- **performance** - Keywords: performance, slow, optimize, speed, latency, memory
40+
- **dependencies** - Keywords: dependency, dependencies, package, npm, pip, upgrade, update version
41+
42+
### How It Works
43+
44+
The issue labeler runs automatically when an issue is:
45+
- Opened
46+
- Edited
47+
48+
It uses a GitHub Actions script to scan the issue title and body for relevant keywords and applies matching labels.
49+
50+
## Manual Label Management
51+
52+
While most labels are applied automatically, maintainers can still:
53+
- Add additional labels manually
54+
- Remove auto-applied labels if incorrect
55+
- Create custom labels for special cases
56+
57+
## Benefits
58+
59+
1. **Quick Identification**: See at a glance what areas of the codebase a PR affects
60+
2. **Better Organization**: Filter and search issues/PRs by component
61+
3. **Review Assignment**: Easily identify which team members should review
62+
4. **Release Notes**: Generate better changelogs grouped by component
63+
5. **Consistency**: Standardized labeling across all contributions
64+
65+
## Configuration Files
66+
67+
- `.github/labeler.yml` - PR labeling rules (path-based)
68+
- `.github/workflows/auto-label.yml` - PR labeling workflow
69+
- `.github/workflows/auto-label-issues.yml` - Issue labeling workflow
70+
71+
## Customization
72+
73+
To modify the labeling rules:
74+
75+
1. Edit `.github/labeler.yml` for PR path-based rules
76+
2. Edit `.github/workflows/auto-label-issues.yml` to adjust issue keyword matching
77+
3. Test changes by creating a PR or issue
78+
79+
For more information on the labeler syntax, see:
80+
- [actions/labeler documentation](https://github.com/actions/labeler)
81+
- [GitHub Actions documentation](https://docs.github.com/en/actions)

.github/labeler.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# Automated labeling configuration for hadiscover PRs
3+
# See https://github.com/actions/labeler for syntax
4+
5+
# Frontend changes (Next.js, TypeScript, UI)
6+
frontend:
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- 'frontend/**/*'
10+
- 'biome.json'
11+
12+
# Backend changes (Python, FastAPI, API)
13+
backend:
14+
- changed-files:
15+
- any-glob-to-any-file:
16+
- 'backend/**/*'
17+
- 'pyproject.toml'
18+
- 'bandit.yml'
19+
20+
# Dependency updates
21+
dependencies:
22+
- changed-files:
23+
- any-glob-to-any-file:
24+
- 'package.json'
25+
- 'package-lock.json'
26+
- 'requirements.txt'
27+
- 'backend/requirements.txt'
28+
- 'renovate.json'
29+
30+
# CI/CD workflow changes
31+
ci/cd:
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- '.github/workflows/**/*'
35+
- '.github/scripts/**/*'
36+
37+
# Documentation changes
38+
documentation:
39+
- changed-files:
40+
- any-glob-to-any-file:
41+
- '**/*.md'
42+
- '.github/copilot-instructions.md'
43+
44+
# Docker configuration
45+
docker:
46+
- changed-files:
47+
- any-glob-to-any-file:
48+
- '**/Dockerfile'
49+
- '**/docker-compose*.yml'
50+
- '**/.dockerignore'
51+
52+
# Tests
53+
tests:
54+
- changed-files:
55+
- any-glob-to-any-file:
56+
- 'backend/tests/**/*'
57+
- '**/test_*.py'
58+
- '**/*_test.py'
59+
- 'pytest.ini'
60+
61+
# Configuration files
62+
configuration:
63+
- changed-files:
64+
- any-glob-to-any-file:
65+
- '.editorconfig'
66+
- '.gitignore'
67+
- '.pre-commit-config.yaml'
68+
- '.markdown-lint.yml'
69+
- 'setup.sh'
70+
- 'start.sh'
71+
- 'stop.sh'
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Auto Label Issues
3+
4+
on: # yamllint disable-line rule:truthy
5+
issues:
6+
types: [opened, edited]
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
12+
jobs:
13+
label:
14+
name: Label Issue
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Label issues based on keywords
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const issue = context.payload.issue;
23+
const title = issue.title.toLowerCase();
24+
const body = (issue.body || '').toLowerCase();
25+
const text = title + ' ' + body;
26+
27+
const labels = [];
28+
29+
// Frontend related keywords
30+
const frontendPattern =
31+
/frontend|ui|interface|next\.?js|react|typescript|tsx|css|tailwind/;
32+
if (text.match(frontendPattern)) {
33+
labels.push('frontend');
34+
}
35+
36+
// Backend related keywords
37+
const backendPattern =
38+
/backend|api|fastapi|python|database|sqlite|endpoint|service/;
39+
if (text.match(backendPattern)) {
40+
labels.push('backend');
41+
}
42+
43+
// Docker related keywords
44+
const dockerPattern =
45+
/docker|container|image|dockerfile|docker-compose/;
46+
if (text.match(dockerPattern)) {
47+
labels.push('docker');
48+
}
49+
50+
// CI/CD related keywords
51+
const cicdPattern =
52+
/ci\/cd|workflow|github actions|deployment|pipeline/;
53+
if (text.match(cicdPattern)) {
54+
labels.push('ci/cd');
55+
}
56+
57+
// Documentation related keywords
58+
const docsPattern =
59+
/documentation|readme|docs|guide|tutorial/;
60+
if (text.match(docsPattern)) {
61+
labels.push('documentation');
62+
}
63+
64+
// Bug related keywords
65+
const bugPattern =
66+
/bug|error|crash|fail|broken|problem|not working/;
67+
if (text.match(bugPattern)) {
68+
labels.push('bug');
69+
}
70+
71+
// Enhancement related keywords
72+
const enhancementPattern =
73+
/feature|enhancement|improvement|add|new|request|suggestion/;
74+
if (text.match(enhancementPattern)) {
75+
labels.push('enhancement');
76+
}
77+
78+
// Security related keywords
79+
const securityPattern =
80+
/security|vulnerability|cve|exploit|unsafe/;
81+
if (text.match(securityPattern)) {
82+
labels.push('security');
83+
}
84+
85+
// Performance related keywords
86+
const performancePattern =
87+
/performance|slow|optimize|speed|latency|memory/;
88+
if (text.match(performancePattern)) {
89+
labels.push('performance');
90+
}
91+
92+
// Dependencies related keywords
93+
const depsPattern =
94+
/dependency|dependencies|package|npm|pip|upgrade|update.*version/;
95+
if (text.match(depsPattern)) {
96+
labels.push('dependencies');
97+
}
98+
99+
if (labels.length > 0) {
100+
await github.rest.issues.addLabels({
101+
owner: context.repo.owner,
102+
repo: context.repo.repo,
103+
issue_number: issue.number,
104+
labels: labels
105+
});
106+
}

.github/workflows/auto-label.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Auto Label PRs
3+
4+
on: # yamllint disable-line rule:truthy
5+
pull_request_target:
6+
types: [opened, synchronize, reopened]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
12+
jobs:
13+
label:
14+
name: Label PR
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v6
20+
with:
21+
persist-credentials: false
22+
23+
- name: Apply labels
24+
uses: actions/labeler@v5
25+
with:
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
configuration-path: .github/labeler.yml
28+
sync-labels: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ OpenAPI/Swagger docs available at <http://localhost:8000/docs> once running.
127127
## More Information
128128

129129
- **Architecture**: See [ARCHITECTURE.md](./ARCHITECTURE.md) for technical details
130-
- **Contributing**: PRs welcome! Open an issue for bugs or feature requests
130+
- **Contributing**: PRs welcome! Open an issue for bugs or feature requests. PRs are automatically labeled based on changed files—see [.github/LABELING.md](./.github/LABELING.md) for details
131131
- **License**: MIT License
132132
- **Stack**: FastAPI (Python), Next.js (TypeScript), SQLite
133133
- **Inspired by**: [kubesearch.dev](https://kubesearch.dev)

0 commit comments

Comments
 (0)