Skip to content

Commit

Permalink
Merge pull request #8 from globocom/py3
Browse files Browse the repository at this point in the history
Migrate to Py3
  • Loading branch information
devppjr authored Mar 15, 2022
2 parents e434c15 + 516e7ce commit 23cd16a
Show file tree
Hide file tree
Showing 19 changed files with 675 additions and 404 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: unittest
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install apt dependencies
run: sudo apt install -y libcurl4-openssl-dev libssl-dev libjpeg-dev
- name: Install pip dependencies
run: make setup
- run: make test
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
REDIS_CONTAINER := redis-test

test: run-redis unit stop-redis

unit:
@pytest --cov=tc_redis tests/ --asyncio-mode=strict --cov-report term-missing

setup:
@pip install -Ue .[tests]
@pre-commit install

format:
@pre-commit run --all-files

run-redis:
@docker-compose up -d $(REDIS_CONTAINER)

stop-redis:
@docker-compose stop $(REDIS_CONTAINER)
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,48 @@ Thumbor redis storage adapters.

## Installation

`pip install tc_redis`
```bash
pip install tc_redis
```

## Configuration

To use redis as a storage or result storage some values must be configured in `thumbor.conf`

##### Redis Storage
```
STORAGE='tc_redis.storages.redis_storage'

```python
STORAGE = "tc_redis.storages.redis_storage"

REDIS_STORAGE_IGNORE_ERRORS = True
REDIS_STORAGE_SERVER_PORT = 6379
REDIS_STORAGE_SERVER_HOST = 'localhost'
REDIS_STORAGE_SERVER_HOST = "localhost"
REDIS_STORAGE_SERVER_DB = 0
REDIS_STORAGE_SERVER_PASSWORD = None
```

##### Redis Result Storage

```
RESULT_STORAGE='tc_redis.result_storages.redis_result_storage'
```python
RESULT_STORAGE = "tc_redis.result_storages.redis_result_storage"

REDIS_RESULT_STORAGE_IGNORE_ERRORS = True
REDIS_RESULT_STORAGE_SERVER_PORT = 6379
REDIS_RESULT_STORAGE_SERVER_HOST = 'localhost'
REDIS_RESULT_STORAGE_SERVER_HOST = "localhost"
REDIS_RESULT_STORAGE_SERVER_DB = 0
REDIS_RESULT_STORAGE_SERVER_PASSWORD = None
```

## Contribute

To build tc_redis locally use

```bash
make setup
```

To run unit tests use

```bash
make test
```
7 changes: 0 additions & 7 deletions circle.yml

This file was deleted.

7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.8"

services:
redis-test:
image: "redis:6.2-alpine"
ports:
- 6379:6379
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

35 changes: 26 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@

try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')

long_description = pypandoc.convert("README.md", "rst")
except (IOError, ImportError):
long_description = 'Thumbor redis storage adapters'
long_description = "Thumbor redis storage adapters"


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


TESTS_REQUIREMENTS = [
"black==22.*,>=22.1.0",
"preggy==1.*,>=1.4.4",
"pyssim==0.*,>=0.4",
"pytest==7.*,>=7.0.0",
"pytest-cov==3.*,>=3.0.0",
"pytest-asyncio==0.*,>=0.18.0",
]

RUNTIME_REQUIREMENTS = [
"redis==4.*,>=4.1.3",
"thumbor==7.*,>=7.0.6",
"pre-commit==2.*,>=2.17.0",
]

setup(
name="tc_redis",
version="1.0.1",
Expand All @@ -23,12 +39,13 @@ def read(fname):
packages=find_packages(),
long_description=long_description,
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
],
install_requires=[
'thumbor>=5.0.0',
'redis'
]
install_requires=RUNTIME_REQUIREMENTS,
extras_require={
"all": RUNTIME_REQUIREMENTS,
"tests": RUNTIME_REQUIREMENTS + TESTS_REQUIREMENTS,
},
)
Loading

0 comments on commit 23cd16a

Please sign in to comment.