Skip to content

Commit efa6e56

Browse files
authored
initial (#126)
1 parent 17877ce commit efa6e56

File tree

10 files changed

+219
-184
lines changed

10 files changed

+219
-184
lines changed

.circleci/circle_requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
poetry>=1.1.6
2+
tox>=3.23.1
3+
tox-poetry>=0.3.0

.circleci/config.yml

+82-115
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,99 @@
11
version: 2.1
22

33
commands:
4-
test-steps:
5-
parameters:
6-
python_ver:
7-
type: string
8-
default: "3"
9-
redisearch_ver:
10-
type: string
11-
default: edge
12-
coverage:
13-
type: boolean
14-
default: true
15-
steps:
4+
5+
abort_for_docs:
6+
steps:
7+
- run:
8+
name: Avoid tests for docs
9+
command: |
10+
if [[ $CIRCLE_BRANCH == *docs ]]; then
11+
echo "Identifies as documents PR, no testing required"
12+
circleci step halt
13+
fi
14+
15+
abort_for_noci:
16+
steps:
17+
- run:
18+
name: Ignore CI for specific branches
19+
command: |
20+
if [[ $CIRCLE_BRANCH == *noci ]]; then
21+
echo "Identifies as actively ignoring CI, no testing required."
22+
circleci step halt
23+
fi
24+
25+
26+
early_return_for_forked_pull_requests:
27+
description: >-
28+
If this build is from a fork, stop executing the current job and return success.
29+
This is useful to avoid steps that will fail due to missing credentials.
30+
steps:
31+
- run:
32+
name: Early return if this build is from a forked PR
33+
command: |
34+
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
35+
echo "Nothing to do for forked PRs, so marking this step successful"
36+
circleci step halt
37+
fi
38+
39+
build_and_test:
40+
steps:
41+
- abort_for_docs
42+
- abort_for_noci
1643
- checkout
1744

1845
- restore_cache: # Download and cache dependencies
1946
keys:
20-
- v1-dependencies-{{ checksum "requirements.txt" }}
47+
- v1-dependencies-{{ checksum "pyproject.toml" }}
2148
# fallback to using the latest cache if no exact match is found
2249
- v1-dependencies-
2350

51+
- run:
52+
name: install tox dependencies
53+
command: |
54+
pip install --user --quiet -r .circleci/circle_requirements.txt
55+
2456
- run:
2557
name: install dependencies
2658
command: |
27-
virtualenv venv
28-
. venv/bin/activate
29-
python --version
30-
pip install -r requirements.txt
31-
pip install --force-reinstall git+https://github.com/RedisLabs/rmtest.git
32-
<<# parameters.coverage >> pip install codecov <</ parameters.coverage >>
33-
python - \<<'__'
34-
import redis
35-
r = redis.Redis(decode_responses=True)
36-
print(r.execute_command('info server'))
37-
print(r.execute_command('info modules'))
38-
__
39-
40-
- save_cache:
41-
paths:
42-
- ./venv
43-
key: v1-dependencies-{{ checksum "requirements.txt" }}
59+
poetry install
4460
4561
- run:
46-
name: test dist
47-
command: python setup.py sdist
62+
name: build sdist and wheels
63+
command: |
64+
poetry build
4865
4966
- run:
50-
name: run tests
67+
name: lint
5168
command: |
52-
. venv/bin/activate
53-
<<# parameters.coverage >> COV=1 <</ parameters.coverage >>
54-
if [[ $COV == 1 ]]; then
55-
REDIS_PORT=6379 coverage run test/test.py
56-
REDIS_PORT=6379 coverage run -a test/test_builder.py
57-
codecov
58-
else
59-
REDIS_PORT=6379 python test/test.py
60-
REDIS_PORT=6379 python test/test_builder.py
61-
fi
69+
tox -e linters
70+
71+
- run:
72+
name: run tests
73+
command:
74+
tox -e cover
75+
76+
- save_cache:
77+
paths:
78+
- ./.tox
79+
- ~/.cache/pip
80+
key: v1-dependencies-{{ checksum "pyproject.toml" }}
6281

6382
- store_artifacts:
6483
path: test-reports
6584
destination: test-reports
6685

67-
6886
jobs:
69-
test:
87+
build:
7088
parameters:
71-
python_ver:
72-
type: string
73-
default: "3"
74-
redisearch_ver:
89+
python_version:
7590
type: string
76-
default: edge
77-
coverage:
78-
type: boolean
79-
default: true
91+
default: latest
8092
docker:
81-
- image: circleci/python:<<parameters.python_ver >>
82-
- image: redislabs/redisearch:<<parameters.redisearch_ver >>
93+
- image: circleci/python:<<parameters.python_version >>
94+
- image: redislabs/redisearch:edge
8395
steps:
84-
- test-steps:
85-
python_ver: <<parameters.python_ver>>
86-
redisearch_ver: <<parameters.redisearch_ver>>
87-
coverage: <<parameters.coverage>>
88-
- store_artifacts:
89-
path: test-reports
90-
destination: test-reports
91-
92-
working_directory: ~/repo
93-
96+
- build_and_test
9497

9598
on-any-branch: &on-any-branch
9699
filters:
@@ -99,71 +102,35 @@ on-any-branch: &on-any-branch
99102
tags:
100103
only: /.*/
101104

102-
never: &never
103-
filters:
104-
branches:
105-
ignore: /.*/
106-
tags:
107-
ignore: /.*/
108-
109105
on-master: &on-master
110-
filters:
111-
branches:
112-
only: master
113-
114-
on-version-tags: &on-version-tags
115-
filters:
116-
branches:
117-
ignore: /.*/
118-
tags:
119-
only: /^v[0-9].*/
120-
121-
on-master-and-version-tags: &on-master-and-version-tags
122106
filters:
123107
branches:
124108
only:
125109
- master
126-
tags:
127-
only: /^v[0-9].*/
128110

111+
# the is to build and test, per commit against all supported python versions
112+
python-versions: &python-versions
113+
matrix:
114+
parameters:
115+
python_version:
116+
- "3.6.9"
117+
- "3.7.9"
118+
- "3.8.9"
119+
- "3.9.4"
120+
- "latest"
129121

130122
workflows:
131123
version: 2
132124
commit:
133125
jobs:
134-
- test:
135-
name: build
136-
python_ver: "3"
137-
redisearch_ver: edge
138-
coverage: yes
139-
<<: *on-any-branch
140-
- test:
141-
name: test_py2_latest
142-
python_ver: "2.7"
143-
redisearch_ver: edge
144-
coverage: yes
145-
<<: *on-any-branch
146-
- test:
147-
name: test_py3_search1.6
148-
python_ver: "3"
149-
redisearch_ver: "1.6.14"
150-
coverage: yes
151-
<<: *on-any-branch
152-
- test:
153-
name: test_py2_search1.6
154-
python_ver: "2.7"
155-
redisearch_ver: "1.6.14"
156-
coverage: yes
157-
<<: *on-any-branch
126+
- build:
127+
<<: *on-any-branch
128+
<<: *python-versions
158129

159130
nightly:
160131
triggers:
161132
- schedule:
162133
cron: "0 0 * * *"
163134
<<: *on-master
164135
jobs:
165-
- test:
166-
name: test-nightly
167-
python_ver: "3"
168-
redisearch_ver: edge
169-
coverage: no
136+
- build

.github/workflows/publish-pypi.yml

+24-31
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,43 @@
11
name: Publish Pypi
22
on:
33
release:
4-
types: [published]
4+
types: [ published ]
55

66
jobs:
7-
publish:
8-
name: publish
7+
pytest:
8+
name: Publish to PyPi
99
runs-on: ubuntu-latest
10+
env:
11+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1012
steps:
1113
- uses: actions/checkout@master
12-
- name: Set up Python 2.7
14+
- name: Set up Python 3.7
1315
uses: actions/setup-python@v1
1416
with:
15-
python-version: 2.7
17+
python-version: 3.7
1618

17-
- name: Install twine
18-
run: |
19-
pip install twine
20-
21-
- name: Install wheel
22-
run: |
23-
pip install wheel
24-
25-
- name: Create a source distribution
26-
run: |
27-
python setup.py sdist
19+
- name: Install Poetry
20+
uses: dschep/[email protected]
2821

29-
- name: Create a wheel
30-
run: |
31-
python setup.py bdist_wheel
22+
- name: Cache Poetry virtualenv
23+
uses: actions/cache@v1
24+
id: cache
25+
with:
26+
path: ~/.virtualenvs
27+
key: poetry-${{ hashFiles('**/poetry.lock') }}
28+
restore-keys: |
29+
poetry-${{ hashFiles('**/poetry.lock') }}
3230
33-
- name: Create a .pypirc
31+
- name: Set Poetry config
3432
run: |
35-
echo -e "[pypi]" >> ~/.pypirc
36-
echo -e "username = __token__" >> ~/.pypirc
37-
echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
38-
echo -e "[testpypi]" >> ~/.pypirc
39-
echo -e "username = __token__" >> ~/.pypirc
40-
echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc
33+
poetry config virtualenvs.in-project false
34+
poetry config virtualenvs.path ~/.virtualenvs
4135
42-
- name: Publish to Test PyPI
43-
if: github.event_name == 'release'
44-
run: |
45-
twine upload --skip-existing -r testpypi dist/*
36+
- name: Install Dependencies
37+
run: poetry install
38+
if: steps.cache.outputs.cache-hit != 'true'
4639

4740
- name: Publish to PyPI
4841
if: github.event_name == 'release'
4942
run: |
50-
twine upload -r pypi dist/*
43+
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build

Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM redislabs/redisearch:edge as builder
2+
3+
RUN apt update && apt install -y python3 python3-pip
4+
ADD . /build
5+
WORKDIR /build
6+
RUN pip3 install poetry
7+
RUN poetry config virtualenvs.create false
8+
RUN poetry build
9+
10+
### clean docker stage
11+
FROM redislabs/redisearch:edge as runner
12+
13+
RUN apt update && apt install -y python3 python3-pip git
14+
RUN rm -rf /var/cache/apt/
15+
16+
COPY --from=builder /build/dist/redisearch*.tar.gz /tmp/
17+
RUN pip3 install /tmp/redisearch*.tar.gz

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![CircleCI](https://circleci.com/gh/RediSearch/redisearch-py/tree/master.svg?style=svg)](https://circleci.com/gh/RediSearch/redisearch-py/tree/master)
44
[![GitHub issues](https://img.shields.io/github/release/RediSearch/redisearch-py.svg)](https://github.com/RediSearch/redisearch-py/releases/latest)
55
[![Codecov](https://codecov.io/gh/RediSearch/redisearch-py/branch/master/graph/badge.svg)](https://codecov.io/gh/RediSearch/redisearch-py)
6-
[![Known Vulnerabilities](https://snyk.io/test/github/RediSearch/redisearch-py/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/RediSearch/redisearch-py?targetFile=requirements.txt)
6+
[![Known Vulnerabilities](https://snyk.io/test/github/RediSearch/redisearch-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RediSearch/redisearch-py?targetFile=pyproject.toml)
77
[![Total alerts](https://img.shields.io/lgtm/alerts/g/RediSearch/redisearch-py.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RediSearch/redisearch-py/alerts/)
88

99
# RediSearch Python Client
@@ -394,6 +394,15 @@ req = AggregateRequest('*').group_by(
394394
$ pip install redisearch
395395
```
396396

397+
## Developing
398+
399+
1. Create a virtualenv to manage your python dependencies, and ensure it's active.
400+
```virtualenv -v venv```
401+
2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.
402+
```pip install --user poetry```
403+
3. Install dependencies.
404+
```poetry install```
405+
397406
## Testing
398407

399408
Testing can easily be performed using using Docker.

0 commit comments

Comments
 (0)