forked from claude-did-this/claude-hub
refactor: Clean up project root directory structure
- Remove backup Dockerfile and temporary benchmark results - Organize scripts and documentation into proper directories - Update CLAUDE.md to reference actual script locations instead of wrappers - Enhance .gitignore to prevent future root directory clutter - Move utilities to appropriate locations (cli/, test/, docs/) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Cheffromspace
parent
cf92900bad
commit
2662ed41da
16
.gitignore
vendored
16
.gitignore
vendored
@@ -65,4 +65,18 @@ auth.json
|
||||
service-account.json
|
||||
|
||||
# Docker secrets
|
||||
secrets/
|
||||
secrets/
|
||||
|
||||
# Benchmark results
|
||||
benchmark_results_*.json
|
||||
|
||||
# Temporary and backup files
|
||||
*.backup
|
||||
*.tmp
|
||||
*~
|
||||
.#*
|
||||
|
||||
# Root level clutter prevention
|
||||
/test-*.js
|
||||
/PR_SUMMARY.md
|
||||
/*-proposal.md
|
||||
@@ -24,7 +24,7 @@ This repository contains a webhook service that integrates Claude with GitHub, a
|
||||
- **Start with Docker (recommended)**: `docker compose up -d`
|
||||
- **Start the server locally**: `npm start`
|
||||
- **Development mode with auto-restart**: `npm run dev`
|
||||
- **Start on specific port**: `./start-api.sh` (uses port 3003)
|
||||
- **Start on specific port**: `./scripts/runtime/start-api.sh` (uses port 3003)
|
||||
- **Run tests**: `npm test`
|
||||
- Run specific test types:
|
||||
- Unit tests: `npm run test:unit`
|
||||
@@ -39,14 +39,14 @@ This repository contains a webhook service that integrates Claude with GitHub, a
|
||||
- **View logs**: `docker compose logs -f webhook`
|
||||
- **Restart**: `docker compose restart webhook`
|
||||
- Build Claude container: `./build-claude-container.sh`
|
||||
- Build Claude Code container: `./build-claudecode.sh`
|
||||
- Build Claude Code container: `./scripts/build/build-claudecode.sh`
|
||||
- Update production image: `./update-production-image.sh`
|
||||
|
||||
### AWS Credential Management
|
||||
- Create AWS profile: `./scripts/create-aws-profile.sh`
|
||||
- Migrate from static credentials: `./scripts/migrate-aws-credentials.sh`
|
||||
- Setup AWS profiles: `./scripts/setup-aws-profiles.sh`
|
||||
- Setup Claude authentication: `./setup-claude-auth.sh`
|
||||
- Setup Claude authentication: `./scripts/setup/setup-claude-auth.sh`
|
||||
|
||||
### Testing Utilities
|
||||
- Test Claude API directly: `node test/test-claude-api.js owner/repo`
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
FROM node:24
|
||||
|
||||
ARG TZ
|
||||
ENV TZ="$TZ"
|
||||
|
||||
# Install basic development tools and iptables/ipset
|
||||
RUN apt update && apt install -y less \
|
||||
git \
|
||||
procps \
|
||||
sudo \
|
||||
fzf \
|
||||
zsh \
|
||||
man-db \
|
||||
unzip \
|
||||
gnupg2 \
|
||||
gh \
|
||||
iptables \
|
||||
ipset \
|
||||
iproute2 \
|
||||
dnsutils \
|
||||
aggregate \
|
||||
jq
|
||||
|
||||
# Ensure default node user has access to /usr/local/share
|
||||
RUN mkdir -p /usr/local/share/npm-global && \
|
||||
chown -R node:node /usr/local/share
|
||||
|
||||
ARG USERNAME=node
|
||||
|
||||
# Persist bash history.
|
||||
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
|
||||
&& mkdir /commandhistory \
|
||||
&& touch /commandhistory/.bash_history \
|
||||
&& chown -R $USERNAME /commandhistory
|
||||
|
||||
# Set `DEVCONTAINER` environment variable to help with orientation
|
||||
ENV DEVCONTAINER=true
|
||||
|
||||
# Create workspace and config directories and set permissions
|
||||
RUN mkdir -p /workspace /home/node/.claude && \
|
||||
chown -R node:node /workspace /home/node/.claude
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN ARCH=$(dpkg --print-architecture) && \
|
||||
wget "https://github.com/dandavison/delta/releases/download/0.18.2/git-delta_0.18.2_${ARCH}.deb" && \
|
||||
sudo dpkg -i "git-delta_0.18.2_${ARCH}.deb" && \
|
||||
rm "git-delta_0.18.2_${ARCH}.deb"
|
||||
|
||||
# Set up non-root user
|
||||
USER node
|
||||
|
||||
# Install global packages
|
||||
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
|
||||
ENV PATH=$PATH:/usr/local/share/npm-global/bin
|
||||
|
||||
# Set the default shell to bash rather than sh
|
||||
ENV SHELL /bin/zsh
|
||||
|
||||
# Default powerline10k theme
|
||||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.0/zsh-in-docker.sh)" -- \
|
||||
-p git \
|
||||
-p fzf \
|
||||
-a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \
|
||||
-a "source /usr/share/doc/fzf/examples/completion.zsh" \
|
||||
-a "export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
|
||||
-x
|
||||
|
||||
# Install Claude
|
||||
RUN npm install -g @anthropic-ai/claude-code
|
||||
|
||||
# Copy and set up firewall script
|
||||
COPY init-firewall.sh /usr/local/bin/
|
||||
USER root
|
||||
RUN chmod +x /usr/local/bin/init-firewall.sh && \
|
||||
echo "node ALL=(root) NOPASSWD: /usr/local/bin/init-firewall.sh" > /etc/sudoers.d/node-firewall && \
|
||||
chmod 0440 /etc/sudoers.d/node-firewall
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY claudecode-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Run as root to allow permission management
|
||||
USER root
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
177
PR_SUMMARY.md
177
PR_SUMMARY.md
@@ -1,177 +0,0 @@
|
||||
# PR: Add Comprehensive CI/CD Pipeline with Automated PR Reviews
|
||||
|
||||
## 🚀 Summary
|
||||
|
||||
This PR implements a complete CI/CD pipeline with GitHub Actions, automated PR reviews, code quality tools, and security scanning.
|
||||
|
||||
## 🔧 Changes Made
|
||||
|
||||
### GitHub Actions Workflows
|
||||
- **CI Pipeline** (`.github/workflows/ci.yml`)
|
||||
- Multi-stage testing (unit, integration, e2e)
|
||||
- ESLint code quality checks
|
||||
- Docker image building and testing
|
||||
- Automatic deployment to staging
|
||||
- Code coverage reporting
|
||||
|
||||
- **Security Scanning** (`.github/workflows/security.yml`)
|
||||
- Daily dependency vulnerability scans
|
||||
- Secret detection with TruffleHog
|
||||
- CodeQL static analysis
|
||||
- npm audit security checks
|
||||
|
||||
### Automated PR Review System
|
||||
- **Trigger**: `check_suite` webhook with `conclusion: 'success'`
|
||||
- **Process**: Comprehensive code review using Claude with GitHub CLI
|
||||
- **Coverage**: Security, logic, performance, and code quality analysis
|
||||
- **Output**: Line-specific comments and review decisions
|
||||
|
||||
### Code Quality Tools
|
||||
- **ESLint** configuration for JavaScript/Node.js
|
||||
- **Prettier** for consistent code formatting
|
||||
- **Pre-commit hooks** for quality gates
|
||||
- **Package.json** scripts for linting, formatting, and security
|
||||
|
||||
### Project Templates
|
||||
- **Pull Request Template** with comprehensive checklist
|
||||
- **Bug Report Template** with structured issue reporting
|
||||
- **Feature Request Template** for new functionality requests
|
||||
- **Dependabot Configuration** for automated dependency updates
|
||||
|
||||
### Documentation
|
||||
- **CI/CD Setup Guide** (`docs/ci-cd-setup.md`)
|
||||
- **Updated README** with status badges and CI information
|
||||
- **Updated CLAUDE.md** with new CI/CD commands
|
||||
|
||||
### Testing Infrastructure
|
||||
- **Check Suite Tests** for automated PR review functionality
|
||||
- **Enhanced Test Coverage** for new webhook events
|
||||
- **Test Environment** configuration for CI
|
||||
|
||||
## 🔒 Security Features
|
||||
|
||||
- **Dependency Scanning**: Daily vulnerability detection
|
||||
- **Secret Scanning**: Repository-wide credential detection
|
||||
- **SAST Analysis**: Static code analysis with CodeQL
|
||||
- **Automated Updates**: Security patches via Dependabot
|
||||
|
||||
## 🏗️ Infrastructure
|
||||
|
||||
### Docker Integration
|
||||
- **Multi-image builds**: Webhook service + Claude Code runner
|
||||
- **Registry publishing**: GitHub Container Registry
|
||||
- **Health checks**: Container validation in CI
|
||||
|
||||
### Quality Gates
|
||||
- ✅ All tests must pass
|
||||
- ✅ No linting violations
|
||||
- ✅ Security scans clear
|
||||
- ✅ Docker builds successful
|
||||
|
||||
## 📊 Test Coverage
|
||||
|
||||
```
|
||||
File | % Stmts | % Branch | % Funcs | % Lines |
|
||||
---------------------------|---------|----------|---------|---------|
|
||||
All files | 58.98 | 63.8 | 71.42 | 59.33 |
|
||||
controllers | 55.17 | 49.33 | 80 | 55.17 |
|
||||
services | 61.03 | 82.35 | 80 | 61.03 |
|
||||
utils | 62.5 | 54 | 63.63 | 63.63 |
|
||||
```
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### New Test Coverage
|
||||
- ✅ Check suite webhook event handling
|
||||
- ✅ Automated PR review trigger logic
|
||||
- ✅ Multiple PR scenarios
|
||||
- ✅ Error handling for Claude service failures
|
||||
|
||||
### Known Test Issues
|
||||
- AWS credential provider tests fail in test environment (expected)
|
||||
- Tests pass in isolated environments with proper AWS setup
|
||||
|
||||
## 🚀 Deployment Pipeline
|
||||
|
||||
1. **Development**: Local development with pre-commit hooks
|
||||
2. **CI**: Automated testing, linting, and security scans
|
||||
3. **Build**: Docker image creation and registry publishing
|
||||
4. **Staging**: Automatic deployment on main branch
|
||||
5. **Production**: Manual approval with health checks
|
||||
|
||||
## 📋 Manual Setup Required
|
||||
|
||||
Due to GitHub token permissions, the following files need manual review/approval:
|
||||
|
||||
### GitHub Actions Workflows
|
||||
- `.github/workflows/ci.yml` - Main CI pipeline
|
||||
- `.github/workflows/security.yml` - Security scanning
|
||||
|
||||
### Configuration Files
|
||||
- `.github/dependabot.yml` - Dependency updates
|
||||
- `.eslintrc.js` - JavaScript linting rules
|
||||
- `.prettierrc` - Code formatting standards
|
||||
|
||||
## 🔧 Local Development Commands
|
||||
|
||||
```bash
|
||||
# Setup development environment
|
||||
npm run setup:dev
|
||||
|
||||
# Run linting
|
||||
npm run lint # Auto-fix issues
|
||||
npm run lint:check # Check only
|
||||
|
||||
# Run formatting
|
||||
npm run format # Auto-format code
|
||||
npm run format:check # Check formatting
|
||||
|
||||
# Run tests
|
||||
npm test # All tests
|
||||
npm run test:unit # Unit tests only
|
||||
npm run test:coverage # With coverage
|
||||
|
||||
# Security
|
||||
npm run security:audit # Check vulnerabilities
|
||||
npm run security:fix # Auto-fix issues
|
||||
```
|
||||
|
||||
## 📖 Documentation
|
||||
|
||||
- **Complete CI/CD Guide**: `docs/ci-cd-setup.md`
|
||||
- **Updated README**: Status badges and CI information
|
||||
- **Updated CLAUDE.md**: New CI/CD commands and features
|
||||
|
||||
## ✅ Checklist
|
||||
|
||||
- [x] GitHub Actions workflows created
|
||||
- [x] Automated PR review system implemented
|
||||
- [x] Code quality tools configured
|
||||
- [x] Security scanning enabled
|
||||
- [x] Docker builds integrated
|
||||
- [x] Test coverage enhanced
|
||||
- [x] Documentation updated
|
||||
- [x] Templates created for issues/PRs
|
||||
- [x] Dependabot configuration added
|
||||
|
||||
## 🎯 Benefits
|
||||
|
||||
### For Developers
|
||||
- **Automated quality checks** prevent issues
|
||||
- **Consistent formatting** improves readability
|
||||
- **Pre-commit hooks** catch issues early
|
||||
- **Comprehensive testing** ensures reliability
|
||||
|
||||
### For Security
|
||||
- **Daily vulnerability scans** detect threats
|
||||
- **Secret detection** prevents credential leaks
|
||||
- **Automated updates** patch vulnerabilities
|
||||
- **SAST analysis** finds code issues
|
||||
|
||||
### For Operations
|
||||
- **Automated deployments** reduce manual work
|
||||
- **Container builds** ensure consistency
|
||||
- **Health checks** validate deployments
|
||||
- **Monitoring** tracks system health
|
||||
|
||||
This implementation provides a production-ready CI/CD pipeline with comprehensive testing, security, and quality measures.
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"timestamp": "2025-05-21T02:32:41+00:00",
|
||||
"compose_file": "docker-compose.yml",
|
||||
"runs": 2,
|
||||
"results_ms": [2542,1614],
|
||||
"average_ms": 2078,
|
||||
"min_ms": 1614,
|
||||
"max_ms": 2542
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"timestamp": "2025-05-21T02:36:01+00:00",
|
||||
"compose_file": "docker-compose.optimized.yml",
|
||||
"runs": 2,
|
||||
"results_ms": [3110,1580],
|
||||
"average_ms": 2345,
|
||||
"min_ms": 1580,
|
||||
"max_ms": 3110
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Wrapper script for backward compatibility
|
||||
echo "This script is now located at scripts/build/build.sh"
|
||||
exec scripts/build/build.sh claudecode "$@"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Wrapper script for backward compatibility
|
||||
echo "This script is now located at scripts/setup/setup-claude-auth.sh"
|
||||
exec scripts/setup/setup-claude-auth.sh "$@"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Wrapper script for backward compatibility
|
||||
echo "This script is now located at scripts/runtime/start-api.sh"
|
||||
exec scripts/runtime/start-api.sh "$@"
|
||||
@@ -1,175 +0,0 @@
|
||||
# Test Reorganization Proposal
|
||||
|
||||
## Current State
|
||||
|
||||
The repository has been improved from its original state:
|
||||
- Created Jest test structure in `/test/unit/`, `/test/integration/`, and `/test/e2e/`
|
||||
- Created Jest configuration file for structured test execution
|
||||
- Removed 8 one-off shell script tests that were redundant or debug-only
|
||||
- Implemented some key unit tests for `awsCredentialProvider.js`
|
||||
- Implemented containerExecution E2E test
|
||||
- Preserved essential shell script tests for infrastructure testing
|
||||
|
||||
## Proposed Test Organization
|
||||
|
||||
### 1. Unit Tests (Jest)
|
||||
|
||||
Convert suitable JavaScript tests to Jest tests and organize in a structured way:
|
||||
|
||||
```
|
||||
/test
|
||||
/unit
|
||||
/controllers
|
||||
githubController.test.js
|
||||
/services
|
||||
claudeService.test.js
|
||||
githubService.test.js
|
||||
/utils
|
||||
awsCredentialProvider.test.js
|
||||
logger.test.js
|
||||
sanitize.test.js
|
||||
```
|
||||
|
||||
### 2. Integration Tests (Jest)
|
||||
|
||||
Convert integration-focused JavaScript tests to Jest tests:
|
||||
|
||||
```
|
||||
/test
|
||||
/integration
|
||||
/github
|
||||
webhookProcessing.test.js
|
||||
/claude
|
||||
claudeApiResponse.test.js
|
||||
/aws
|
||||
credentialHandling.test.js
|
||||
```
|
||||
|
||||
### 3. E2E Tests (Shell scripts + Jest)
|
||||
|
||||
Maintain shell scripts for true E2E tests that require container or environment setup:
|
||||
|
||||
```
|
||||
/test
|
||||
/e2e
|
||||
/scripts # Shell scripts that set up test environments
|
||||
setupTestContainer.sh
|
||||
setupFirewall.sh
|
||||
/scenarios # Jest tests that use the shell scripts
|
||||
githubWebhookFlow.test.js
|
||||
claudeContainerExecution.test.js
|
||||
```
|
||||
|
||||
## Test Dependencies
|
||||
|
||||
All required dependencies have been added:
|
||||
- ✅ `jest` - Test framework for unit, integration and E2E tests
|
||||
- ✅ `supertest` - For API testing
|
||||
- ✅ `jest-junit` - For CI integration with test report generation
|
||||
- ✅ `@types/jest` - For TypeScript support and IntelliSense
|
||||
|
||||
## Jest Configuration
|
||||
|
||||
✅ `jest.config.js` file has been created and configured:
|
||||
|
||||
```javascript
|
||||
module.exports = {
|
||||
testEnvironment: 'node',
|
||||
testMatch: [
|
||||
'**/test/unit/**/*.test.js',
|
||||
'**/test/integration/**/*.test.js',
|
||||
'**/test/e2e/scenarios/**/*.test.js'
|
||||
],
|
||||
collectCoverage: true,
|
||||
coverageReporters: ['text', 'lcov'],
|
||||
coverageDirectory: 'coverage',
|
||||
testTimeout: 30000, // Some tests might take longer due to container initialization
|
||||
verbose: true,
|
||||
reporters: [
|
||||
'default',
|
||||
['jest-junit', { outputDirectory: 'test-results/jest', outputName: 'results.xml' }]
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
## NPM Scripts
|
||||
|
||||
✅ `package.json` scripts have been updated:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"dev": "nodemon src/index.js",
|
||||
"test": "jest",
|
||||
"test:unit": "jest --testMatch='**/test/unit/**/*.test.js'",
|
||||
"test:integration": "jest --testMatch='**/test/integration/**/*.test.js'",
|
||||
"test:e2e": "jest --testMatch='**/test/e2e/scenarios/**/*.test.js'",
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:watch": "jest --watch",
|
||||
"setup:dev": "pre-commit install"
|
||||
}
|
||||
```
|
||||
|
||||
## Conversion Priority
|
||||
|
||||
1. Convert unit-testable JavaScript modules first:
|
||||
- `awsCredentialProvider.js`
|
||||
- `logger.js`
|
||||
- `sanitize.js`
|
||||
|
||||
2. Next, convert service-level tests:
|
||||
- `claudeService.js`
|
||||
- `githubService.js`
|
||||
|
||||
3. Finally, address integration and E2E tests
|
||||
|
||||
## Shell Scripts to Preserve
|
||||
|
||||
These shell scripts test container/environment configurations and should remain:
|
||||
- `test-claude-direct.sh`
|
||||
- `test-firewall.sh`
|
||||
- `test-container-privileged.sh`
|
||||
- `test-full-flow.sh`
|
||||
|
||||
## Shell Scripts to Convert
|
||||
|
||||
These scripts could be converted to Jest tests:
|
||||
- `test-aws-credential-provider.js` → Jest unit test (✅ Partially converted)
|
||||
- `test-logger-redaction.js` → Jest unit test
|
||||
- `test-webhook-response.js` → Jest integration test
|
||||
- `test-claude-api.js` → Jest integration test
|
||||
|
||||
## One-Off Shell Scripts Removed
|
||||
|
||||
These debugging/one-off scripts have been removed to clean up the codebase:
|
||||
- `test-debug-claude.sh` - Debug script for development
|
||||
- `test-debug-response.sh` - Debug script for development
|
||||
- `test-simple-error.sh` - Simple error test case
|
||||
- `test-response-file.sh` - Tests response file handling
|
||||
- `test-simple-claude.sh` - Simple Claude test covered by containerExecution.test.js
|
||||
- `test-minimal-claude.sh` - Minimal Claude test used as utility
|
||||
- `test-entrypoint.sh` - Entrypoint test covered by container tests
|
||||
- `test-sudo-env.sh` - Environment handling covered by container tests
|
||||
|
||||
## Implementation Progress
|
||||
|
||||
1. ✅ Created directory structure
|
||||
2. ✅ Set up Jest configuration
|
||||
3. 🔄 Converting highest-priority unit tests (in progress)
|
||||
- ✅ `awsCredentialProvider.js` (partially completed)
|
||||
- ⬜ `logger.js` (pending)
|
||||
- ⬜ `sanitize.js` (pending)
|
||||
4. ✅ Removed one-off test scripts
|
||||
5. ✅ Created containerExecution.test.js E2E test
|
||||
6. ✅ Set up CI integration with Jest-JUnit
|
||||
7. ⬜ Convert remaining JavaScript tests (pending)
|
||||
8. ✅ Documented test approach in README.md
|
||||
9. ✅ Added test-container-cleanup.sh script for test automation
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. Complete unit test migration for `awsCredentialProvider.js`
|
||||
2. Add unit tests for `logger.js` and `sanitize.js`
|
||||
3. Convert integration test scripts to Jest tests
|
||||
4. Set up CI pipeline to run the Jest tests
|
||||
5. Complete Docker container setup for test automation
|
||||
Reference in New Issue
Block a user