Skip to content

Commit

Permalink
docs: update the Docker test integration docs
Browse files Browse the repository at this point in the history
A top-level Dockerfile is now present which can be used to test this repo with prism.
  • Loading branch information
Sam Harrison committed Jul 1, 2020
1 parent 6728946 commit 91f4cd8
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 582 deletions.
110 changes: 23 additions & 87 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@ All third party contributors acknowledge that any contributions they provide wil
- [Please use our Bug Report Template](#please-use-our-bug-report-template)
- [Improvements to the Codebase](#improvements-to-the-codebase)
- [Development Environment](#development-environment)
- [There are two ways to get set up:](#there-are-two-ways-to-get-set-up)
- [1. Using Docker](#1-using-docker)
- [- OR -](#or)
- [2. Install and Run Locally](#2-install-and-run-locally)
- [Prerequisites](#prerequisites)
- [Initial setup:](#initial-setup)
- [Environment Variables](#environment-variables)
- [Execute:](#execute)
- [Prerequisites](#prerequisites)
- [Initial setup](#initial-setup)
- [Environment Variables](#environment-variables)
- [Execute:](#execute)
- [Understanding the Code Base](#understanding-the-code-base)
- [Testing](#testing)
- [Testing Multiple Versions of Python](#testing-multiple-versions-of-python)
- [Prerequisites:](#prerequisites)
- [Initial setup:](#initial-setup-1)
- [Execute:](#execute-1)
- [Style Guidelines & Naming Conventions](#style-guidelines--naming-conventions)
- [Creating a Pull Request<a name="creating-a-pull-request"></a>](#creating-a-pull-requesta-name%22creating-a-pull-request%22a)
- [Creating a Pull Request](#creating-a-pull-request)
- [Code Reviews](#code-reviews)

<a name="roadmap"></a>
We use [Milestones](https://github.com/sendgrid/sendgrid-python/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community reviews, comments, suggestions, and additional PRs are welcomed and encouraged.

There are a few ways to contribute, which we'll enumerate below:

<a name="feature-request"></a>
## Feature Request

If you'd like to make a feature request, please read this section.
Expand All @@ -40,7 +31,6 @@ The GitHub issue tracker is the preferred channel for library feature requests,
- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
- Please be respectful and considerate of others when commenting on issues

<a name="submit-a-bug-report"></a>
## Submit a Bug Report

Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
Expand All @@ -57,34 +47,28 @@ Before you decide to create a new issue, please try the following:

In order to make the process easier, we've included a [sample bug report template](ISSUE_TEMPLATE.md).

<a name="improvements-to-the-codebase"></a>
## Improvements to the Codebase

We welcome direct contributions to the sendgrid-python code base. Thank you!

### Development Environment ###
#### There are two ways to get set up: ####
#### 1. Using Docker ####
This is usually the easiest and fastest way to get set up.
You can use our Docker image to avoid setting up the development environment yourself. See [USAGE.md](https://github.com/sendgrid/sendgrid-python/blob/master/docker/USAGE.md).
### Development Environment

#### - OR - ####
#### 2. Install and Run Locally ####
#### Prerequisites

##### Prerequisites #####

- Python 2.7 and 3.4+
- Python version 2.7, 3.5, 3.6, 3.7, or 3.8
- [python_http_client](https://github.com/sendgrid/python-http-client)
- [ecdsa_python](https://github.com/starkbank/ecdsa-python)
- [pyenv](https://github.com/yyuu/pyenv)
- [tox](https://pypi.python.org/pypi/tox)

##### Initial setup: #####
#### Initial setup

```bash
git clone https://github.com/sendgrid/sendgrid-python.git
cd sendgrid-python
```

### Environment Variables
#### Environment Variables

First, get your free Twilio SendGrid account [here](https://sendgrid.com/free?source=sendgrid-python).

Expand All @@ -101,78 +85,31 @@ Then edit `.env` and insert your API key.
source .env
```

##### Execute: #####
#### Execute

See the [examples folder](https://github.com/sendgrid/sendgrid-python/tree/master/examples) to get started quickly.

If testing from the root directory of this repo, create a new file (e.g. test.py) and replace `import sendgrid` with `from sendgrid import *`

<a name="understanding-the-codebase"></a>
## Understanding the Code Base

**/examples**

Working examples that demonstrate usage.

**/tests**

Currently, we have unit and profiling tests.
- **/examples**
- Working examples that demonstrate usage.
- **/tests**
- Currently, we have unit and profiling tests.
- **/sendgrid**
- The Web API v3 client is `sendgrid.py`, the other files are legacy code for our mail send v2 endpoint.

**/sendgrid**

The Web API v3 client is `sendgrid.py`, the other files are legacy code for our mail send v2 endpoint.

<a name="testing"></a>
## Testing

The PR must pass all the tests before it is reviewed.

All test files are in the [`test`](https://github.com/sendgrid/sendgrid-python/test) directory.

For the purposes of contributing to this repo, please update the [`test_sendgrid.py`](https://github.com/sendgrid/sendgrid-python/tree/master/test/test_sendgrid.py) file with unit tests as you modify the code.

`python -m unittest discover -v`

### Testing Multiple Versions of Python

The PR must pass all the tests before it is reviewed.

#### Prerequisites: ####

The above local "Initial setup" is complete
All test files are in the [`test`](https://github.com/sendgrid/sendgrid-python/test) directory. For the purposes of contributing to this repo, please update the [`test_sendgrid.py`](https://github.com/sendgrid/sendgrid-python/tree/master/test/test_sendgrid.py) file with unit tests as you modify the code.

* [pyenv](https://github.com/yyuu/pyenv)
* [tox](https://pypi.python.org/pypi/tox)
* [prism](https://github.com/stoplightio/prism) v0.6 - It should be available in your PATH, but unittest script
will try to install it locally if not found. Apart from PATH env variable it will check in `~/bin` and `/usr/local/bin`.
You can install it by yourself in user dir by calling `source test/prism.sh`.
The integration tests require a Twilio SendGrid mock API in order to execute. We've simplified setting this up using Docker to run the tests. You will just need [Docker Desktop](https://docs.docker.com/get-docker/) and `make`.

#### Initial setup: ####

Add ```eval "$(pyenv init -)"``` to your shell environment (.profile, .bashrc, etc) after installing tox, you only need to do this once.

```
pyenv install 2.7.11
pyenv install 3.4.3
pyenv install 3.5.0
```
Make sure to change the current working directory to your local version of the repo before running the following command:
```
python setup.py install
```
```
pyenv local 3.5.0 3.4.3 2.7.11
pyenv rehash
```

#### Execute: ####

```
source venv/bin/activate
tox
```
Once these are available, simply execute the Docker test target to run all tests: `make test-docker`. This command can also be used to open an interactive shell into the container where this library is installed. To start a *bash* shell for example, use this command: `command=bash make test-docker`.

<a name="style-guidelines-and-naming-conventions"></a>
## Style Guidelines & Naming Conventions

Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
Expand All @@ -185,7 +122,7 @@ Please run your code through:
- [pylint](https://www.pylint.org/)
- [pep8](https://pypi.python.org/pypi/pep8)

## Creating a Pull Request<a name="creating-a-pull-request"></a>
## Creating a Pull Request

1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:
Expand Down Expand Up @@ -240,6 +177,5 @@ Please run your code through:
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.

<a name="code-reviews"></a>
## Code Reviews
If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, GitHub has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/).
20 changes: 0 additions & 20 deletions docker-test/Dockerfile

This file was deleted.

47 changes: 0 additions & 47 deletions docker-test/README.md

This file was deleted.

17 changes: 0 additions & 17 deletions docker-test/entrypoint.sh

This file was deleted.

50 changes: 0 additions & 50 deletions docker-test/prism.sh

This file was deleted.

52 changes: 0 additions & 52 deletions docker/Dockerfile

This file was deleted.

Loading

0 comments on commit 91f4cd8

Please sign in to comment.