Skip to content
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
3 changes: 3 additions & 0 deletions .circleci/circle_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
poetry>=1.1.6
tox>=3.23.1
tox-poetry>=0.3.0
144 changes: 106 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,135 @@
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.1

- image: redislabs/rejson:edge
port: 6379:6379
version: 2.1

working_directory: ~/repo
commands:

abort_for_docs:
steps:
- run:
name: Avoid tests for docs
command: |
if [[ $CIRCLE_BRANCH == *docs ]]; then
echo "Identifies as documents PR, no testing required"
circleci step halt
fi

abort_for_noci:
steps:
- run:
name: Ignore CI for specific branches
command: |
if [[ $CIRCLE_BRANCH == *noci ]]; then
echo "Identifies as actively ignoring CI, no testing required."
circleci step halt
fi


early_return_for_forked_pull_requests:
description: >-
If this build is from a fork, stop executing the current job and return success.
This is useful to avoid steps that will fail due to missing credentials.
steps:
- run:
name: Early return if this build is from a forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi

build_and_test:
steps:
- abort_for_docs
- abort_for_noci
- checkout

# Download and cache dependencies
- restore_cache:
- restore_cache: # Download and cache dependencies
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
- v1-dependencies-{{ checksum "pyproject.toml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install tox dependencies
command: |
pip install --user --quiet -r .circleci/circle_requirements.txt

- run:
name: install dependencies
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pip install codecov
poetry install

- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
- run:
name: build sdist and wheels
command: |
poetry build

- run:
name: test dist
command: python setup.py sdist
name: lint
command: |
tox -e linters

- run:
name: run tests
command: |
. venv/bin/activate
coverage run --source=rejson setup.py test
codecov

# - store_artifacts:
# path: test-reports
# destination: test-reports

command:
tox -e cover

- save_cache:
paths:
- ./.tox
- ~/.cache/pip
key: v1-dependencies-{{ checksum "pyproject.toml" }}

jobs:
build:
parameters:
python_version:
type: string
default: "latest"
docker:
- image: circleci/python:<<parameters.python_version>>
- image: redislabs/rejson:edge
steps:
- build_and_test

on-any-branch: &on-any-branch
filters:
branches:
only:
- /.*/
tags:
ignore: /.*/

on-master: &on-master
filters:
branches:
only:
- master

# the is to build and test, per commit against all supported python versions
python-versions: &python-versions
matrix:
parameters:
python_version:
- "3.6.9"
- "3.7.9"
- "3.8.9"
- "3.9.4"
- "latest"

workflows:
version: 2
commit:
jobs:
- build
- build:
<<: *on-any-branch
<<: *python-versions

nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
<<: *on-master
jobs:
- build
- build
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
[![PyVersions](https://img.shields.io/pypi/pyversions/rejson.svg)](https://github.com/RedisJSON/redisjson-py)
[![GitHub issues](https://img.shields.io/github/release/RedisJSON/redisjson-py.svg)](https://github.com/RedisJSON/redisjson-py/releases/latest)
[![Codecov](https://coveralls.io/repos/github/RedisLabs/rejson-py/badge.svg?branch=master)](https://coveralls.io/github/RedisLabs/rejson-py?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/RedisJSON/redisjson-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RedisJSON/redisjson-py?targetFile=pyproject.toml)

# RedisJSON Python Client

[![Forum](https://img.shields.io/badge/Forum-RedisJSON-blue)](https://forum.redislabs.com/c/modules/redisjson)
[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/QUkjSsk)

rejson-py is a package that allows storing, updating and querying objects as
JSON documents in a [Redis](https://redis.io) database that is extended with the
[ReJSON module](https://github.com/redislabsmodules/rejson). The package extends
Expand All @@ -23,6 +24,17 @@ JSON.
$ pip install rejson
```

## Development

1. Create a virtualenv to manage your python dependencies, and ensure it's active.
```virtualenv -v venv```
2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.
```pip install --user poetry```
3. Install dependencies.
```poetry install```

[tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded.

## Usage example

```python
Expand Down
8 changes: 8 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from typing import Any, Dict
from rejson import __version__

def build(setup_kwargs: Dict[str, Any]) -> None:
setup_kwargs.update({
"zip_safe": False,
"version": __version__
})
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[tool.poetry]
name = "rejson"
version = "0.5.4"
description = "RedisJSON Python Client"
authors = ["RedisLabs <oss@redislabs.com>"]
license = "BSD-3-Clause"
readme = "README.md"
build = "build.py"

classifiers = [
'Topic :: Database',
'Programming Language :: Python',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Development Status :: 5 - Production/Stable'
]
keywords = ["Redis JSON Extension"]

[tool.poetry.dependencies]
python = "^3.6"
redis = "^3.5.3"
six = "^1.16.0"


[tool.poetry.urls]
url = "https://redisjson.io"
repository = "https://github.com/RedisJSON/redisjson-py"

[tool.poetry.dev-dependencies]
codecov = "^2.1.11"
flake8 = "^3.9.2"
tox = "^3.23.1"
tox-poetry = "^0.3.0"
bandit = "^1.7.0"
vulture = "^2.3"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

66 changes: 0 additions & 66 deletions setup.py

This file was deleted.

26 changes: 26 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tox]
skipsdist = True
envlist = linters

[flake8]
max-complexity = 10
ignore = E127,E265,E266,E301,E501
srcdir = rejson
show-source = true
exclude =.git,.tox,dist,doc,*/__pycache__/*,*test*.py

[testenv:cover]
whitelist_externals = find
commands_pre =
find . -type f -name "*.pyc" -delete
setenv =
REDIS_PORT = 6379
commands =
coverage run tests/test_rejson.py
codecov

[testenv:linters]
commands =
# flake8 --show-source
vulture rejson --min-confidence 80
bandit rejson/**