This document provides comprehensive information for developers working on the XenForo to GitHub Discussions migration tool.
Note
This project follows Go best practices with a clean architecture and comprehensive testing strategy.
Tip
Use the Makefile for all development tasks - it provides consistent commands across environments:
# Get help with available commands
make help
# Set up development environment
make deps
# Build the project
make build
# Run tests
make test
# Run pre-commit checks
make check
# Format code
make fmtThe project follows Go best practices with a clean architecture:
cmd/
└── xenforo-to-gh-discussions/ # Application entry point (30 lines, minimal)
└── main.go
internal/
├── config/ # Configuration and interactive prompts
├── xenforo/ # XenForo API client and models
├── github/ # GitHub GraphQL client and operations
├── bbcode/ # BB-code to Markdown conversion
├── attachments/ # File download and processing
├── progress/ # Migration progress tracking
├── migration/ # Migration orchestration and interactive flow
└── testutil/ # Shared test utilities and mocks
test/
├── integration/ # Integration tests
└── testdata/ # Test data and fixtures
Important
Unit tests are located alongside their respective source code following Go conventions (e.g., internal/config/config_test.go).
# Run all tests
make test
# Run unit tests only
make test-unit
# Run integration tests only
make test-integration
# Run with coverage report
make test-coverage
# Run with race detector
make test-race
# Run benchmarks
make benchTip
Unit Tests: Located with source code (internal/*/*_test.go)
- Direct access to package internals
- Better IDE integration and discovery
- Simpler import paths
Note
Integration Tests: Centralized in test/integration/
- End-to-end migration workflows
- Mock-based full pipeline testing
- Real API interaction patterns
# Development build (with race detector)
make dev
# Production build
make build
# Install to $GOPATH/bin
make install# Build for all platforms
make build-all
# Create release packages
make package
# Full release process (clean, lint, test, build-all)
make release# Manual build without Makefile
go build -o xenforo-to-gh-discussions ./cmd/xenforo-to-gh-discussions# Format code
make fmt
# Run linter checks
make lint
# Run golangci-lint (if installed)
make golangci-lint
# Run all pre-commit checks
make checkImportant
Always run make check before committing - it ensures code quality and test coverage.
The codebase maintains high-quality standards:
- Cyclomatic Complexity: All functions kept below complexity 15
- Package Organization: Clear separation of concerns
- Test Coverage: Comprehensive unit and integration tests
- Documentation: Detailed README and architecture docs
# Watch for changes and auto-rebuild
make watch
# Clean build artifacts
make clean
# Update dependencies
make deps-update
# Tidy dependencies
make tidy# Show version and build information
make version# Build Docker image
make docker-build
# Build and run Docker container
make docker-run- Location: Alongside source code in each package
- Scope: Individual function behavior and edge cases
- Dependencies: Minimal external dependencies, use mocks
- Location:
test/integration/ - Scope: Complete migration workflows
- Dependencies: Uses
internal/testutil/mocks
- Benchmarks: Critical migration path performance
- Memory profiling: Large dataset handling
- Rate limiting: API compliance testing
Tip
Follow these principles when contributing:
- config: Configuration management with interactive prompts
- xenforo: XenForo API client with retry logic
- github: GitHub GraphQL operations
- bbcode: BB-code to Markdown conversion
- attachments: Secure file handling
- progress: Migration progress tracking
- migration: High-level orchestration and interactive workflow
- testutil: Shared test utilities and mocks
- Strategy Pattern: BB-code conversion, file handling
- Repository Pattern: Progress persistence, configuration
- Adapter Pattern: API clients, mock implementations
- Command Pattern: Migration operations with retry logic
- Follow standard Go formatting (
gofmt) - Use meaningful variable and function names
- Keep functions focused and under 15 cyclomatic complexity
- Add comprehensive tests for new functionality
- Run
make checkto ensure quality - Write clear, descriptive commit messages
- Include tests for new features
- Update documentation as needed
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Make your changes following the guidelines above
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Caution
Watch out for these common issues:
- Import cycles: Keep package dependencies clean
- Race conditions: Use
make test-raceregularly - Memory leaks: Profile with large datasets
- API rate limits: Test with realistic delays
# Build with debug information
go build -gcflags="all=-N -l" -o debug-binary ./cmd/xenforo-to-gh-discussions# CPU profiling
go test -cpuprofile=cpu.prof -bench=.
# Memory profiling
go test -memprofile=mem.prof -bench=.- Install Go extension
- Use workspace settings for consistent formatting
- Enable automatic test discovery
- Import project settings
- Configure Go modules properly
- Use built-in test runner
- Go 1.24 or higher
- Make (for using Makefile commands)
- Git (for version control)
- Optional: Docker (for containerized development)
- Clone the repository
- Run
make depsto install dependencies - Run
make testto verify setup - Run
make buildto create the binary - Start developing!
Tip
For additional information, check the main README or architecture documentation first.