You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
14 KiB

  1. # Contribution Guidelines
  2. ## Table of Contents
  3. - [Contribution Guidelines](#contribution-guidelines)
  4. - [Introduction](#introduction)
  5. - [Bug reports](#bug-reports)
  6. - [Discuss your design](#discuss-your-design)
  7. - [Testing redux](#testing-redux)
  8. - [Vendoring](#vendoring)
  9. - [Translation](#translation)
  10. - [Code review](#code-review)
  11. - [Styleguide](#styleguide)
  12. - [Developer Certificate of Origin (DCO)](#developer-certificate-of-origin-dco)
  13. - [Release Cycle](#release-cycle)
  14. - [Maintainers](#maintainers)
  15. - [Owners](#owners)
  16. - [Versions](#versions)
  17. - [Releasing Gitea](#releasing-gitea)
  18. - [Copyright](#copyright)
  19. ## Introduction
  20. This document explains how to contribute changes to the Gitea project.
  21. It assumes you have followed the
  22. [installation instructions](https://docs.gitea.io/en-us/).
  23. Sensitive security-related issues should be reported to
  24. [security@gitea.io](mailto:security@gitea.io).
  25. For configuring IDE or code editor to develop Gitea see [IDE and code editor configuration](contrib/ide/)
  26. ## Bug reports
  27. Please search the issues on the issue tracker with a variety of keywords
  28. to ensure your bug is not already reported.
  29. If unique, [open an issue](https://github.com/go-gitea/gitea/issues/new)
  30. and answer the questions so we can understand and reproduce the
  31. problematic behavior.
  32. To show us that the issue you are having is in Gitea itself, please
  33. write clear, concise instructions so we can reproduce the behavior—
  34. even if it seems obvious. The more detailed and specific you are,
  35. the faster we can fix the issue. Check out [How to Report Bugs
  36. Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
  37. Please be kind, remember that Gitea comes at no cost to you, and you're
  38. getting free help.
  39. ## Discuss your design
  40. The project welcomes submissions. If you want to change or add something,
  41. please let everyone know what you're working on—[file an issue](https://github.com/go-gitea/gitea/issues/new)!
  42. Significant changes must go through the change proposal process
  43. before they can be accepted. To create a proposal, file an issue with
  44. your proposed changes documented, and make sure to note in the title
  45. of the issue that it is a proposal.
  46. This process gives everyone a chance to validate the design, helps
  47. prevent duplication of effort, and ensures that the idea fits inside
  48. the goals for the project and tools. It also checks that the design is
  49. sound before code is written; the code review tool is not the place for
  50. high-level discussions.
  51. ## Testing redux
  52. Before submitting a pull request, run all the tests for the whole tree
  53. to make sure your changes don't cause regression elsewhere.
  54. Here's how to run the test suite:
  55. - Install the correct version of the drone-cli package. As of this
  56. writing, the correct drone-cli version is
  57. [1.1.0](https://docs.drone.io/cli/install/).
  58. - Ensure you have enough free disk space. You will need at least
  59. 15-20 Gb of free disk space to hold all of the containers drone
  60. creates (a default AWS or GCE disk size won't work -- see
  61. [#6243](https://github.com/go-gitea/gitea/issues/6243)).
  62. - Change into the base directory of your copy of the gitea repository,
  63. and run `drone exec --event pull_request`.
  64. The drone version, command line, and disk requirements do change over
  65. time (see [#4053](https://github.com/go-gitea/gitea/issues/4053) and
  66. [#6243](https://github.com/go-gitea/gitea/issues/6243)); if you
  67. discover any issues, please feel free to send us a pull request to
  68. update these instructions.
  69. ## Vendoring
  70. We keep a cached copy of dependencies within the `vendor/` directory,
  71. managing updates via [Modules](https://golang.org/cmd/go/#hdr-Module_maintenance).
  72. Pull requests should only include `vendor/` updates if they are part of
  73. the same change, be it a bugfix or a feature addition.
  74. The `vendor/` update needs to be justified as part of the PR description,
  75. and must be verified by the reviewers and/or merger to always reference
  76. an existing upstream commit.
  77. You can find more information on how to get started with it on the [Modules Wiki](https://github.com/golang/go/wiki/Modules).
  78. ## Translation
  79. We do all translation work inside [Crowdin](https://crowdin.com/project/gitea).
  80. The only translation that is maintained in this git repository is
  81. [`en_US.ini`](https://github.com/go-gitea/gitea/blob/master/options/locale/locale_en-US.ini)
  82. and is synced regularly to Crowdin. Once a translation has reached
  83. A SATISFACTORY PERCENTAGE it will be synced back into this repo and
  84. included in the next released version.
  85. ## Building Gitea
  86. Generally, the go build tools are installed as-needed in the `Makefile`.
  87. An exception are the tools to build the CSS and images.
  88. - To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager) at version 8.0 or above
  89. with `npm` and then run `npm install` and `make css`.
  90. - To build Images: ImageMagick, inkscape and zopflipng binaries must be
  91. available in your `PATH` to run `make generate-images`.
  92. ## Code review
  93. Changes to Gitea must be reviewed before they are accepted—no matter who
  94. makes the change, even if they are an owner or a maintainer. We use GitHub's
  95. pull request workflow to do that. And, we also use [LGTM](http://lgtm.co)
  96. to ensure every PR is reviewed by at least 2 maintainers.
  97. Please try to make your pull request easy to review for us. And, please read
  98. the *[How to get faster PR reviews](https://github.com/kubernetes/community/blob/261cb0fd089b64002c91e8eddceebf032462ccd6/contributors/guide/pull-requests.md#best-practices-for-faster-reviews)* guide;
  99. it has lots of useful tips for any project you may want to contribute.
  100. Some of the key points:
  101. * Make small pull requests. The smaller, the faster to review and the
  102. more likely it will be merged soon.
  103. * Don't make changes unrelated to your PR. Maybe there are typos on
  104. some comments, maybe refactoring would be welcome on a function... but
  105. if that is not related to your PR, please make *another* PR for that.
  106. * Split big pull requests into multiple small ones. An incremental change
  107. will be faster to review than a huge PR.
  108. ## Styleguide
  109. For imports you should use the following format (_without_ the comments)
  110. ```go
  111. import (
  112. // stdlib
  113. "encoding/json"
  114. "fmt"
  115. // local packages
  116. "code.gitea.io/gitea/models"
  117. "code.gitea.io/sdk/gitea"
  118. // external packages
  119. "github.com/foo/bar"
  120. "gopkg.io/baz.v1"
  121. )
  122. ```
  123. ## Developer Certificate of Origin (DCO)
  124. We consider the act of contributing to the code by submitting a Pull
  125. Request as the "Sign off" or agreement to the certifications and terms
  126. of the [DCO](DCO) and [MIT license](LICENSE). No further action is required.
  127. Additionally you could add a line at the end of your commit message.
  128. ```
  129. Signed-off-by: Joe Smith <joe.smith@email.com>
  130. ```
  131. If you set your `user.name` and `user.email` git configs, you can add the
  132. line to the end of your commit automatically with `git commit -s`.
  133. We assume in good faith that the information you provide is legally binding.
  134. ## Release Cycle
  135. We adopted a release schedule to streamline the process of working
  136. on, finishing, and issuing releases. The overall goal is to make a
  137. minor release every two months, which breaks down into one month of
  138. general development followed by one month of testing and polishing
  139. known as the release freeze. All the feature pull requests should be
  140. merged in the first month of one release period. And, during the frozen
  141. period, a corresponding release branch is open for fixes backported from
  142. master. Release candidates are made during this period for user testing to
  143. obtain a final version that is maintained in this branch. A release is
  144. maintained by issuing patch releases to only correct critical problems
  145. such as crashes or security issues.
  146. Major release cycles are bimonthly. They always begin on the 25th and end on
  147. the 24th (i.e., the 25th of December to February 24th).
  148. During a development cycle, we may also publish any necessary minor releases
  149. for the previous version. For example, if the latest, published release is
  150. v1.2, then minor changes for the previous release—e.g., v1.1.0 -> v1.1.1—are
  151. still possible.
  152. ## Maintainers
  153. To make sure every PR is checked, we have [team
  154. maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least
  155. two maintainers (or owners) before it can get merged. A maintainer
  156. should be a contributor of Gitea (or Gogs) and contributed at least
  157. 4 accepted PRs. A contributor should apply as a maintainer in the
  158. [Discord](https://discord.gg/NsatcWJ) #develop channel. The owners
  159. or the team maintainers may invite the contributor. A maintainer
  160. should spend some time on code reviews. If a maintainer has no
  161. time to do that, they should apply to leave the maintainers team
  162. and we will give them the honor of being a member of the [advisors
  163. team](https://github.com/orgs/go-gitea/teams/advisors). Of course, if
  164. an advisor has time to code review, we will gladly welcome them back
  165. to the maintainers team. If a maintainer is inactive for more than 3
  166. months and forgets to leave the maintainers team, the owners may move
  167. him or her from the maintainers team to the advisors team.
  168. For security reasons, Maintainers should use 2FA for their accounts and
  169. if possible provide gpg signed commits.
  170. https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
  171. https://help.github.com/articles/signing-commits-with-gpg/
  172. ## Owners
  173. Since Gitea is a pure community organization without any company support,
  174. to keep the development healthy we will elect three owners every year. All
  175. contributors may vote to elect up to three candidates, one of which will
  176. be the main owner, and the other two the assistant owners. When the new
  177. owners have been elected, the old owners will give up ownership to the
  178. newly elected owners. If an owner is unable to do so, the other owners
  179. will assist in ceding ownership to the newly elected owners.
  180. For security reasons, Owners or any account with write access (like a bot)
  181. must use 2FA.
  182. https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
  183. After the election, the new owners should proactively agree
  184. with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the
  185. [Discord](https://discord.gg/NsatcWJ) #general channel. Below are the
  186. words to speak:
  187. ```
  188. I'm honored to having been elected an owner of Gitea, I agree with
  189. [CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea
  190. and lead the development of Gitea.
  191. ```
  192. To honor the past owners, here's the history of the owners and the time
  193. they served:
  194. * 2016-11-04 ~ 2017-12-31
  195. * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
  196. * [Thomas Boerger](https://github.com/tboerger) <thomas@webhippie.de>
  197. * [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
  198. * 2018-01-01 ~ 2018-12-31
  199. * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
  200. * [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
  201. * [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
  202. * 2019-01-01 ~ 2019-12-31
  203. * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
  204. * [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
  205. * [Matti Ranta](https://github.com/techknowlogick) <matti@mdranta.net>
  206. ## Versions
  207. Gitea has the `master` branch as a tip branch and has version branches
  208. such as `release/v0.9`. `release/v0.9` is a release branch and we will
  209. tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept
  210. pull requests on the `release/v0.9` branch and publish a `v0.9.1` tag,
  211. after bringing the bug fix also to the master branch.
  212. Since the `master` branch is a tip version, if you wish to use Gitea
  213. in production, please download the latest release tag version. All the
  214. branches will be protected via GitHub, all the PRs to every branch must
  215. be reviewed by two maintainers and must pass the automatic tests.
  216. ## Releasing Gitea
  217. * Let $vmaj, $vmin and $vpat be Major, Minor and Patch version numbers, $vpat should be rc1, rc2, 0, 1, ...... $vmaj.$vmin will be kept the same as milestones on github or gitea in future.
  218. * Before releasing, confirm all the version's milestone issues or PRs has been resolved. Then discuss the release on discord channel #maintainers and get agreed with almost all the owners and mergers. Or you can declare the version and if nobody against in about serval hours.
  219. * If this is a big version first you have to create PR for changelog on branch `master` with PRs with label `changelog` and after it has been merged do following steps:
  220. * Create `-dev` tag as `git tag -s -F release.notes v$vmaj.$vmin.0-dev` and push the tag as `git push origin v$vmaj.$vmin.0-dev`.
  221. * When CI has finished building tag then you have to create a new branch named `release/v$vmaj.$vmin`
  222. * If it is bugfix version create PR for changelog on branch `release/v$vmaj.$vmin` and wait till it is reviewed and merged.
  223. * Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
  224. * And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically created a release and upload all the compiled binary. (But currently it didn't add the release notes automatically. Maybe we should fix that.)
  225. * If needed send PR for changelog on branch `master`.
  226. * Send PR to [blog repository](https://github.com/go-gitea/blog) announcing the release.
  227. ## Copyright
  228. Code that you contribute should use the standard copyright header:
  229. ```
  230. // Copyright 2019 The Gitea Authors. All rights reserved.
  231. // Use of this source code is governed by a MIT-style
  232. // license that can be found in the LICENSE file.
  233. ```
  234. Files in the repository contain copyright from the year they are added
  235. to the year they are last changed. If the copyright author is changed,
  236. just paste the header below the old one.