5.8 KiB
Contributing
Thanks for helping make Twirp better! This is great!
Twirp Design Principles
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.
Report an Issue
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 security@twitch.tv.
Contributing Code with Pull Requests
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.
Requirements
- Twirp officially supports the last 3 releases of Go.
- Protobuf version 3.x.x to generate code with the protoc command.
- The Python implementation uses Python 2.7. As such, it is not suitable for production use in its current form.
- 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
.
Running tests
Generally you want to make changes and run make
, which will install all
dependencies we know about, build the core, and run all of the tests that we
have against Go and Python code. A few notes:
- Make sure to clone the repo on
$GOPATH/src/github.com/twitchtv/twirp
- Run Go unit tests with
make test_core
, or just the tests withgo test -race ./...
(make sure to re-generate code withmake generate
before running unit tests). - Most tests of the Go server are in
internal/twirptest/service_test.go
. - Integration tests running the full stack in both Go and Python auto-generated clients are in the clientcompat directory.
Contributing Documentation
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. To do this:
- Install docusaurus on your machine.
cd website
npm start
- Navigate to http://localhost:3000/twirp.
Follow this guide to publish changes to the gh-pages
branch.
Making a New Release
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 master branch.
- Update the version constant in
internal/gen/version.go
. Please respect semantic versioning:v<major>.<minor>.<patch>
. - Run
make generate
and run tests. Check that generated test files include a header comment with the new version. - Add a new commit to master 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 to document changes, upgrade instructions are very important.
- Run
make release_gen
to generate release assets in therelease
directory. This requires Docker to be installed. Then Upload all files in therelease
directory as part of the release.
Code of Conduct
This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opensource-codeofconduct@amazon.com with any additional questions or comments.
Licensing
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.