Skip to content

Commit

Permalink
Add contribution guide (#1167)
Browse files Browse the repository at this point in the history
* Add contribution guide

* Apply suggestions from code review

Co-authored-by: Daniel Granhão <32176319+danielgranhao@users.noreply.github.com>

* Clean up generating code section

---------

Co-authored-by: Daniel Granhão <32176319+danielgranhao@users.noreply.github.com>
  • Loading branch information
dangeross and danielgranhao authored Feb 21, 2025
1 parent bb68587 commit 4cfea81
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
libs/sdk-bindings/*.sql
.DS_Store
*.sln
.idea/

libs/sdk-react-native/ios/breez_sdk.swift
Expand Down
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Contribution guide

Contributions are always welcome. The codebase is maintained using the "contributor workflow" where anyone can contribute proposals using [pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests).

The contribution workflow is as follows:

1. Fork the repository.
2. Create a topic branch.
3. Commit changes to the branch.
4. Push changes to the fork.
5. Create a pull request to merge the branch of the fork into this repository.
6. If you had someone specifically in mind, ask them to review the pull request.
Otherwise, just wait for a code review: most members with merge permissions receive notifications for newly created pull requests.
7. Address review comments, if any.
8. Merge and submit the pull request.
If you don't have merge permissions, a reviewer will do it for you.

> **NOTE:** Before starting a particular feature, please make sure to check if a related [issue](https://github.com/breez/breez-sdk-greenlight/issues) already exists and is not already assigned to somebody. If there is no issue created, open up a [new issue](https://github.com/breez/breez-sdk-greenlight/issues/new) if you want to first discuss and to agree on the optimal way of solving a particular problem.
>
> If you don't know where to start, look for issues labeled with [good first issue](https://github.com/breez/breez-sdk-greenlight/labels/good%20first%20issue).
#### Code formatting
The Rust source code should be formatted according to `cargo fmt` and have no linting errors from `cargo clippy`. Any changes to public facing functions or structs should be adequately documented according to [rustdoc](https://doc.rust-lang.org/rustdoc/index.html#using-rustdoc-with-cargo). Comments on code should be written clearly and concisely, and written in English.

#### Generating code
If there are any changes to the SDK's interface, they also need to be updated in the bindings interface. The SDK uses [UniFFI](https://github.com/mozilla/uniffi-rs) and [Flutter Rust Bridge](https://pub.dev/packages/flutter_rust_bridge) to generate the bindings code for several different languages.

Please update the following crates when you change an SDK interface:

__*[libs/sdk-bindings](libs/sdk-bindings)*__
* [uniffi_bindings.rs](libs/sdk-bindings/src/uniffi_binding.rs) - Update the Rust interface for the UniFFI bindings.
* [breez_sdk.udl](libs/sdk-bindings/src/breez_sdk.udl) - Update the UniFFI interface definition language file.

__*[libs/sdk-core](libs/sdk-core)*__
* [bindings.rs](libs/sdk-core/src/bindings.rs) - Update the Rust interface for the Flutter Rust Bridge bindings.

After making these changes the [Flutter](libs/sdk-flutter) and [React Native](libs/sdk-react-native) bindings code also need to be regenerated and included in your pull request. You can regenerate these from the project root using `make codegen`. Please see the prerequisites for [Flutter](libs/sdk-flutter/README.md) and [React Native](libs/sdk-bindings/bindings-react-native/README.md) if this is your first time generating code.

#### Testing
Please adequately test your code using the existing tests and write additional tests for new features. You can run the tests from the project root using `make test`. You can also make use of the [CLI](tools/sdk-cli) to test changes while developing your feature.

## Pull requests

A pull request contains one or more related git commits. Please, do not bundle independent and unrelated commits into a single pull request.

Just like a git commit message, a pull request consists of a subject and a body. If a pull request contains only one git commit, set its title and description to the commit's subject and the body. Otherwise, make an overall summary of what all the commits accomplish together, in a way similar to a commit message. If you are addressing an existing issue, please reference it in the pull request body.

See the following docs on creating [github pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).

Before creating a pull request, please make sure all tests and lints pass locally on your machine. In a case where a pull request isn't ready for a regular code review and you're just looking for some early feedback,
it's ok to let some tests fail but please mention it explicitly in the request description.

#### Checklist
You can run all the following commands in the project root directory to comply to the contribution guide:
- Format and lint the source code: `make fmt clippy`
- Generate code Flutter and React Native bindings: `make codegen`
- Test the code: `make test`

You can run all these in one command: `make all`
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
all: fmt codegen clippy

fmt:
cd libs && cargo fmt -- --check
cd tools/sdk-cli && cargo fmt -- --check
cd libs && cargo fmt
cd tools/sdk-cli && cargo fmt

clippy:
# Explicitly allow clippy::uninlined-format-args lint because it's present in the generated breez_sdk.uniffi.rs
cd libs && cargo clippy -- -D warnings -A clippy::uninlined-format-args
cd libs && cargo clippy --tests -- -D warnings -A clippy::uninlined-format-args
cd tools/sdk-cli && cargo clippy -- -D warnings

test:
cd libs && cargo test

codegen: flutter-codegen react-native-codegen

flutter-codegen:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ The tools folder contains a simple command line interface (sdk-cli) to the SDK.

See the instructions in each sub-project readme on how to build, test, and run.

## **Contributing**

Contributions are always welcome. Please read our [contribution guide](CONTRIBUTING.md) to get started.

## SDK Development Roadmap

- [x] ‘On-the-fly’ channel creation
Expand Down

0 comments on commit 4cfea81

Please sign in to comment.