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.

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