mirror of https://github.com/grafana/grafana
Docs: Improve guides for contributing (#19575)
* Move style guides into contribute directory * Move contribution guides into contribute directory * Refactor CONTRIBUTING.md * Clean up docs/README.md * Update reference to style guide and minor formatting fixes * Apply suggestions from code review Co-Authored-By: gotjosh <josue.abreu@gmail.com> * Update CONTRIBUTING.md Co-Authored-By: gotjosh <josue.abreu@gmail.com>pull/19652/head
parent
27ddd2d60f
commit
2fb301ccaf
@ -1,96 +1,60 @@ |
||||
# Contributing |
||||
# Contributing to Grafana |
||||
|
||||
Grafana uses GitHub to manage contributions. Contributions take the form of pull requests that will be reviewed by the core team. |
||||
Thank you for your interest in contributing to Grafana! We welcome all people who want to contribute in a healthy and constructive manner within our community. To help us create a safe and positive community experience for all, we require all participants to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md). |
||||
|
||||
- If you are a new contributor, see [Steps to contribute](#steps-to-contribute). |
||||
This document is a guide to help you through the process of contributing to Grafana. |
||||
|
||||
- If you have a trivial fix or improvement, go ahead and create a pull request. |
||||
## Become a contributor |
||||
|
||||
- If you plan to do something more involved, then discuss your idea on the respective [issue](https://github.com/grafana/grafana/issues) or create a [new issue](https://github.com/grafana/grafana/issues/new) if one does not exist. This helps avoid unnecessary work and gives you and us a good deal of inspiration. |
||||
You can contribute to Grafana in several ways. Here are some examples: |
||||
|
||||
- Sign our [CLA](http://docs.grafana.org/contribute/cla/). |
||||
- Contribute to the Grafana codebase. |
||||
- Report and triage bugs. |
||||
- Develop community plugins and dashboards. |
||||
- Write technical documentation and blog posts, for users and contributors. |
||||
- Organize meetups and user groups in your local area. |
||||
- Help others by answering questions about Grafana. |
||||
|
||||
- Follow the code style guides: |
||||
- [Backend style guide](https://github.com/grafana/grafana/tree/master/pkg) |
||||
- [Frontend style guide](https://github.com/grafana/grafana/tree/master/style_guides) |
||||
For more ways to contribute, check out the [Open Source Guides](https://opensource.guide/how-to-contribute/). |
||||
|
||||
## Steps to contribute |
||||
### Report bugs |
||||
|
||||
Should you wish to work on a GitHub issue, check first if it is not already assigned to someone. If it is free, you claim it by commenting on the issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue. |
||||
Report a bug by submitting a [bug report](https://github.com/grafana/grafana/issues/new?labels=type%3A+bug&template=1-bug_report.md). Make sure that you provide as much information as possible on how to reproduce the bug. |
||||
|
||||
Please check the [`beginner friendly`](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) and [`help wanted`](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) labels to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the core team or the original poster will clarify it. |
||||
Before submitting a new issue, try to make sure someone hasn't already reported the problem. Look through the [existing issues](https://github.com/grafana/grafana/issues) for similar issues. |
||||
|
||||
To set up a local development environment we recommend reading [Building Grafana from source](http://docs.grafana.org/project/building_from_source/). |
||||
#### Security issues |
||||
|
||||
## Pull request checklist |
||||
If you believe you've found a security vulnerability, please read our [security policy](https://github.com/grafana/grafana/security/policy) for more details. |
||||
|
||||
Whether you are contributing or doing code review, first read and understand https://google.github.io/eng-practices/review/reviewer/ for general engineering practices around code reviews that we also use. |
||||
### Suggest enhancements |
||||
|
||||
- Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master, then you might be asked to rebase your changes. |
||||
If you have an idea of how to improve Grafana, submit an [enhancement request](https://github.com/grafana/grafana/issues/new?labels=type%3A+feature+request&template=2-feature_request.md). |
||||
|
||||
- If your patch is not getting reviewed or you need a specific person to review it, then you can @-reply a reviewer asking for a review in the pull request or a comment. |
||||
### Your first contribution |
||||
|
||||
- Add tests relevant to the fixed bug or new feature. |
||||
Unsure where to begin contributing to Grafana? Start by browsing issues labeled `beginner friendly` or `help wanted`. |
||||
|
||||
### High-level checks |
||||
- [Beginner-friendly](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) issues are generally straightforward to complete. |
||||
- [Help wanted](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) issues are problems we would like the community to help us with regardless of complexity. |
||||
|
||||
- [ ] The pull request adds value and the impact of the change is in line with the [Backend style guide](https://github.com/grafana/grafana/tree/master/pkg) or [Frontend style guide](https://github.com/grafana/grafana/tree/master/style_guides). |
||||
- [ ] The pull request works the way it says it should do. |
||||
- [ ] The pull request closes one issue if possible and does not fix unrelated issues within the same pull request. |
||||
- [ ] The pull request contains necessary tests. |
||||
If you're looking to make a code change, see how to set up your environment for [local development](contribute/development.md). |
||||
|
||||
### Low-level checks |
||||
When you're ready to contribute, it's time to [Create a pull request](/contribute/pull-request.md). |
||||
|
||||
- [ ] The pull request contains a title that explains it. It follows [PR and commit messages guidelines](#Pull-Requests-titles-and-message). |
||||
- [ ] The pull request contains necessary links to issues. |
||||
- [ ] The pull request contains commits with messages that are small and understandable. It follows [PR and commit messages guidelines](#Pull-Requests-titles-and-message). |
||||
- [ ] The pull request does not contain magic strings or numbers that could be replaced with an `Enum` or `const` instead. |
||||
#### Contributor License Agreement (CLA) |
||||
|
||||
#### Bug-specific checks |
||||
Before we can accept your pull request, you need to [sign our CLA](https://grafana.com/docs/contribute/cla/). If you haven't, our CLA assistant prompts you to when you create your pull request. |
||||
|
||||
- [ ] The pull request contains `Closes: #Issue` or `Fixes: #Issue` in pull request description. |
||||
- [ ] The Pull Request adds tests that replicate the fixed bug and helps avoid regressions. |
||||
## Community |
||||
|
||||
### Frontend-specific checks |
||||
- Follow [@grafana on Twitter](https://twitter.com/grafana/) |
||||
- Read and subscribe to the [Grafana blog](https://grafana.com/blog/) |
||||
- If you have a specific question, check out our [discussion forums](https://community.grafana.com). |
||||
- For general discussions, join us on the [official Slack](http://slack.raintank.io/). |
||||
|
||||
- [ ] The pull request does not increase the Angular code base. |
||||
> We are in the process of migrating to React so any increment of Angular code is generally discouraged. |
||||
- [ ] The pull request does not contain uses of `any` or `{}` without comments describing why. |
||||
- [ ] The pull request does not contain large React components that could easily be split into several smaller components. |
||||
- [ ] The pull request does not contain back end calls directly from components, use actions and Redux instead. |
||||
- [ ] The pull request follows our [styling with Emotion convention](./style_guides/styling.md) |
||||
> We still use a lot of SASS, but any new CSS work should be using or migrating existing code to Emotion |
||||
## Where do I go from here? |
||||
|
||||
#### Redux specific checks (skip if your pull request does not contain Redux changes) |
||||
|
||||
- [ ] The pull request does not contain code that mutates state in reducers or thunks. |
||||
- [ ] The pull request uses helpers `actionCreatorFactory` and `reducerFactory` instead of traditional `switch statement` reducers in Redux. See [Redux framework](https://github.com/grafana/grafana/tree/master/style_guides/redux.md) for more details. |
||||
- [ ] The pull request uses `reducerTester` to test reducers. See [Redux framework](https://github.com/grafana/grafana/tree/master/style_guides/redux.md) for more details. |
||||
- [ ] The pull request does not contain code that accesses the reducers state slice directly, instead, the code uses state selectors to access state. |
||||
|
||||
### Pull request titles and message |
||||
|
||||
Pull request titles should follow this format: `Area: Name of the change`. Titles are used to generate the changelog so they should be as descriptive as possible in one line. |
||||
|
||||
Good examples: |
||||
|
||||
- `Explore: Adds Live option for supported data sources` |
||||
- `GraphPanel: Don't sort series when legend table & sort column is not visible` |
||||
- `Build: Support publishing MSI to grafana.com` |
||||
|
||||
The message in the pull requests should contain a reference so the issue if there is one. For example, `Closes #<issue number>`, `Fixes #<issue number>`, or `Ref #<issue number>` if the change is related to an issue but does not close it. Make sure to explain what problem the pull request is solving and why its implemented this way. As a new contributor its often better to overcommunicate to avoid back-and-forth communication, as it consumes time and energy. |
||||
|
||||
### Git commit formatting |
||||
|
||||
Grafana Squash Pull requests when merging them into master. This means the maintainer will be responsible for the title in the git commit message. |
||||
The commit message of the commits in the Pull Request can still be part of the git commit body. So it's always encouraged to write informative commit messages. |
||||
|
||||
The Git commit title should be short, descriptive and include the Pull Request ID. |
||||
|
||||
Good examples: |
||||
|
||||
- `Explore: Live supprt in data sources (#12345)` |
||||
- `GraphPanel: Fix legend sorting issues (#12345)` |
||||
- `Build: Support publishing MSI to grafana.com (#12345)` |
||||
|
||||
Its also good practice to include a reference to the issue in the Git commit body when possible. |
||||
- Set up your [development environment](contribute/development.md). |
||||
- Learn how to [contribute documentation](contribute/documentation.md). |
||||
- Get started [developing plugins](https://grafana.com/docs/plugins/developing/development/) for Grafana. |
||||
|
||||
@ -0,0 +1,94 @@ |
||||
# Create a pull request |
||||
|
||||
We're excited that you're considering making a contribution to the Grafana project! This document guides you through the process of creating a [pull request](https://help.github.com/en/articles/about-pull-requests/). |
||||
|
||||
## Before you begin |
||||
|
||||
We know you're excited to create your first pull request. Before we get started, read these resources first: |
||||
|
||||
- Learn how to start [Contributing to Grafana](https://grafana.com/docs/contribute/overview/). |
||||
- Make sure your code follows the relevant [style guides](/contribute/style-guides). |
||||
|
||||
## Your first pull request |
||||
|
||||
If this is your first time contributing to an open-source project on GitHub, make sure you read about [Creating a pull request](https://help.github.com/en/articles/creating-a-pull-request). |
||||
|
||||
To increase the chance of having your pull request accepted, make sure your pull request follows these guidelines: |
||||
|
||||
- Title and description matches the implementation. |
||||
- Commits within the pull request follow the [style guide](#style-guide). |
||||
- The pull request closes one related issue. |
||||
- The pull request contains necessary tests that verify the intended behavior. |
||||
- If your pull request has conflicts, rebase your branch onto the master branch. |
||||
|
||||
If the pull request fixes a bug: |
||||
|
||||
- The pull request description must include `Closes #<issue number>` or `Fixes #<issue number>`. |
||||
- To avoid regressions, the pull request should include tests that replicate the fixed bug. |
||||
|
||||
### Frontend-specific guidelines |
||||
|
||||
Pull requests for frontend contributions must: |
||||
|
||||
- Use [Emotion](https://github.com/grafana/grafana/blob/master/style_guides/styling.md) for styling. |
||||
- Not increase the Angular code base. |
||||
- Not use `any` or `{}` without reason. |
||||
- Not contain large React components that could easily be split into several smaller components. |
||||
- Not contain backend calls directly from components—use actions and Redux instead. |
||||
|
||||
Pull requests for Redux contributions must: |
||||
|
||||
- Use the `actionCreatorFactory` and `reducerFactory` helpers instead of traditional switch statement reducers in Redux. Refer to [Redux framework](https://github.com/grafana/grafana/tree/master/style_guides/redux.md) for more details. |
||||
- Use `reducerTester` to test reducers. Refer to [Redux framework](https://github.com/grafana/grafana/tree/master/style_guides/redux.md) for more details. |
||||
- Not contain code that mutates state in reducers or thunks. |
||||
- Not contain code that accesses the reducers state slice directly. Instead, the code should use state selectors to access state. |
||||
|
||||
## Code review |
||||
|
||||
Once you've created a pull request, the next step is to have someone review your change. A review is a learning opportunity for both the reviewer and the author of the pull request. |
||||
|
||||
If you think a specific person needs to review your pull request, then you can tag them in the description or in a comment. Tag a user by typing the `@` symbol followed by their GitHub username. |
||||
|
||||
We recommend that you read [How to do a code review](https://google.github.io/eng-practices/review/reviewer/) to learn more about code reviews. |
||||
|
||||
## Formatting guidelines |
||||
|
||||
A well-written pull request minimizes the time to get your change accepted. These guidelines help you write good commit messages and descriptions for your pull requests. |
||||
|
||||
### Commit message format |
||||
|
||||
Grafana uses the guidelines for commit messages outlined in [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/), with the following additions: |
||||
|
||||
- Subject line must begin with the _area_ of the commit. |
||||
- A footer in the form of an optional [keyword and issue reference](https://help.github.com/en/articles/closing-issues-using-keywords). |
||||
|
||||
#### Area |
||||
|
||||
The area should use upper camel case, e.g. UpperCamelCase. |
||||
|
||||
Prefer using one of the following areas: |
||||
|
||||
- **Build:** Changes to the build system, or external dependencies. |
||||
- **Chore:** Changes that don't affect functionality. |
||||
- **Dashboard:** Changes to the Dashboard feature. |
||||
- **Docs:** Changes to documentation. |
||||
- **Explore:** Changes to the Explore feature. |
||||
- **Plugins:** Changes to any of the plugins. |
||||
|
||||
For changes to data sources, the area should be the name of the data source, e.g., AzureMonitor, Graphite, and Prometheus. |
||||
|
||||
For changes to panels, the area should be the name of the panel, suffixed with Panel, e.g., GraphPanel, SinglestatPanel, and TablePanel. |
||||
|
||||
**Example** |
||||
|
||||
- `Build: Support publishing MSI to grafana.com` |
||||
- `Explore: Add Live option for supported data sources` |
||||
- `GraphPanel: Fix legend sorting issues` |
||||
|
||||
### Pull request titles |
||||
|
||||
The Grafana team _squashes_ all commits into one when we accept a pull request. The title of the pull request becomes the subject line of the squashed commit message. We still encourage contributors to write informative commit messages, as they becomes a part of the Git commit body. |
||||
|
||||
We use the pull request title when we generate change logs for releases. As such, we strive to make the title as informative as possible. |
||||
|
||||
Make sure that the title for your pull request uses the same format as the subject line in the commit message. |
||||
@ -1,11 +0,0 @@ |
||||
+++ |
||||
title = "Development" |
||||
type = "docs" |
||||
[menu.docs] |
||||
name = "Development" |
||||
identifier = "development" |
||||
parent = "contribute" |
||||
weight = 2 |
||||
+++ |
||||
|
||||
# Development |
||||
Loading…
Reference in new issue