Thanks for helping make Twirp better! This is great!
Contributions to Twirp should align with the project’s design principles:
- Maintain backwards compatibility. Twirp has been in production at Twitch since 2016 and released to the public in January 2018. It is currently used by many companies and individuals with a variety of needs. There must be a compelling use-case and solid reasoning behind a major version upgrade.
- Simple wire protocol and minimal public API. Fewer things in the core means fewer things to break. In addition, it ensures lower friction updates and easier to maintain implementations in other languages.
- Avoid surprising behavior. For instance, mechanisms that can alter a program’s control flow in a surprising way (such as middleware or observability hooks) should be treated with caution.
- Prefer pragmatism over bleeding-edge. Users should be able to deploy and accept updates to Twirp even if they are conservative on updating its dependencies. This includes Go, the protobuf compiler and runtime libraries, and the HTTP protocol.
- Keep configuration to a minimum. For example: avoid adding flags to code generation commands, so that generated code is predictable across versions and platforms.
- Limit dependencies where possible, so that they are easier to integrate and upgrade.
- Prefer generated code over shared libraries between services and clients, so that it is easier to implement changes without forcing a lock-step upgrade across the ecosystem.
Examples of contributions that should be addressed with high priority:
- Security updates.
- Performance improvements.
- Supporting new versions of key dependencies such as Go and Protobuf.
- Documentation.
- Making Twirp easier to integrate with other tools.
If you have run into a bug or want to discuss a new feature, please file an issue. If you'd rather not publicly discuss the issue, please email [email protected].
Twirp uses github pull requests. Fork, hack away at your changes and submit. Most pull requests will go through a few iterations before they get merged. Different contributors will sometimes have different opinions, and often patches will need to be revised before they can get merged.
- Add tests that cover your contribution. Overall code coverage should not decrease.
- Twirp officially supports the last 3 releases of Go.
- Protobuf version 3.x.x to generate code with the protoc command.
- For linters and other tools, we use retool. If
make setup
is not able to install it, you can install it in your path withgo get github.com/twitchtv/retool
and then install tools withretool build
.
Generally you want to make changes and run make
, which will install all
dependencies we know about, build the core, and run tests. A few notes:
- Clone the repo on
$GOPATH/src/github.com/twitchtv/twirp
(go modules not supported yet). - Run Go unit tests with
make test
. - Most tests of the Go server are in
internal/twirptest/service_test.go
. - Integration tests running the full stack in Go are in the clientcompat directory.
Twirp's docs are generated with Docusaurus. You can safely edit anything inside the docs directory, adding new pages or editing them. You can edit the sidebar by editing website/sidebars.json.
Then, to render your changes, run docusaurus's local server. See Install docusaurus on your machine.
cd website
npm install
npm start
- Navigate to http://localhost:3000/twirp.
Follow this guide to publish changes to the gh-pages
branch.
Releasing versions is the responsibility of the core maintainers. Most people can skip this section.
Twirp uses Github releases. To make a new release:
- Merge all changes that should be included in the release into the main branch.
- Update the version constant in
internal/gen/version.go
. Please respect semantic versioning:v<major>.<minor>.<patch>
. - Run
make test_all
to re-generate code and run tests. Check that generated test files include the new version in the header comment. - Add a new commit to main with a message like "Version vX.X.X release" and push.
- Tag the commit you just made:
git tag vX.X.X
andgit push origin --tags
. - Go to Github https://github.com/twitchtv/twirp/releases and "Draft a new release".
- Make sure that all new functionality is properly documented, on code comments, PR description, and include links and/or upgrade instructions on the release. For example the v7 release. Minor releases can just include a link to the PR/PRs that were merged included into the release.
This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
See the LICENSE file for our project's licensing. We will ask you to confirm the licensing of your contribution.
We may ask you to sign a Contributor License Agreement (CLA) for larger changes.