3.2 KiB
3.2 KiB
Contributing to RelSpec
Setup
- Go 1.25+ (see
go.mod), Git - Optional: golangci-lint, Docker/Podman (PostgreSQL integration tests)
git clone git@git.warky.dev:wdevs/relspecgo.git
cd relspecgo
make deps
make build # outputs build/relspec
Make Targets
| Target | Purpose |
|---|---|
make test |
Unit tests (race detection, coverage) |
make test-integration |
Integration tests (needs RELSPEC_TEST_PG_CONN) |
make docker-test |
PostgreSQL integration tests via Docker/Podman |
make lint |
golangci-lint |
make fmt / fmt-check |
gofumpt + goimports |
make check |
vet, fmt-check, staticcheck, govulncheck |
make coverage |
Coverage report |
Single test: go test -run TestName ./pkg/readers/dbml
Layout
cmd/relspec/ CLI commands (convert, diff, merge, split, edit, inspect, job, ...)
pkg/models/ Core model: Database > Schema > Table > Column/Constraint/Index/Relationship
pkg/readers/<fmt> One reader per format
pkg/writers/<fmt> One writer per format
pkg/diff, merge, inspector, jobs, transform, ui, pgsql, sqltypes ...
examples/ Sample files
tests/ Integration tests and assets
docs/ Feature docs
Adding a Reader
- Create
pkg/readers/<format>/reader.gowithNewReader(options *readers.ReaderOptions). - Implement
readers.Reader:ReadDatabase,ReadSchema,ReadTable. - Add
reader_test.goin the same package. - Register the format in the CLI switches (
cmd/relspec/convert.go,diff.go,edit.go, ...). - Add a
README.mdin the reader directory.
Adding a Writer
- Create
pkg/writers/<format>/writer.gowithNewWriter(options *writers.WriterOptions). - Implement
writers.Writer:WriteDatabase,WriteSchema,WriteTable. - Add
writer_test.goin the same package. - Register the format in the CLI switches.
- Add a
README.mdin the writer directory.
Code Rules
- Format with gofumpt/goimports (
make fmt);make checkmust pass. - Iterate
Table.Columns,Constraints,Indexes,Relationshipsin sorted order (maps are unordered; output must be deterministic). - Every writer stamps
buildinfo.GeneratedComment()in its file header. - Comment exported functions and types.
Testing
- Tests live in the same package as the code.
- Table-driven tests; cover positive and negative cases.
- Reuse existing test data in
tests/andexamples/before adding new data. - Tests run with
-race.
Commits
- Format:
type(scope): description - Types:
feat,fix,docs,test,refactor,chore,ci - Keep commits focused. Reference issues where applicable.
Pull Requests
- Branch from
master. - Add tests;
make testandmake checkpass. - Update docs/README if behaviour changes.
- Open a PR with a clear description.
Security
Do not report vulnerabilities in public issues. See SECURITY.md.
License
Contributions are licensed under the Apache License 2.0.