Skip to content

Commit 444f2bd

Browse files
JAORMXclaude
andcommitted
Add contributing guide with development workflow
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7c15535 commit 444f2bd

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Contributing to propolis
2+
3+
## Prerequisites
4+
5+
- **Go 1.25.7+**
6+
- **[Task](https://taskfile.dev/)** -- `go install github.com/go-task/task/v3/cmd/task@latest`
7+
- **golangci-lint** -- `go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest`
8+
- **goimports** -- `go install golang.org/x/tools/cmd/goimports@latest`
9+
10+
For CGO builds (runner binary), you also need libkrun headers:
11+
12+
| Platform | Install |
13+
|----------|---------|
14+
| Fedora | `sudo dnf install libkrun-devel` |
15+
| macOS | `brew tap slp/krun && brew install libkrun libkrunfw` |
16+
| Any Linux | `task build-runner` (uses builder container, no system libkrun needed) |
17+
18+
## Development Workflow
19+
20+
```bash
21+
# 1. Make your changes
22+
23+
# 2. Format and lint
24+
task fmt
25+
task lint
26+
27+
# 3. Run tests
28+
task test-nocgo # Pure Go packages (no libkrun needed)
29+
task test # All packages (requires libkrun-devel)
30+
31+
# 4. Build the runner (pick one)
32+
task build-dev # Linux with system libkrun-devel
33+
task build-dev-darwin # macOS with Homebrew libkrun (auto-signs)
34+
task build-runner # Linux via builder container (no system deps)
35+
```
36+
37+
`task verify` runs fmt, lint, and test in sequence as a pre-push check.
38+
39+
## Task Reference
40+
41+
Run `task --list` for the full list. Key tasks for development:
42+
43+
| Task | What it does |
44+
|------|-------------|
45+
| `task test` | Run all tests with race detector |
46+
| `task test-nocgo` | Run tests excluding CGO packages |
47+
| `task lint` | Run golangci-lint |
48+
| `task fmt` | go fmt + goimports |
49+
| `task verify` | fmt + lint + test (pre-push check) |
50+
| `task build-dev` | Build runner binary (Linux, requires libkrun-devel) |
51+
| `task build-dev-darwin` | Build runner binary (macOS, requires Homebrew libkrun) |
52+
| `task build-runner` | Build runner via builder container (no system deps) |
53+
| `task build-nocgo` | Verify pure Go packages compile |
54+
| `task clean` | Remove bin/, dist/, and coverage files |
55+
56+
## Code Conventions
57+
58+
- **SPDX headers** on every `.go` and `.yaml` file
59+
- **`log/slog`** for logging (no `fmt.Println` or `log.Printf`)
60+
- **Error wrapping**: `fmt.Errorf("context: %w", err)`
61+
- **Table-driven tests** with testify
62+
- **Functional options**: follow the `With*` pattern in `options.go`
63+
- **CGO boundary**: only `krun/` and `runner/cmd/propolis-runner/` use CGO.
64+
Never import `krun` from other packages.
65+
66+
## Commit Guidelines
67+
68+
- Imperative mood, capitalized, no trailing period
69+
- Limit subject line to 50 characters
70+
- Stage specific files only (never `git add -A`)
71+
72+
## CI
73+
74+
CI runs automatically on push and PR. See [docs/CI.md](docs/CI.md) for
75+
details on the pipeline structure and the builder image dependency chain.
76+
77+
The key thing to know: most CI jobs run pure Go tests and lint. The Linux
78+
CGO build depends on a pre-built builder container image. If you're only
79+
changing pure Go code, all jobs should pass without any special setup.

0 commit comments

Comments
 (0)