-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing
iamvirul edited this page Mar 21, 2026
·
1 revision
- Go 1.24+
- Docker (for integration tests only)
-
golangci-lint(for linting) -
gofmt(included with Go)
git clone https://github.com/iamvirul/deepdiff-db.git
cd deepdiff-db
# Install dependencies
go mod download
# Build
go build ./cmd/deepdiffdb/...
# Run unit tests
go test ./tests/config ./tests/content ./tests/checkpoint \
./tests/drivers ./tests/schema ./internal/schema ./internal/content
# Run integration tests (requires Docker)
go test -tags integration ./tests/schema/...cmd/deepdiffdb/ CLI entry point
internal/ Private packages (schema, content, checkpoint, drivers, cli, report)
pkg/ Shared packages (config, logger, progress, errors)
tests/ Test files (mirrors package structure)
website/docs/ Documentation site source
scripts/ Local build scripts
samples/ Example configs and output
See Architecture Overview for the full module map.
go test -race -coverprofile=coverage.txt \
-coverpkg=./internal/...,./pkg/... \
./tests/config ./tests/content ./tests/checkpoint \
./tests/drivers ./tests/schema \
./internal/schema ./internal/contentIntegration tests use testcontainers-go to spin up real databases. Docker must be running.
go test -tags integration ./tests/schema/...Integration test files are identified by the build tag //go:build integration at the top of the file.
go tool cover -func=coverage.txt | tail -1
# target: 80%+ overallAll code must be gofmt-clean:
gofmt -w ./...golangci-lint run ./...Key rules enforced:
-
gosimple— no redundant nil checks, prefer idiomatic Go -
golint— exported types and functions must have doc comments - No blank imports without justification comments
- No stutter in package-qualified names (e.g.
resolve.ResolveConflicts→resolve.Conflicts)
Always use the typed error system in pkg/errors/:
// Good
return errors.Wrap(err, errors.ErrHashingFailed, "failed to hash table").
With("table", tableName)
// Bad — never swallow or return plain errors from internal code
return fmt.Errorf("hash failed: %w", err)Use structured logging with context fields, never bare strings:
log := logger.FromContext(ctx)
log.Info("hashing table", "table", tableName, "batch_size", batchSize)Never log passwords, tokens, or PII.
- One test file per source file, in
tests/<package>/ - Test behavior, not implementation
- No mocking your own code — only mock at system boundaries (DB, HTTP, filesystem)
- Error path coverage is required for all public functions
- Use platform-independent file tricks to trigger OS errors (see existing tests for patterns)
| Branch | Purpose |
|---|---|
main |
Stable, releasable code |
development |
Integration branch for in-progress features |
feature/<name> |
Individual feature or fix branches |
hotfix/<name> |
Critical production fixes |
PRs target development for features, main for hotfixes.
Follow Conventional Commits:
<type>(<scope>): <short description>
Types: feat, fix, docs, refactor, test, chore, perf
Scope: schema, content, drivers, config, cli, checkpoint, errors, ci
Examples:
feat(content): add keyset pagination for large tables
fix(schema): handle nullable columns with empty default in PostgreSQL
test(checkpoint): add error path tests for atomic write
docs(wiki): add contributing guide
-
gofmt -w ./...— no formatting violations -
golangci-lint run ./...— no lint issues - All unit tests pass
- New code has tests (error paths included)
- No secrets or credentials in code or tests
- PR title follows Conventional Commits format
- Description explains why, not just what
- Add the Go driver import to
internal/drivers/imports.gowith a comment - Add DSN construction to
drivers.BuildDSN()ininternal/drivers/drivers.go - Add schema introspection queries to
internal/schema/introspect.go - Add cursor (pagination) SQL to
internal/content/cursor.go - Add migration SQL generation to
internal/schema/migrate.go - Add FK disable/enable SQL to
internal/content/pack.go - Add a test container definition and integration tests in
tests/schema/ - Update Driver Support wiki page
Use GitHub Issues. Include:
- DeepDiff DB version (
deepdiff-db --version) - Database driver and version
- Config file (with credentials redacted)
- Full error output with
--log-level debug - Steps to reproduce
Home · Problem Statement · Architecture · Data Flow · CLI Reference · Configuration · Contributing
DeepDiff DB — safe, deterministic database synchronization