Contributing to Vetrix
Development setup
Prerequisites
- Go 1.22+
- PostgreSQL 15+
- Node.js 20+ (for the UI)
- Docker (optional, for integration tests)
Clone and build
git clone git@github.com:your-org/vetrix.git
cd vetrix
go build ./...
Database setup
createdb vetrix_dev
export DATABASE_URL="postgres://postgres@localhost/vetrix_dev?sslmode=disable"
export JWT_SECRET="$(openssl rand -base64 48)"
go run ./cmd/server
Running the server
go run ./cmd/server
The API is available at http://localhost:3000.
Running the UI (development)
cd web
npm install
npm run dev
The UI dev server runs on port 3001 and proxies API requests to localhost:3000.
Code conventions
Go
- Run
gofmtandgolangci-lintbefore committing. - Error messages are lowercase and do not end with punctuation.
- Use
context.Contextas the first argument for all functions that make I/O calls. - Avoid global state. Wire dependencies through struct fields.
- Keep packages cohesive.
internal/apihandles HTTP concerns only; business logic lives ininternal/<feature>/.
Package structure
cmd/
server/ — main HTTP + SSH server entry point
worker/ — standalone CI/CD runner entry point
internal/
admin/ — admin settings, user management, health
api/ — HTTP handlers and router
auth/ — JWT issuance and middleware
acl/ — permissions, PATs, SSH keys
cicd/ — pipeline execution, runner protocol
git/ — git repository operations
mirror/ — pull/push mirror scheduler
registry/ — container, npm, PyPI, Go, generic registries
search/ — indexing and query engine
scanning/ — SAST, secret scanning
Database
- Migrations live in
db/migrations/. Use sequential integer prefixes:0001_init.up.sql,0001_init.down.sql. - Never modify an existing migration. Add a new one.
- Use
pgx/v5for all database access. No ORM. - Prefer
RETURNINGclauses over separateSELECTafterINSERT/UPDATE.
Tests
- Unit tests live alongside the code they test:
foo.go→foo_test.go. - Integration tests that need a real database are in
internal/<pkg>/integration_test.goand use the//go:build integrationtag. - Run unit tests:
go test ./... - Run integration tests:
go test -tags integration ./...(requiresTEST_DATABASE_URL) - See backend-pipeline.md for the backend CI testing runbook (the
go-test/go-integration-testjobs, localTEST_DSNagainstmydev_postgres, and cookbooks for adding TEST_DSN-gated tests + structural projection guards).
Merge request guidelines
- One concern per MR. Separate refactoring from feature work.
- Reference the issue. Include
Closes #123in the MR description. - Write tests. New behaviour must have unit tests. Bug fixes must have a regression test.
- Update docs. If you change API behaviour, update the relevant file in
docs/. - Keep commits clean. Squash or rebase if your branch has fixup commits before requesting review.
- CI must pass. PRs with failing CI are not reviewed.
Naming and terminology
A few project-wide naming rules. Apply them in any new copy you write and check existing copy when you touch it.
- Vetrix's own merge / pull surface is "merge request" / "MR". The DB table is
merge_requests, the type isMergeRequest, the API client ispullsApi(kept for back-compat with the/pulls/route — seeinternal/api/pulls.go). User-facing copy uses "merge request"; wire-level identifiers like thepull_requestwebhook event are deliberately kept. - Vetrix's own CI / workflow surface is "Vetrix Workflows" (proper noun) when referring to the feature concept, or "pipeline" / "workflow" (lowercase) when referring to a single configured run. Do not call it "Actions" or "GitHub Actions" in product copy. "Actions" as a UI table-column header for row affordances (Cancel / Retry / Delete / etc.) is a different word with the same spelling — keep it.
Commit message format
<type>(<scope>): <short summary>
<optional body>
<optional footer: Closes #123>
Types: feat, fix, docs, refactor, test, chore.
Examples:
feat(cicd): add job timeout enforcement
fix(auth): reject expired JWTs with a 401 instead of 500
docs(registry): add PyPI install examples
Reporting issues
File bugs at /issues with:
- Vetrix version (
vetrix --version) - Steps to reproduce
- Expected behaviour
- Actual behaviour
- Logs if applicable
Security vulnerabilities
Do not open a public issue for security vulnerabilities. Email the maintainers directly. See SECURITY.md for the disclosure policy.