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

Improve contribution process #239

Merged
merged 6 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributing to Trino Python Client

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to [submit a CLA](https://github.com/trinodb/cla).

## License

By contributing to Trino Python Client, you agree that your contributions will be licensed under the [Apache License Version 2.0 (APLv2)](../LICENSE).
134 changes: 134 additions & 0 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Development

Developers should read [the development section of the website](https://trino.io/development),
which covers things like development philosophy and contribution process.

* [Getting started](#getting-started)
* [Running tests](#running-tests)
* [Commits and pull requests](#commits-and-pull-requests)
* [Code style](#code-style)
* [Releasing](#releasing)

## Getting started

Start by forking the repository and then modify the code in your fork.

We recommend that you use Python3's `venv` for development:

```
python3 -m venv .venv
. .venv/bin/activate
pip install -e '.[tests]'
```

With `-e` passed to `pip install` above pip can reference the code you are
modifying in the *virtual env*. That way, you do not need to run `pip install`
again to make your changes applied to the *virtual env*.

## Running tests

`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run
only unit tests, type:

```
pytest tests/unit
```

Then you can pass options like `--pdb` or anything supported by `pytest --help`.

To run integration tests:

```
pytest tests/integration
```

They pull a Docker image and then run a container with a Trino server:
- the image is named `trinodb/trino:${TRINO_VERSION}`
- the container is named `trino-python-client-tests-{uuid4()[:7]}`

To run the tests with different versions of Python in managed *virtual envs*,
use `tox` (see the configuration in `tox.ini`):

```
tox
```

When the code is ready, submit a Pull Request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps indicating somewhere that creating an issue before actually starting working on something make sense to avoid unnecessary work which won't be accepted by maintainers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the first things linked from this DEVELOPMENT.md page - https://trino.io/development/process.html


## Commits and pull requests

See [Commits and pull requests](https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md#commits-and-pull-requests) section from Trino.

## Code style

To run linting and formatting checks before opening a PR: `pip install pre-commit && pre-commit run --all-files`

In addition to that you should also adhere to the following:

### Readability

Prefer code that is readable over one that is "clever". The purpose of code
style rules is to maintain code readability and developer efficiency when
working with the code. All the code style rules explained below are good
guidelines to follow but there may be exceptional situations where we
purposefully depart from them. When readability and code style rule are at
odds, the readability is more important.

### Consistency

Keep code consistent with surrounding code where possible.

### Avoid mocks where possible

Do not use mocking libraries. These libraries encourage testing specific call
sequences, interactions, and other internal behavior, which we believe leads to
fragile tests. They also make it possible to mock complex interfaces or
classes, which hides the fact that these classes are not (easily) testable. We
prefer to write mocks by hand, which forces code to be written in a certain
testable style.

We also acknowledge that there is existing code which uses mocks but that
should not be taken as a reason increase reliance on mocks.

### Maintain production quality for test code

Maintain the same quality for production and test code.

### Avoid abbreviations

Please avoid abbreviations, slang or inside jokes as this makes harder for
non-native english speaker to understand the code. Very well known
abbreviations like `max` or `min` and ones already very commonly used across
the code base like `ttl` are allowed and encouraged.

## Releasing

- [Set up your development environment](#getting-started).
- Check the local workspace is up to date and has no uncommitted changes
```bash
git fetch -a && git status
```
- Change version in `trino/__init__.py` to a new version, e.g. `0.123.0`.
- Commit
```bash
git commit -a -m "Bump version to 0.123.0"
```
- Create an annotated tag
```bash
git tag -m "" 0.123.0
```
- Create release package and upload it to PyPI
```bash
. .venv/bin/activate && \
pip install twine wheel setuptools && \
rm -rf dist/ && \
./setup.py sdist bdist_wheel && \
twine upload dist/* && \
open https://pypi.org/project/trino/ && \
echo "Released!"
```
- Push the branch and the tag
```bash
git push upstream master 0.123.0
```
- Send release announcement on the *#python-client* channel on [Trino Slack](https://trino.io/slack.html).
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- Mark the appropriate option with an (x). Propose a release note if you can. -->
## Release notes

( ) This is not user-visible and no release notes are required.
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- "master"
pull_request:
paths-ignore:
- '**.md'

# Cancel previous PR builds.
concurrency:
Expand Down
99 changes: 8 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ It supports Python>=3.7 and pypy.
[![Trino Slack](https://img.shields.io/static/v1?logo=slack&logoColor=959DA5&label=Slack&labelColor=333a41&message=join%20conversation&color=3AC358)](https://trino.io/slack.html)
[![Trino: The Definitive Guide book download](https://img.shields.io/badge/Trino%3A%20The%20Definitive%20Guide-download-brightgreen)](https://www.starburst.io/info/oreilly-trino-guide/)

## Development

See [DEVELOPMENT](.github/DEVELOPMENT.md) for information about code style,
development process, and guidelines.

See [CONTRIBUTING](.github/CONTRIBUTING.md) for contribution requirements.

## Usage

### The Python Database API (DBAPI)
Expand Down Expand Up @@ -412,101 +419,11 @@ assert rows[0][0] == params
assert cur.description[0][1] == "timestamp with time zone"
```

# Development

## Getting started with development

Start by forking the repository and then modify the code in your fork.

We recommend that you use Python3's `venv` for development:

```
$ python3 -m venv .venv
$ . .venv/bin/activate
$ pip install -e '.[tests]'
```

With `-e` passed to `pip install` above pip can reference the code you are
modifying in the *virtual env*. That way, you do not need to run `pip install`
again to make your changes applied to the *virtual env*.

When the code is ready, submit a Pull Request.

### Code style

- For Python code, adhere to PEP 8.
- Prefer code that is readable over one that is "clever".
- When writing a Git commit message, follow these [guidelines](https://chris.beams.io/posts/git-commit/).

See also Trino's [guidelines](https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md).
Most of them also apply to code in trino-python-client.

### Running tests

`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run
only unit tests, type:

```
$ pytest tests/unit
```

Then you can pass options like `--pdb` or anything supported by `pytest --help`.

To run integration tests:

```
$ pytest tests/integration
```

They pull a Docker image and then run a container with a Trino server:
- the image is named `trinodb/trino:${TRINO_VERSION}`
- the container is named `trino-python-client-tests-{uuid4()[:7]}`

To run the tests with different versions of Python in managed *virtual envs*,
use `tox` (see the configuration in `tox.ini`):

```
$ tox
```

## Releasing

- [Set up your development environment](#Getting-Started-With-Development).
- Check the local workspace is up to date and has no uncommitted changes
```bash
git fetch -a && git status
```
- Change version in `trino/__init__.py` to a new version, e.g. `0.123.0`.
- Commit
```bash
git commit -a -m "Bump version to 0.123.0"
```
- Create an annotated tag
```bash
git tag -m "" 0.123.0
```
- Create release package and upload it to PyPI
```bash
. .venv/bin/activate && \
pip install twine wheel setuptools && \
rm -rf dist/ && \
./setup.py sdist bdist_wheel && \
twine upload dist/* && \
open https://pypi.org/project/trino/ && \
echo "Released!"
```
- Push the branch and the tag
```bash
git push upstream master 0.123.0
```
- Send release announcement on the *#python-client* channel on [Trino Slack][trino-slack].

# Need help?

Feel free to create an issue as it makes your request visible to other users and contributors.

If an interactive discussion would be better or if you just want to hangout and chat about
the Trino Python client, you can join us on the *#python-client* channel on
[Trino Slack][trino-slack].
[Trino Slack](https://trino.io/slack.html).

[trino-slack]: https://trino.io/slack.html