Commit fd734dcf authored by Éloïs's avatar Éloïs
Browse files

doc: add CONTRIBUTING and git-conventions

parent 7efd749d
# Contributing
Before contributing, please make sure that your development environment is properly configured by following this tutorial :
[Setting up your development environment]
Sign-ups on our gitlab are disabled. If you would like to contribute, please ask for its creation on [the technical forum].
When contributing to this repository, please first discuss the change you wish to make via issue or
via [the technical forum] before making a change.
Please note we have a specific workflow, please follow it in all your interactions with the project.
## Developer documentation
Please read [Developer documentation] before contribute.
## Workflow
- Create a branch based on `master` and prefixed with your nickname. Give your branch a short name indicating the subject.
- Create an MR from your branch to `master`.
- Never contribute to a branch of ahother contributor! If the contributor make a `git rebase` your commit will be lost !
- Before you push your commit:
- Apply formatters (rustfmt and prettier) and linter (clippy)
- Document your code.
- Apply the [project's git conventions]
## Merge Process
1. Ensure you rebased your branch on the latest `master` commit to avoid any merge conflicts.
2. Ensure that you respect the [commit naming conventions].
3. Ensure that all automated tests pass with the `npm test` command.
4. Update the documentation with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
5. Push your branch on the gitlab and create a merge request. Briefly explain the purpose of your contribution in the description of the merge request.
6. Tag a Duniter reviewer so he will review your contribution. If you still have no news after several weeks, tag another reviewer or/and talk about your contribution on [the technical forum].
## List of Duniter's reviewers
- @librelois
- @tuxmain
[commit naming conventions]: ./docs/dev/git-conventions.md#naming-commits
[Developer documentation]: ./docs/dev/index.md
[project's git conventions]: ./docs/dev/git-conventions.md
[Setting up your development environment]: ./docs/setup.md
[the technical forum]: https://forum.duniter.org
......@@ -24,8 +24,11 @@ Use Rust's native `cargo` command to build and launch the node:
cargo run --release -- --dev --tmp
```
## Contribute
### Embedded Docs
Before any contribution, please read carefully the [CONTRIBUTING](./CONTRIBUTING.md) file and our [git conventions](./docs/dev/git-conventions.md).
## Embedded Docs
Once the project has been built, the following command can be used to explore all parameters and
subcommands:
......@@ -34,13 +37,7 @@ subcommands:
./target/release/lc-core -h
```
## Run
The provided `cargo run` command will launch a temporary node and its state will be discarded after
you terminate the process. After the project has been built, there are other ways to launch the
node.
### Single-Node Development Chain
## Single-Node Development Chain
This command will start the single-node development chain with persistent state:
......@@ -60,7 +57,7 @@ Start the development chain with detailed logging:
RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/lc-core -lruntime=debug --dev
```
### Connect with Polkadot-JS Apps Front-end
## Connect with Polkadot-JS Apps Front-end
Once the node template is running locally, you can connect it with **Polkadot-JS Apps** front-end
to interact with your chain. [Click here](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944) connecting the Apps to your local node template.
......@@ -69,12 +66,12 @@ CAUTION: In order for **Polkadot-JS Apps** to be able to fully understand the in
![js-app-custom-types](./images/js-app-custom-types.png)
### Multi-Node Local Testnet
## Multi-Node Local Testnet
If you want to see the multi-node consensus algorithm in action, refer to
[our Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/).
## Template Structure
## Project Structure
A Substrate project such as this consists of a number of components that are spread across a few
directories.
......@@ -165,7 +162,7 @@ A FRAME pallet is compromised of a number of blockchain primitives:
- Config: The `Config` configuration interface is used to define the types and parameters upon
which a FRAME pallet depends.
### Run in Docker
## Run in Docker
First, install [Docker](https://docs.docker.com/get-docker/) and
[Docker Compose](https://docs.docker.com/compose/install/).
......
# Duniter git conventions
## TL;DR summary of this page, workflow instructions
The summary gives an overview of the rules described below. Reading it will help you to dive into the details.
- draft work must be prefixed by "WIP" (work in progress)
- the naming of final commits must comply with the template `type(scope): action subject`
- one should communicate with developers through dedicated spaces
- integrating a contribution can only be done via a merge request on our gitlab option and since the following critera are fullfilled
- branch up to date with `master` branch (except hotfixes, see the hotfix section)
- idiomatic code formatting, automated tests passed successfully
- clean commit history, understandable and concise
- contribution approved by a reviewer
## Naming commits
Every commit must follow [conventional commit specification v1.0.0].
The commit name hase to be meaningful in the context of commit history reread. It should not make reference to a specific MR or discussion.
Among other, commit history is used in changlogs and to follow the project progress, that's why it has to be self-explanatory.
If you have a new need, please contact the main developers to add a type together.
## Update strategy
We only use **rebases**, *merges* are strictly fordbidden !
Every time the `master` branch is updated, you must rebase each of your working branch on it. For each of them:
1. Go on your branch
2. Run a rebase on master:
git rebase master
3. If you see conflicts, fix them by editing the sources. Once it is done, you must:
a. commit the files that were in conflict
b. continue the rebase with `git rebase --continue`
c. Do 3. again for each commit that will be in conflict.
4. When you don't have any conflict anymore after `git rebase --continue`, then the rebase succeeded. Then rebase a remaning branch.
To prevent accidental merge commits, we recommend that force the `--ff-only` option on the merge command:
git config --global merge.ff only
## When to push
Ideally, you should push when you are about to shut down your computer, so about once a day.
You must prefix your commit with `wip:` when it is a work in progress.
> But why push if I am not done ?
Pushing is no big deal and prevents you from loosing work in case of
any problem with your material.
## Before requesting proofreading of your merge request
After complying with the above criteria in your commits, you should check that your branch is up to date with the target branch (`master` in this example). As this branch is moving forward frequently, it is possible that new commits may have occurred while you were working on your branch (named YOUR_BRANCH, here). If this is the case or in case of doubt, to update your branch with respect to `master`, do the following:
git checkout master # switch to master branch
git pull # updates the remote branch based on remote
git checkout YOU_BRANCH # switch back to your branch
git rebase master # rebase you work on master branch
In case of conflict during rebase that you can not solve, contact a lead developer telling him the hash of the commit on which YOUR_BRANCH is currently based so he can reproduce the rebase and see the conflicts. While waiting for his answer, you can cancel the rebase and work on YOUR_BRANCH without updating:
git rebase --abort
It is better to take your time before integrating a new contribution because the history of the master branch cannot be modified: it is a protected branch. Each commit on this branch remains there *ad vitam aeternam* that is why we make sure to keep a clear and understandable commit history.
## Discussion in a merge request
On Gitlab, a discussion is opened for each merge request. It will allow you to discuss the changes you have made. Feel free to identify someone by writing @pseudo so that they are notified of your request. Don't be impatient, the review of your contribution may take more or less time depending on its content!
The general discussion is used to comment on the merge request as a whole, for example to tag a developer for a proofreading request. When it comes to discussing a specific change in the code, you should go to the "Changes" tab of the merge request and comment under the code extract involved. This makes it easier to break down the resolution of problems raised by the merge request via the "comment resolution" feature. Each segment can be marked as resolved, but only the reviewer is allowed to do so!
## How to merge
When you finished developing, you must compile, run linter and run all tests:
cargo fmt
cargo clippy
cd tests && npm test
Then commit everything.
In case you had a `wip:` prefix, you can remove it.
If you have a pile of commits, use the useful interactive rebase to clean up your branch history and create atomic ones:
git rebase -i master
There you can rename the `wip:` commits, you can "fixup" commits that go together, you can rename and re-order commits,...
After an interactive rebase, your local git history is different that yours in Gitlab, so you need a force push to make it to Gitlab:
git push -f
Now is time to go to Gitlab and re-check your commits.
Wait for the Continuous Integration pipeline to finish (it lasts ±20min), and at last when it is done you can remove the "WIP" mention of your Merge Request and mention (with "@name") the lead developers to ask for a code review.
## Workflow
There are 3 types of permanent branches:
- The `master` branch is the default branch (the trunk), all contributions must be merged to this branch (except hotfixes).
- The `stable` branch, it always points to the most recent tag of the latest stable release. It is used as a reference for documentation, in particular.
- The hotfix branches, in `hotfix/x.y` format. A hotfix branch for an `x.y` release is only created when there is a patch to be released to production on that `x.y` release that cannot wait for the next release.
## Hotfix
If a blocking bug occurs in production and requires a hotfix, the latter must be the subject of 2 issues and 2 branches :
1. The original issue, must be processed on a `hotfix/issue-number-or-bug-description` branch, then merged to the `hotfix/x.y` branch, where `x.y` is the version in production at that time.
2. A carryover issue must be created, quoting the original issue and tracing the bug fix to the `master` branch. If for any reason the hotfix does not need to be carried over to the `master` branch, the carryover issue should explain why and then be closed.
[conventional commit specification v1.0.0]: https://www.conventionalcommits.org/en/v1.0.0/#specification
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment