|
| 1 | +# Contributing to solana-go |
| 2 | + |
| 3 | +We encourage everyone to contribute — submit issues, PRs, and discuss. Every kind of help is welcome. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. Fork the repository and clone your fork |
| 8 | +2. Make sure you have Go 1.24+ installed |
| 9 | +3. Run `go mod download` to fetch dependencies |
| 10 | +4. Run the tests to verify everything works: `go test ./... -count=1` |
| 11 | + |
| 12 | +## Development Workflow |
| 13 | + |
| 14 | +1. Create a branch from `main` for your changes |
| 15 | +2. Make your changes and write tests |
| 16 | +3. Ensure all tests pass locally |
| 17 | +4. Commit using [Conventional Commits](#commit-messages) format |
| 18 | +5. Open a pull request against `main` |
| 19 | + |
| 20 | +## Commit Messages |
| 21 | + |
| 22 | +This project uses [Conventional Commits](https://www.conventionalcommits.org/). All commit messages must follow this format: |
| 23 | + |
| 24 | +``` |
| 25 | +<type>[optional scope]: <description> |
| 26 | +
|
| 27 | +[optional body] |
| 28 | +
|
| 29 | +[optional footer(s)] |
| 30 | +``` |
| 31 | + |
| 32 | +### Types |
| 33 | + |
| 34 | +| Type | When to use | |
| 35 | +| ---------- | ----------------------------------------------------- | |
| 36 | +| `feat` | A new feature or public API addition | |
| 37 | +| `fix` | A bug fix | |
| 38 | +| `docs` | Documentation-only changes | |
| 39 | +| `refactor` | Code changes that neither fix a bug nor add a feature | |
| 40 | +| `test` | Adding or updating tests | |
| 41 | +| `chore` | Build process, CI, or auxiliary tool changes | |
| 42 | +| `perf` | Performance improvements | |
| 43 | + |
| 44 | +### Breaking Changes |
| 45 | + |
| 46 | +If your change breaks the public API, you **must** indicate it in the commit: |
| 47 | + |
| 48 | +``` |
| 49 | +feat!: remove deprecated GetRecentBlockhash method |
| 50 | +
|
| 51 | +BREAKING CHANGE: GetRecentBlockhash has been removed. Use GetLatestBlockhash instead. |
| 52 | +``` |
| 53 | + |
| 54 | +The `!` after the type or a `BREAKING CHANGE:` footer will signal a major version bump. |
| 55 | + |
| 56 | +### Examples |
| 57 | + |
| 58 | +``` |
| 59 | +feat: add priority fee support to SendTransaction |
| 60 | +fix: handle nil response in GetAccountInfo |
| 61 | +docs: update RPC methods table in README |
| 62 | +refactor(ws): simplify subscription reconnect logic |
| 63 | +test: add coverage for address lookup table resolution |
| 64 | +``` |
| 65 | + |
| 66 | +Commit messages are enforced in CI via [commitlint](https://commitlint.js.org/). |
| 67 | + |
| 68 | +## Semver and API Compatibility |
| 69 | + |
| 70 | +This project follows [Semantic Versioning](https://semver.org/): |
| 71 | + |
| 72 | +- **Patch** (`v1.0.x`): bug fixes, no API changes |
| 73 | +- **Minor** (`v1.x.0`): new features, backwards-compatible API additions |
| 74 | +- **Major** (`vX.0.0`): breaking changes to the public API |
| 75 | + |
| 76 | +CI runs [`gorelease`](https://pkg.go.dev/golang.org/x/exp/cmd/gorelease) on every pull request to detect whether your changes are backwards-compatible. If you modify or remove any exported type, function, method, or interface, `gorelease` will flag it and the check will fail unless the version is bumped accordingly. |
| 77 | + |
| 78 | +**What counts as a breaking change:** |
| 79 | + |
| 80 | +- Removing or renaming an exported function, type, method, or constant |
| 81 | +- Changing the signature of an exported function or method |
| 82 | +- Changing the type of an exported struct field |
| 83 | +- Removing or renaming a package |
| 84 | + |
| 85 | +**What is safe (minor/patch):** |
| 86 | + |
| 87 | +- Adding new exported functions, types, or methods |
| 88 | +- Adding new fields to structs (unless they affect interface satisfaction) |
| 89 | +- Bug fixes that don't change API signatures |
| 90 | + |
| 91 | +## CI Checks |
| 92 | + |
| 93 | +Every pull request runs the following checks: |
| 94 | + |
| 95 | +| Check | What it does | |
| 96 | +| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 97 | +| **tests** | Runs `go test ./...` across Go 1.24.x on ubuntu, macos, and windows. Only triggered when `.go`, `go.mod`, `go.sum`, or the workflow file itself changes. | |
| 98 | +| **semver-check** | Runs `gorelease` to compare the public API against the latest release tag. Fails if breaking changes are detected without a major version bump. | |
| 99 | +| **commit-lint** | Validates that all commits in the PR follow Conventional Commits format. | |
| 100 | + |
| 101 | +## Releases |
| 102 | + |
| 103 | +Releases are automated via [Release Please](https://github.com/googleapis/release-please). When commits land on `main`, Release Please opens (or updates) a release PR with: |
| 104 | + |
| 105 | +- A version bump based on conventional commit types (`fix:` = patch, `feat:` = minor, `feat!:` = major) |
| 106 | +- An auto-generated `CHANGELOG.md` |
| 107 | + |
| 108 | +When the release PR is merged, a new GitHub Release and Git tag are created automatically. |
| 109 | + |
| 110 | +## Running Tests |
| 111 | + |
| 112 | +```bash |
| 113 | +# Run all tests |
| 114 | +go test ./... -count=1 |
| 115 | + |
| 116 | +# Run tests for a specific package |
| 117 | +go test ./rpc/... -count=1 |
| 118 | + |
| 119 | +# Run tests with race detection |
| 120 | +go test -race ./... -count=1 |
| 121 | +``` |
| 122 | + |
| 123 | +## Reporting Issues |
| 124 | + |
| 125 | +- Use GitHub Issues for bug reports and feature requests |
| 126 | +- Include Go version, OS, and a minimal reproducer when reporting bugs |
| 127 | +- Check existing issues before opening a new one |
0 commit comments