Skip to content

Commit 334ca81

Browse files
committed
feat: creeper
1 parent 74a4685 commit 334ca81

File tree

9 files changed

+5347
-0
lines changed

9 files changed

+5347
-0
lines changed

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release Action
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Build
25+
run: npm run build
26+
27+
- name: Create Release
28+
id: create_release
29+
uses: actions/create-release@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: ${{ github.ref }}
34+
release_name: Release ${{ github.ref }}
35+
draft: false
36+
prerelease: false
37+
38+
- name: Upload Release Asset
39+
uses: actions/upload-release-asset@v1
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
with:
43+
upload_url: ${{ steps.create_release.outputs.upload_url }}
44+
asset_path: ./dist/index.js
45+
asset_name: index.js
46+
asset_content_type: application/javascript

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test TODO Creeper
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test-todo-scan:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build action
26+
run: npm run build
27+
28+
- name: Test TODO scan
29+
id: todo-scan
30+
uses: ./
31+
with:
32+
threshold: 5
33+
exclude-patterns: 'node_modules,dist,build,.git'
34+
35+
- name: Display results
36+
run: |
37+
echo "TODO count: ${{ steps.todo-scan.outputs.todo-count }}"
38+
echo "Files with TODOs: ${{ steps.todo-scan.outputs.todo-files }}"

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build outputs
8+
dist/
9+
build/
10+
11+
# Environment variables
12+
.env
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
# IDE files
19+
.vscode/
20+
.idea/
21+
*.swp
22+
*.swo
23+
24+
# OS files
25+
.DS_Store
26+
Thumbs.db
27+
28+
# Test files (remove these if you want to keep them for demonstration)
29+
test-example.js
30+
test-example.py
31+
test-local.js
32+
33+
# Logs
34+
logs
35+
*.log

README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# TODO Creeper
2+
3+
A GitHub Action that helps you identify and track TODO comments as they creep into your codebase. This action scans your repository for TODO, FIXME, and HACK comments and can fail your workflow if the count exceeds a specified threshold.
4+
5+
## Features
6+
7+
- 🔍 **Comprehensive Scanning**: Detects TODO, FIXME, and HACK comments across multiple programming languages
8+
- 📊 **Detailed Reporting**: Provides count, file distribution, and detailed location information
9+
- ⚙️ **Configurable Thresholds**: Set maximum allowed TODO count before action fails
10+
- 🚫 **Exclusion Patterns**: Skip specific directories and files (e.g., node_modules, build artifacts)
11+
- 📈 **Action Outputs**: Expose TODO statistics for use in other workflow steps
12+
13+
## Supported Comment Patterns
14+
15+
The action detects the following comment patterns:
16+
17+
- `// TODO` - JavaScript, TypeScript, Java, C#, etc.
18+
- `/* TODO */` - Multi-line comments
19+
- `# TODO` - Python, Shell scripts, YAML, etc.
20+
- `<!-- TODO -->` - HTML, XML, Markdown
21+
- `// FIXME` - Similar patterns for FIXME comments
22+
- `// HACK` - Similar patterns for HACK comments
23+
24+
## Usage
25+
26+
### Basic Usage
27+
28+
```yaml
29+
name: Check TODOs
30+
on: [push, pull_request]
31+
32+
jobs:
33+
todo-check:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Scan for TODOs
39+
uses: Gustrb/todo-creeper@v1
40+
with:
41+
threshold: 10
42+
```
43+
44+
### Advanced Usage
45+
46+
```yaml
47+
name: Comprehensive TODO Check
48+
on: [push, pull_request]
49+
50+
jobs:
51+
todo-analysis:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Scan for TODOs
57+
id: todo-scan
58+
uses: Gustrb/todo-creeper@v1
59+
with:
60+
threshold: 5
61+
exclude-patterns: 'node_modules,dist,build,.git,tests/mocks'
62+
63+
- name: Report TODO Count
64+
run: |
65+
echo "Found ${{ steps.todo-scan.outputs.todo-count }} TODOs"
66+
echo "Across ${{ steps.todo-scan.outputs.todo-files }} files"
67+
68+
- name: Create TODO Report
69+
if: steps.todo-scan.outputs.todo-count != '0'
70+
run: |
71+
echo "## TODO Report" >> $GITHUB_STEP_SUMMARY
72+
echo "Found ${{ steps.todo-scan.outputs.todo-count }} TODOs" >> $GITHUB_STEP_SUMMARY
73+
echo "Files affected: ${{ steps.todo-scan.outputs.todo-files }}" >> $GITHUB_STEP_SUMMARY
74+
```
75+
76+
## Inputs
77+
78+
| Input | Description | Required | Default |
79+
|-------|-------------|----------|---------|
80+
| `token` | GitHub token for API access | Yes | `${{ github.token }}` |
81+
| `threshold` | Maximum number of TODOs allowed before action fails | No | `10` |
82+
| `exclude-patterns` | Comma-separated patterns to exclude from TODO search | No | `node_modules,dist,build,.git` |
83+
84+
## Outputs
85+
86+
| Output | Description |
87+
|--------|-------------|
88+
| `todo-count` | Total number of TODOs found |
89+
| `todo-files` | Number of files containing TODOs |
90+
| `todo-details` | JSON string with detailed TODO information |
91+
92+
## Example Output
93+
94+
```
95+
🔍 Starting TODO scan...
96+
📊 Found 3 TODOs across 2 files
97+
98+
📝 TODO Details:
99+
1. src/utils.js:15 - // TODO: Implement error handling
100+
2. src/components/Button.jsx:42 - // TODO: Add loading state
101+
3. docs/README.md:8 - <!-- TODO: Add API documentation -->
102+
103+
✅ TODO count (3) is within threshold (10)
104+
```
105+
106+
## Supported File Types
107+
108+
The action scans files with the following extensions:
109+
- JavaScript/TypeScript: `.js`, `.jsx`, `.ts`, `.tsx`
110+
- Python: `.py`
111+
- Java: `.java`
112+
- C/C++: `.cpp`, `.c`
113+
- C#: `.cs`
114+
- PHP: `.php`
115+
- Ruby: `.rb`
116+
- Go: `.go`
117+
- Rust: `.rs`
118+
- Swift: `.swift`
119+
- Kotlin: `.kt`
120+
- Scala: `.scala`
121+
- Clojure: `.clj`
122+
- Haskell: `.hs`
123+
- OCaml: `.ml`
124+
- F#: `.fs`
125+
- Visual Basic: `.vb`
126+
- SQL: `.sql`
127+
- Shell scripts: `.sh`, `.bash`, `.zsh`, `.fish`
128+
- PowerShell: `.ps1`
129+
- Batch files: `.bat`, `.cmd`
130+
- Configuration: `.yml`, `.yaml`, `.json`, `.xml`
131+
- Web: `.html`, `.css`, `.scss`, `.sass`, `.less`
132+
- Frameworks: `.vue`, `.svelte`
133+
- Documentation: `.md`, `.txt`
134+
135+
## Contributing
136+
137+
Contributions are welcome! Please feel free to submit a Pull Request.
138+
139+
## License
140+
141+
This project is licensed under the ISC License.

action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Todo Creeper
2+
description: Identify as TODOs creep into a project's code
3+
4+
inputs:
5+
token:
6+
description: GitHub token for API access
7+
required: true
8+
default: ${{ github.token }}
9+
10+
threshold:
11+
description: Maximum number of TODOs allowed before action fails
12+
required: false
13+
default: '10'
14+
15+
exclude-patterns:
16+
description: Comma-separated patterns to exclude from TODO search
17+
required: false
18+
default: 'node_modules,dist,build,.git'
19+
20+
outputs:
21+
todo-count:
22+
description: Total number of TODOs found
23+
todo-files:
24+
description: Number of files containing TODOs
25+
todo-details:
26+
description: Detailed TODO information
27+
28+
runs:
29+
using: node20
30+
main: dist/index.js
31+

example-workflow.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Example TODO Check
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
check-todos:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Scan for TODOs
17+
id: todo-scan
18+
uses: Gustrb/todo-creeper@v1
19+
with:
20+
threshold: 5
21+
exclude-patterns: 'node_modules,dist,build,.git,tests/mocks'
22+
23+
- name: Create TODO Report
24+
if: steps.todo-scan.outputs.todo-count != '0'
25+
run: |
26+
echo "## 📋 TODO Report" >> $GITHUB_STEP_SUMMARY
27+
echo "" >> $GITHUB_STEP_SUMMARY
28+
echo "**Total TODOs found:** ${{ steps.todo-scan.outputs.todo-count }}" >> $GITHUB_STEP_SUMMARY
29+
echo "**Files affected:** ${{ steps.todo-scan.outputs.todo-files }}" >> $GITHUB_STEP_SUMMARY
30+
echo "" >> $GITHUB_STEP_SUMMARY
31+
echo "### TODO Details:" >> $GITHUB_STEP_SUMMARY
32+
echo '```json' >> $GITHUB_STEP_SUMMARY
33+
echo '${{ steps.todo-scan.outputs.todo-details }}' >> $GITHUB_STEP_SUMMARY
34+
echo '```' >> $GITHUB_STEP_SUMMARY
35+
36+
- name: Comment on PR
37+
if: github.event_name == 'pull_request' && steps.todo-scan.outputs.todo-count != '0'
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
const todoCount = '${{ steps.todo-scan.outputs.todo-count }}';
42+
const todoFiles = '${{ steps.todo-scan.outputs.todo-files }}';
43+
44+
github.rest.issues.createComment({
45+
issue_number: context.issue.number,
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: `🔍 **TODO Creeper Report**
49+
50+
Found **${todoCount} TODOs** across **${todoFiles} files**.
51+
52+
Consider addressing these TODOs to improve code quality!`
53+
});

0 commit comments

Comments
 (0)