Development Setup¶
This guide helps you set up your development environment for contributing to reviewtask.
Prerequisites¶
Required Software¶
-
Go 1.21+
-
Git
-
GitHub CLI (gh)
-
Claude CLI
Optional Tools¶
- Make - For using Makefile commands
- jq - For JSON processing in scripts
- golangci-lint - For code linting
Setting Up the Development Environment¶
1. Fork and Clone the Repository¶
# Fork on GitHub first, then:
git clone https://github.com/YOUR_USERNAME/reviewtask.git
cd reviewtask
git remote add upstream https://github.com/biwakonbu/reviewtask.git
2. Install Dependencies¶
3. Set Up Pre-commit Hooks (Optional)¶
4. Configure GitHub Access¶
# Using GitHub CLI (recommended)
gh auth login
# Or set environment variable
export GITHUB_TOKEN="your_github_token"
5. Configure Claude CLI¶
# Install Claude CLI if not already installed
# Follow instructions at https://claude.ai/code
# Verify installation
claude --version
Building the Project¶
Standard Build¶
Development Build with Version Info¶
VERSION=$(git describe --tags --always --dirty)
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
go build -ldflags "\
-X main.version=$VERSION \
-X main.commitHash=$COMMIT \
-X main.buildDate=$DATE" \
-o reviewtask main.go
Cross-Platform Build¶
# Build for all platforms
./scripts/build.sh all
# Build for specific platform
./scripts/build.sh linux-amd64
Running Tests¶
Unit Tests¶
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package tests
go test ./internal/ai
# Verbose output
go test -v ./...
Golden Tests¶
# Run golden tests
go test ./internal/ai -run Golden
# Update golden files when needed
UPDATE_GOLDEN=1 go test ./internal/ai -run Golden
Integration Tests¶
# Run integration tests
go test ./test -tags integration
# With real GitHub API (requires token)
GITHUB_TOKEN=$YOUR_TOKEN go test ./test -tags integration
Test Coverage¶
# Generate coverage report
go test -coverprofile=coverage.out ./...
# View coverage in browser
go tool cover -html=coverage.out
Debugging¶
Running in Debug Mode¶
# Enable verbose logging
reviewtask fetch 123 --verbose
# Use debug commands
reviewtask debug fetch review 123
reviewtask debug fetch task 123
reviewtask debug prompt 123
Using Delve Debugger¶
# Install delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Debug the application
dlv debug main.go -- fetch 123
# Set breakpoints
(dlv) break internal/ai/analyzer.go:100
(dlv) continue
Logging¶
Enable verbose mode in configuration:
Code Style and Linting¶
Format Code¶
Run Linters¶
# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linters
golangci-lint run
# Fix issues automatically
golangci-lint run --fix
Pre-commit Checks¶
# Run all pre-commit hooks
pre-commit run --all-files
# Run specific hook
pre-commit run go-fmt --all-files
Common Development Tasks¶
Adding a New Command¶
- Create file in
cmd/
directory - Implement command using Cobra
- Add to root command
- Add tests
- Update documentation
Modifying AI Prompts¶
- Edit template in
prompts/
directory - Test with debug command:
- Update golden tests if needed
- Test with real PR
Adding a New Configuration Option¶
- Update
internal/config/config.go
- Add default value
- Update
docs/user-guide/configuration.md
- Add migration logic if needed
Working with Storage¶
- Understand PR-specific directory structure
- Use WriteWorker for concurrent writes
- Always use mutex for file operations
- Test with multiple PRs
Troubleshooting Development Issues¶
Module Issues¶
# Clean module cache
go clean -modcache
# Update dependencies
go get -u ./...
# Tidy modules
go mod tidy
Build Issues¶
Test Issues¶
Development Workflow¶
1. Create Feature Branch¶
2. Make Changes¶
- Write code
- Add tests
- Update documentation
3. Test Locally¶
# Run tests
go test ./...
# Build and test binary
go build -o reviewtask main.go
./reviewtask fetch YOUR_PR_NUMBER
4. Commit Changes¶
5. Push and Create PR¶
Useful Make Commands¶
If using the Makefile:
make build # Build binary
make test # Run tests
make test-cover # Run tests with coverage
make lint # Run linters
make fmt # Format code
make clean # Clean build artifacts
Environment Variables¶
Development Variables¶
# Enable debug logging
export REVIEWTASK_DEBUG=true
# Skip version check
export REVIEWTASK_SKIP_VERSION_CHECK=true
# Use specific config file
export REVIEWTASK_CONFIG=/path/to/config.json
Testing Variables¶
# Update golden test files
export UPDATE_GOLDEN=1
# Skip integration tests
export SKIP_INTEGRATION=1
# Use test GitHub token
export TEST_GITHUB_TOKEN=your_test_token
IDE Setup¶
Visual Studio Code¶
.vscode/settings.json
:
{
"go.lintTool": "golangci-lint",
"go.formatTool": "gofmt",
"go.testFlags": ["-v"],
"go.testTimeout": "30s"
}
GoLand / IntelliJ IDEA¶
- Open project
- Configure Go SDK
- Enable Go modules
- Set up run configurations
Getting Help¶
- Check Troubleshooting Guide
- Search GitHub Issues
- Ask in Discussions
- Review Contributing Guidelines