|
| 1 | +--- |
| 2 | +sidebar_position: 6 |
| 3 | +--- |
| 4 | + |
| 5 | +# Contributing |
| 6 | + |
| 7 | +Contributions to Gilt are very welcome, but we ask that you read this document |
| 8 | +before submitting a PR. |
| 9 | + |
| 10 | +:::note |
| 11 | + |
| 12 | +This document applies to the [Gilt][] repository. |
| 13 | + |
| 14 | +::: |
| 15 | + |
| 16 | +## Before you start |
| 17 | + |
| 18 | +- **Check existing work** - Is there an existing PR? Are there issues discussing |
| 19 | + the feature/change you want to make? Please make sure you consider/address |
| 20 | + these discussions in your work. |
| 21 | +- **Backwards compatibility** - Will your change break existing Giltfiles? It is |
| 22 | + much more likely that your change will merged if it backwards compatible. Is |
| 23 | + there an approach you can take that maintains this compatibility? If not, |
| 24 | + consider opening an issue first so that API changes can be discussed before |
| 25 | + you invest your time into a PR. |
| 26 | + |
| 27 | +## 1. Setup |
| 28 | + |
| 29 | +- **Go** - Gilt is written in [Go][]. We always support the latest two major Go |
| 30 | + versions, so make sure your version is recent enough. |
| 31 | +- **Node.js** - [Node.js][] is used to host Gilt's documentation server and is |
| 32 | + required if you want to run this server locally. |
| 33 | + |
| 34 | +## 2. Making changes |
| 35 | + |
| 36 | +- **Code style** - Try to maintain the existing code style where possible. Go |
| 37 | + code should be formatted by [`gofumpt`][gofumpt] and linted using |
| 38 | + [`golangci-lint`][golangci-lint]. Any Markdown or TypeScript files should be |
| 39 | + formatted and linted by [Prettier][]. This style is enforced by our CI to |
| 40 | + ensure that we have a consistent style across the project. You can use the |
| 41 | + `task fmt:check` command to lint the code locally and the `task fmt` command |
| 42 | + to automatically fix any issues that are found. |
| 43 | +- **Documentation** - Ensure that you add/update any relevant documentation. See |
| 44 | + the [updating documentation](#updating-documentation) section below. |
| 45 | +- **Tests** - Ensure that you add/update any relevant tests and that all tests |
| 46 | + are passing before submitting the PR. See the [writing tests](#writing-tests) |
| 47 | + section below. |
| 48 | + |
| 49 | +### Running your changes |
| 50 | + |
| 51 | +To run Gilt with working changes, you can use `go run main.go overlay`. |
| 52 | + |
| 53 | +### Updating documentation |
| 54 | + |
| 55 | +Gilt uses [Docusaurus][] to host a documentation server. The code for this is |
| 56 | +located in the Gilt repository. This can be setup and run locally by using |
| 57 | +`task docs:start` (requires `nodejs` & `yarn`). All content is written in |
| 58 | +Markdown and is located in the `docs/docs` directory. All Markdown documents |
| 59 | +should have an 80 character line wrap limit (enforced by Prettier). |
| 60 | + |
| 61 | +### Writing tests |
| 62 | + |
| 63 | +When making a changes, consider whether new tests are required. These tests |
| 64 | +should ensure that the functionality you are adding will continue to work in the |
| 65 | +future. Existing tests may also need updating if you have changed Gilt's |
| 66 | +behavior. |
| 67 | + |
| 68 | +You may also consider adding unit tests for any new functions you have added. |
| 69 | +The unit tests should follow the Go convention of being location in a file named |
| 70 | +`*_test.go` in the same package as the code being tested. |
| 71 | + |
| 72 | +Integration tests are located in the `tests` directory and executed by [Bats][]. |
| 73 | + |
| 74 | +## 3. Committing your code |
| 75 | + |
| 76 | +Try to write meaningful commit messages and avoid having too many commits on the |
| 77 | +PR. Most PRs should likely have a single commit (although for bigger PRs it may |
| 78 | +be reasonable to split it in a few). Git squash and rebase is your friend! |
| 79 | + |
| 80 | +If you're not sure how to format your commit message, check out [Conventional |
| 81 | +Commits][]. This style is enforced, and is a good way to make your commit |
| 82 | +messages more readable and consistent. |
| 83 | + |
| 84 | +## 4. Submitting a PR |
| 85 | + |
| 86 | +- **Describe your changes** - Ensure that you provide a comprehensive |
| 87 | + description of your changes. |
| 88 | +- **Issue/PR links** - Link any previous work such as related issues or PRs. |
| 89 | + Please describe how your changes differ to/extend this work. |
| 90 | +- **Examples** - Add any examples or screenshots that you think are useful to |
| 91 | + demonstrate the effect of your changes. |
| 92 | +- **Draft PRs** - If your changes are incomplete, but you would like to discuss |
| 93 | + them, open the PR as a draft and add a comment to start a discussion. Using |
| 94 | + comments rather than the PR description allows the description to be updated |
| 95 | + later while preserving any discussions. |
| 96 | + |
| 97 | +## FAQ |
| 98 | + |
| 99 | +> I want to contribute, where do I start? |
| 100 | +
|
| 101 | +All kinds of contributions are welcome, whether its a typo fix or a shiny new |
| 102 | +feature. You can also contribute by upvoting/commenting on issues or helping to |
| 103 | +answer questions. |
| 104 | + |
| 105 | +> I'm stuck, where can I get help? |
| 106 | +
|
| 107 | +If you have questions, feel free open a [Discussion][] on GitHub. |
| 108 | + |
| 109 | +<!-- prettier-ignore-start --> |
| 110 | +[Gilt]: https://github.com/retr0h/gilt |
| 111 | +[Go]: https://go.dev |
| 112 | +[Node.js]: https://nodejs.org/en/ |
| 113 | +[gofumpt]: https://github.com/mvdan/gofumpt |
| 114 | +[golangci-lint]: https://golangci-lint.run |
| 115 | +[Prettier]: https://prettier.io/ |
| 116 | +[Docusaurus]: https://docusaurus.io |
| 117 | +[Discussion]: https://github.com/retr0h/gilt/discussions |
| 118 | +[Conventional Commits]: https://www.conventionalcommits.org |
| 119 | +[Bats]: https://github.com/bats-core/bats-core |
| 120 | +<!-- prettier-ignore-end --> |
0 commit comments