|
| 1 | + |
| 2 | +# Contributing |
| 3 | + |
| 4 | +🚀 Thank you for contributing to cdevents! 🚀 |
| 5 | + |
| 6 | +## Architecture |
| 7 | + |
| 8 | +The workspace is composed of: |
| 9 | + |
| 10 | +- `cdevents-sdk`: the published rust crate |
| 11 | +- `cdevents-specs`: the different version of cdevent's specifications used to generate and validate part of `cdevents-sdk` |
| 12 | +- `generator`: the code generator, used to generate a part of `cdevents-sdk` from `cdevents-specs` |
| 13 | + |
| 14 | +Few design's rules: |
| 15 | + |
| 16 | +- The generated code is commited, so users of `cdevents-sdk` don't to generate it at each build. |
| 17 | +- TO COMPLETE |
| 18 | + |
| 19 | +## Setting up a development environment |
| 20 | + |
| 21 | +### Setup a GitHub account accessible via SSH |
| 22 | + |
| 23 | +GitHub is used for project Source Code Management (SCM) using the SSH protocol for authentication. |
| 24 | + |
| 25 | +1. Create [a GitHub account](https://github.com/join) if you do not already have one. |
| 26 | +1. Setup |
| 27 | +[GitHub access via SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) |
| 28 | + |
| 29 | +### Install tools |
| 30 | + |
| 31 | +You must install these tools: |
| 32 | + |
| 33 | +1. [`git`](https://help.github.com/articles/set-up-git/): For source control |
| 34 | + |
| 35 | +2. If you use [mise](https://mise.jdx.dev/): `mise install` (after git clone) |
| 36 | + Else look into the mise configuration file [`.mise.toml`](https://github.com/cdevents/sdk-rust/blob/main/.mise.toml) to have the list of tools to install |
| 37 | + |
| 38 | +### Setup a fork |
| 39 | + |
| 40 | +The sdk-rust project requires that you develop (commit) code changes to branches that belong to a fork of the `cdevents/sdk-rust` repository in your GitHub account before submitting them as Pull Requests (PRs) to the actual project repository. |
| 41 | + |
| 42 | +1. [Create a fork](https://help.github.com/articles/fork-a-repo/) of the `cdevents/sdk-rust` repository in your GitHub account. |
| 43 | + |
| 44 | +1. Create a clone of your fork on your local machine: |
| 45 | + |
| 46 | + ```shell |
| 47 | + git clone git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git |
| 48 | + ``` |
| 49 | + |
| 50 | +1. Configure `git` remote repositories |
| 51 | + |
| 52 | + Adding `cdevents/sdk-rust` as the `upstream` and your fork as the `origin` remote repositories to your `.git/config` sets you up nicely for regularly [syncing your fork](https://help.github.com/articles/syncing-a-fork/) and submitting pull requests. |
| 53 | + |
| 54 | + 1. Change into the project directory |
| 55 | + |
| 56 | + ```shell |
| 57 | + cd sdk-rust |
| 58 | + ``` |
| 59 | + |
| 60 | + 2. Retrieve submodules |
| 61 | + |
| 62 | + ```shell |
| 63 | + git submodule init |
| 64 | + git submodule update --init --recursive |
| 65 | + ``` |
| 66 | + |
| 67 | + 3. Configure sdk-rust as the `upstream` repository |
| 68 | + |
| 69 | + ```shell |
| 70 | + git remote add upstream git@github.com:cdevents/sdk-rust.git |
| 71 | +
|
| 72 | + # Optional: Prevent accidental pushing of commits by changing the upstream URL to `no_push` |
| 73 | + git remote set-url --push upstream no_push |
| 74 | + ``` |
| 75 | + |
| 76 | + 4. Configure your fork as the `origin` repository |
| 77 | + |
| 78 | + ```shell |
| 79 | + git remote add origin git@github.com:${YOUR_GITHUB_USERNAME}/sdk-rust.git |
| 80 | + ``` |
| 81 | + |
| 82 | +## Development |
| 83 | + |
| 84 | +### Work into a branch |
| 85 | + |
| 86 | +```shell |
| 87 | +git switch -c feat_foo |
| 88 | +``` |
| 89 | + |
| 90 | +### Building and testing |
| 91 | + |
| 92 | +To format the rust code and imports: |
| 93 | + |
| 94 | +```shell |
| 95 | +make fmt |
| 96 | +``` |
| 97 | + |
| 98 | +To run the go linter: |
| 99 | + |
| 100 | +```shell |
| 101 | +make lint |
| 102 | +``` |
| 103 | + |
| 104 | +To run unit tests: |
| 105 | + |
| 106 | +```shell |
| 107 | +make test |
| 108 | +``` |
| 109 | + |
| 110 | +### Commit & push |
| 111 | + |
| 112 | +Commit's message should follow the [conventional commit] convention: |
| 113 | +e.g. |
| 114 | +
|
| 115 | +```txt |
| 116 | +feat: my super feature |
| 117 | +
|
| 118 | +... |
| 119 | +``` |
| 120 | +
|
| 121 | +```txt |
| 122 | +fix: bug blablabla |
| 123 | +
|
| 124 | +FIX #99 |
| 125 | +``` |
| 126 | +
|
| 127 | +### Review & merge |
| 128 | +
|
| 129 | +Create a PR (pull request) and ask for review. |
| 130 | +The last reviewer, will "Squash & merge" when ready. |
| 131 | +The message of the squashed commit follows the [conventional commit], and aggregate/summaries commits of the branch. |
| 132 | +
|
| 133 | + [conventional commit]: https://www.conventionalcommits.org/en/v1.0.0/#summary |
0 commit comments