Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CONTRIBUTING.md #2411

Merged
merged 12 commits into from
Oct 4, 2023
46 changes: 19 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ This file outlines the process to contribute to the SDK itself. For contributing

## How to Report a Problem

Please search the [issue tracker](https://github.com/getsentry/sentry-python/issues) before creating a new issue (a problem or an improvement request). Please also ask in our [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr) before submitting a new issue. There is a ton of great people in our Discord community ready to help you!
Please search the [issue tracker](https://github.com/getsentry/sentry-python/issues) before creating a new issue (a problem or an improvement request). Please also ask in our [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr) before submitting a new issue. There are a ton of great people in our Discord community ready to help you!

If you feel that you can fix or implement it yourself, please read a few paragraphs below to learn how to submit your changes.

## Submitting Changes

- Fork the `sentry-python` repo and prepare your changes.
- Add tests for your changes to `tests/`.
- Run tests and make sure all of them pass.
- Submit a pull request, referencing any issues it addresses.
- Submit a pull request, referencing any issues your changes address. Please follow our [commit message format](https://develop.sentry.dev/commit-messages/#commit-message-format) when naming your pull request.

We will review your pull request as soon as possible. Thank you for contributing!

Expand All @@ -29,17 +28,9 @@ On macOS, we recommend using `brew` to install Python. For Windows, we recommend

### Fork the Repo

Go to the [home page of the repo](https://github.com/getsentry/sentry-python), click the "Fork" button, and go through the process of creating your fork of `sentry-python`.
Before you can contribute, you will need to [fork the `sentry-python` repository](https://github.com/getsentry/sentry-python/fork).

### Clone the Forked Repo

You should now have a new `sentry-python` repo in your GitHub projects. Clone it to work on it locally:

```bash
git clone git@github.com:<YOUR-USERNAME>/sentry-python.git
```

Replace `<YOUR-USERNAME>` with your actual GitHub username. Alternatively, you can go to your GitHub profile, find the forked `sentry-python` repo, and copy the clone URL from there.
Then, clone the forked repository to your local development environment.
sentrivana marked this conversation as resolved.
Show resolved Hide resolved

### Create a Virtual Environment

Expand All @@ -50,7 +41,12 @@ used by your operation system, create a virtual environment:
cd sentry-python

python -m venv .venv
```

From now on, every time you want to work on your changes for `sentry-python`,
you will need to make sure your virtual environment is active:
sentrivana marked this conversation as resolved.
Show resolved Hide resolved

```bash
source .venv/bin/activate
sentrivana marked this conversation as resolved.
Show resolved Hide resolved
```

Expand Down Expand Up @@ -98,7 +94,7 @@ If you would like to run the tests for a specific integration, use a command sim
pytest -rs tests/integrations/flask/ # Replace "flask" with the specific integration you wish to test
```

**Hint:** Tests of integrations need additional dependencies. The switch `-rs` will show you why tests where skipped and what dependencies you need to install for the tests to run. (You can also consult the [tox.ini](tox.ini) file to see what dependencies are installed for each integration)
**Hint:** Tests of integrations need additional dependencies. The switch `-rs` will show you why tests were skipped and what dependencies you need to install for the tests to run. (You can also consult the [tox.ini](tox.ini) file to see what dependencies are installed for each integration)

## Adding a New Integration

Expand All @@ -112,33 +108,29 @@ pytest -rs tests/integrations/flask/ # Replace "flask" with the specific integr

- You don't need to feel bad about it.

- Make sure your changes don't break end user contracts. The SDK should never alter the expected behavior of the underlying library or framework from the user's perspective and it shouldn't have any side effects.

- Avoid modifying the hub, registering a new client or the like. The user drives the client, and the client owns integrations.

- Allow the user to disable the integration by changing the client. Check `Hub.current.get_integration(MyIntegration)` from within your signal handlers to see if your integration is still active before you do anything impactful (such as sending an event).
- Allow the user to turn off the integration by changing the client. Check `Hub.current.get_integration(MyIntegration)` from within your signal handlers to see if your integration is still active before you do anything impactful (such as sending an event).

2. Write tests.

- Think about the minimum versions supported, and test each version in a separate env in `tox.ini`.
- Consider the minimum versions supported, and test each version in a separate env in `tox.ini`.

- Create a new folder in `tests/integrations/`, with an `__init__` file that skips the entire suite if the package is not installed.

3. Update package metadata.

- We use `extras_require` in `setup.py` to communicate minimum version requirements for integrations. People can use this in combination with tools like Poetry or Pipenv to detect conflicts between our supported versions and their used versions programmatically.

Do not set upper-bounds on version requirements as people are often faster in adopting new versions of a web framework than we are in adding them to the test matrix or our package metadata.

4. Write the [docs](https://github.com/getsentry/sentry-docs). Follow the structure of [existing integration docs](https://docs.sentry.io/platforms/python/integrations/). Make sure to add your integration to the table in `python/integrations/index.md` (people forget to do that all the time).

5. Merge docs after new version has been released (auto-deploys on merge).

6. (optional) Update data in [`sdk_updates.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/sdk_updates.py) to give users in-app suggestions to use your integration. May not be applicable or doable for all kinds of integrations.
Do not set upper bounds on version requirements as people are often faster in adopting new versions of a web framework than we are in adding them to the test matrix or our package metadata.

## Commit Message Format Guidelines
4. Write the [docs](https://github.com/getsentry/sentry-docs). Follow the structure of [existing integration docs](https://docs.sentry.io/platforms/python/integrations/). And, please **make sure to add your integration to the table in `python/integrations/index.md`** (people often forget this step 🙂).

See the documentation on commit messages here:
5. Merge docs after new version has been released. The docs are built and deployed after each merge, so your changes should go live in a few minutes.

https://develop.sentry.dev/commit-messages/#commit-message-format
6. (optional, if possible) Update data in [`sdk_updates.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/sdk_updates.py) to give users in-app suggestions to use your integration. This step will only apply to some integrations.

## Releasing a New Version

Expand All @@ -153,7 +145,7 @@ _(only relevant for Sentry employees)_
### Manual Process

- On GitHub in the `sentry-python` repository, go to "Actions" and select the "Release" workflow.
- Click on "Run workflow" on the right side, make sure the `master` branch is selected.
- Click on "Run workflow" on the right side, and make sure the `master` branch is selected.
- Set the "Version to release" input field. Here you decide if it is a major, minor or patch release. (See "Versioning Policy" below)
- Click "Run Workflow".

Expand Down
Loading