Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77ab577

Browse files
authored
tox, poetry, ci, first cut (#126)
1 parent 4e2be1e commit 77ab577

File tree

12 files changed

+225
-136
lines changed

12 files changed

+225
-136
lines changed

‎.circleci/circle_requirements.txt

Lines changed: 3 additions & 0 deletions
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

Lines changed: 120 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1-
# Python CircleCI 2.0 configuration file
2-
#
3-
# Check https://circleci.com/docs/2.0/language-python/ for more details
4-
#
51
version: 2.1
62
commands:
3+
4+
abort_for_docs:
5+
steps:
6+
- run:
7+
name: Avoid tests for docs
8+
command: |
9+
if [[ $CIRCLE_BRANCH == *docs ]]; then
10+
echo "Identifies as documents PR, no testing required"
11+
circleci step halt
12+
fi
13+
14+
abort_for_noci:
15+
steps:
16+
- run:
17+
name: Ignore CI for specific branches
18+
command: |
19+
if [[ $CIRCLE_BRANCH == *noci ]]; then
20+
echo "Identifies as actively ignoring CI, no testing required."
21+
circleci step halt
22+
fi
23+
24+
725
early_return_for_forked_pull_requests:
826
description: >-
927
If this build is from a fork, stop executing the current job and return success.
@@ -12,33 +30,44 @@ commands:
1230
- run:
1331
name: Early return if this build is from a forked PR
1432
command: |
15-
if [ -n "$CIRCLE_PR_NUMBER" ]; then
33+
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
1634
echo "Nothing to do for forked PRs, so marking this step successful"
1735
circleci step halt
1836
fi
19-
jobs:
20-
build:
21-
docker:
22-
- image: circleci/python:3.6.1
23-
24-
- image: redislabs/redisgraph:edge
25-
26-
working_directory: ~/repo
2737
38+
build_and_test:
2839
steps:
40+
- abort_for_docs
41+
- abort_for_noci
2942
- checkout
3043

44+
- restore_cache: # Download and cache dependencies
45+
keys:
46+
- v1-dependencies-{{ checksum "pyproject.toml" }}
47+
# fallback to using the latest cache if no exact match is found
48+
- v1-dependencies-
49+
3150
- run:
32-
name: Install tox
33-
command: sudo pip install tox
51+
name: install tox dependencies
52+
command: |
53+
pip install --user --quiet -r .circleci/circle_requirements.txt
54+
55+
- save_cache:
56+
paths:
57+
- ./.tox
58+
- ~/.cache/pip
59+
key: v1-dependencies-{{ checksum "pyproject.toml" }}
60+
3461

3562
- run:
36-
name: Test package build
37-
command: tox -e sdist
63+
name: build sdist and wheels
64+
command: |
65+
poetry build
3866
3967
- run:
40-
name: Run code styles
41-
command: tox -e pep8
68+
name: lint
69+
command: |
70+
tox -e linters
4271
4372
- run:
4473
name: Run unittest with coverage
@@ -49,27 +78,90 @@ jobs:
4978
command: tox -e func
5079

5180
- early_return_for_forked_pull_requests
52-
5381
- run:
54-
name: codecove
82+
name: codecov
5583
command: |
5684
. .tox/func/bin/activate
5785
codecov --file .tox/cover/report/coverage.xml --name ${CODECOV_NAME}-unittests
5886
codecov --file .tox/func/report/coverage.xml --name ${CODECOV_NAME}-functional
5987
88+
docker:
89+
parameters:
90+
docker_version:
91+
type: string
92+
default: "edge"
93+
steps:
94+
- setup_remote_docker
95+
- run:
96+
name: dockers
97+
description: Build and release docker
98+
command: |
99+
bash <(curl -fsSL https://get.docker.com)
100+
docker login -u redisfab -p $DOCKER_REDISFAB_PWD
101+
docker build -t redisgraph:<<parameters.docker_version>> .
102+
docker push
103+
104+
jobs:
105+
build:
106+
parameters:
107+
python_version:
108+
type: string
109+
docker:
110+
- image: circleci/python:<<parameters.python_version>>
111+
- image: redislabs/redisgraph:edge
112+
steps:
113+
- build_and_test
114+
115+
# since this is used by cron, we by default build against latest
116+
build_and_publish:
117+
parameters:
118+
docker_version:
119+
type: string
120+
default: "edge"
121+
docker:
122+
- image: circleci/python:latest
123+
- image: redislabs/redisgraph:edge
124+
125+
steps:
126+
- build_and_test
127+
- docker
128+
129+
on-any-branch: &on-any-branch
130+
filters:
131+
branches:
132+
only:
133+
- /.*/
134+
tags:
135+
ignore: /.*/
136+
137+
on-master: &on-master
138+
filters:
139+
branches:
140+
only:
141+
- master
142+
143+
# the is to build and test, per commit against all supported python versions
144+
python-versions: &python-versions
145+
matrix:
146+
parameters:
147+
python_version:
148+
- "3.6.9"
149+
- "3.7.9"
150+
- "3.8.9"
151+
- "3.9.4"
152+
- "latest"
60153

61154
workflows:
62-
version: 2
63155
commit:
64156
jobs:
65-
- build
157+
- build:
158+
<<: *on-any-branch
159+
<<: *python-versions
160+
66161
nightly:
67162
triggers:
68163
- schedule:
69164
cron: "0 0 * * *"
70-
filters:
71-
branches:
72-
only:
73-
- master
165+
<<: *on-master
74166
jobs:
75-
- build
167+
- build_and_publish

‎.github/workflows/publish-pypi.yml

Lines changed: 24 additions & 31 deletions
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/install-poetry-action@v1.3
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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM redislabs/redisgraph: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/redisgraph:edge as runner
12+
13+
RUN apt update && apt install -y python3 python3-pip
14+
RUN rm -rf /var/cache/apt/
15+
16+
COPY --from=builder /build/dist/redisgraph*.tar.gz /tmp/
17+
RUN pip3 install /tmp/redisgraph*.tar.gz

‎README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![PyPI version](https://badge.fury.io/py/redisgraph.svg)](https://badge.fury.io/py/redisgraph)
44
[![GitHub issues](https://img.shields.io/github/release/RedisGraph/redisgraph-py.svg)](https://github.com/RedisGraph/redisgraph-py/releases/latest)
55
[![Codecov](https://codecov.io/gh/RedisGraph/redisgraph-py/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisGraph/redisgraph-py)
6-
[![Known Vulnerabilities](https://snyk.io/test/github/RedisGraph/redisgraph-py/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/RedisGraph/redisgraph-py?targetFile=requirements.txt)
6+
[![Known Vulnerabilities](https://snyk.io/test/github/RedisGraph/redisgraph-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RedisGraph/redisgraph-py?targetFile=pyproject.toml)
77
[![Total alerts](https://img.shields.io/lgtm/alerts/g/RedisGraph/redisgraph-py.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RedisGraph/redisgraph-py/alerts/)
88

99
# redisgraph-py
@@ -91,7 +91,13 @@ pip install git+https://github.com/RedisGraph/redisgraph-py.git@master
9191

9292
### Install for development in env
9393

94-
```
95-
tox -e env
96-
source ./tox/env/bin/activate
97-
```
94+
1. Create a virtualenv to manage your python dependencies, and ensure it's active.
95+
```virtualenv -v venv; source venv/bin/activate```
96+
97+
2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.
98+
```pip install poetry```
99+
100+
3. Install dependencies.
101+
```poetry install```
102+
103+
[tox](https://tox.readthedocs.io/en/latest/) runs all code linters as its default target.

‎pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[tool.poetry]
2+
name = "redisgraph"
3+
version = "2.4.0"
4+
description = "RedisGraph Python Client"
5+
authors = ["RedisLabs <oss@redislabs.com>"]
6+
license = "BSD-3-Clause"
7+
readme = "README.md"
8+
keywords = ["Redis", "Graph"]
9+
classifiers=[
10+
'Topic :: Database',
11+
'Programming Language :: Python',
12+
'Intended Audience :: Developers',
13+
'Programming Language :: Python :: 3.6',
14+
'Programming Language :: Python :: 3.7',
15+
'Programming Language :: Python :: 3.8',
16+
'Programming Language :: Python :: 3.9',
17+
'License :: OSI Approved :: BSD License',
18+
'Development Status :: 5 - Production/Stable'
19+
]
20+
21+
[tool.poetry.urls]
22+
url = "https://redisgraph.io"
23+
repository = "https://github.com/RedisGraph/redisgraph-py"
24+
25+
[tool.poetry.dependencies]
26+
python = "^3.6"
27+
redis = "^3.5.3"
28+
prettytable = "^2.1.0"
29+
30+
[tool.poetry.dev-dependencies]
31+
tox = "^3.23.1"
32+
pytest = "^6.2.4"
33+
pytest-cov = "^2.12.0"
34+
pytest-html = "^3.1.1"
35+
testtools = "^2.4.0"
36+
mock = "^4.0.3"
37+
codecov = "^2.1.11"
38+
flake8 = "^3.9.2"
39+
tox-poetry = "^0.3.0"
40+
vulture = "^2.3"
41+
bandit = "^1.7.0"
42+
43+
[build-system]
44+
requires = ["poetry-core>=1.0.0"]
45+
build-backend = "poetry.core.masonry.api"

‎redisgraph/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def random_string(length=10):
88
"""
99
Returns a random N character long string.
1010
"""
11-
return ''.join(random.choice(string.ascii_lowercase) for x in range(length))
11+
return ''.join(random.choice(string.ascii_lowercase) for x in range(length))# nosec
1212

1313

1414
def quote_string(v):

‎requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /