Skip to content

Commit

Permalink
Merge branch 'master' into feature/57-flexible-aggregagations
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Jul 30, 2022
2 parents 74a743e + 3ccbb50 commit 1329be8
Show file tree
Hide file tree
Showing 57 changed files with 1,372 additions and 256 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
@@ -0,0 +1 @@
service_name: github-actions
1 change: 0 additions & 1 deletion .coverals.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .env
@@ -0,0 +1,2 @@
GITHUB_TOKEN
COVERALLS_REPO_TOKEN
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,100 @@
name: test

on: [push, pull_request]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
es-version: ['6', '7']
include:
- python-version: '3.6'
tox_env: py36-elastic6
requirements: elastic_6x
- python-version: '3.6'
tox_env: py36-elastic7
requirements: elastic_7x

- python-version: '3.7'
tox_env: py37-elastic6
requirements: elastic_6x
- python-version: '3.7'
tox_env: py37-elastic7
requirements: elastic_7x

- python-version: '3.8'
tox_env: py38-elastic6
requirements: elastic_6x
- python-version: '3.8'
tox_env: py38-elastic7
requirements: elastic_7x

- python-version: '3.9'
tox_env: py39-elastic6
requirements: elastic_6x
- python-version: '3.9'
tox_env: py39-elastic7
requirements: elastic_7x

- python-version: '3.10'
tox_env: py310-elastic6
requirements: elastic_6x
- python-version: '3.10'
tox_env: py310-elastic7
requirements: elastic_7x

services:
elasticsearch:
image: bitnami/elasticsearch:${{ matrix.es-version }}
ports:
- 9200:9200
options: >-
-e="discovery.type=single-node"
--health-cmd="curl http://localhost:9200/_cluster/health"
--health-interval=10s
--health-timeout=5s
--health-retries=10
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install pip-tools
python -m pip install tox
pip-compile requirements/testing_${{ matrix.es-version }}x.in
python -m pip install -r requirements/testing_${{ matrix.es-version }}x.txt
- name: Run tests
uses: nick-invision/retry@v2
with:
command: python runtests.py
timeout_minutes: 15
max_attempts: 3
- name: Upload to Codecov
uses: codecov/codecov-action@v2
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: Run Tests

coveralls_finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
debug: True
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -15,6 +15,12 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.7.1
-----
2022-07-28

- Belated migration to GitHub Actions.

0.7
---
2021-03-08
Expand Down
20 changes: 0 additions & 20 deletions docker-compose-test.yml

This file was deleted.

6 changes: 6 additions & 0 deletions docker-compose.yml
Expand Up @@ -22,5 +22,11 @@ services:
- cluster.routing.allocation.disk.watermark.flood_stage=99%
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"

# backend:
# container_name: graphene_elastic_backend
# build:
# context: .
# dockerfile: ./docker/backend/Dockerfile

volumes:
esdata:
5 changes: 5 additions & 0 deletions docker/elasticsearch/Dockerfile_6x
@@ -0,0 +1,5 @@
FROM docker.elastic.co/elasticsearch/elasticsearch:6.8.23
ADD ./docker/elasticsearch/elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch
14 changes: 5 additions & 9 deletions docker/testing/Dockerfile
@@ -1,4 +1,4 @@
FROM python:3.6.8-slim-jessie
FROM python:3.9-slim-bullseye
ENV PYTHONUNBUFFERED 1

RUN apt-get update
Expand All @@ -10,14 +10,10 @@ RUN apt-get install -y nano

RUN pip3 install pip --upgrade
RUN pip3 install virtualenv
RUN pip3 install pip-tools

RUN mkdir /code
WORKDIR /code
ADD pytest.ini /code/pytest.ini
ADD runtests.py /code/runtests.py
ADD requirements.txt /code/requirements.txt
ADD requirements/ /code/requirements/
ADD scripts/ /code/scripts/
ADD docker/ /code/docker/
RUN pip3 install -r /code/requirements.txt
#COPY ./docker /code/docker/
COPY . /code/
#RUN pip-compile /code/requirements/testing_7x.in
#RUN pip3 install -r /code/requirements/testing_7x.txt
13 changes: 8 additions & 5 deletions docker/testing/entrypoint.sh
@@ -1,13 +1,16 @@
#!/bin/sh

# Pip install requirements.txt
echo "Installing requirements"
pip install -r requirements.txt
cd /code/

# Pip install requirements
echo "Testing Elasticsearch 7.x: Installing requirements"
pip-compile requirements/testing_7x.in
pip install -r requirements/testing_7x.txt

# Clean up
echo "Clean up"
echo "Testing Elasticsearch 7.x: Clean up"
./scripts/clean_up.sh

# Running tests
echo "Running tests"
echo "Testing Elasticsearch 7.x: Running tests"
./runtests.py
16 changes: 16 additions & 0 deletions docker/testing/entrypoint_6x.sh
@@ -0,0 +1,16 @@
#!/bin/sh

cd /code/

# Pip install requirements
echo "Testing Elasticsearch 6.x: Installing requirements"
pip-compile requirements/testing_6x.in
pip install -r requirements/testing_6x.txt

# Clean up
echo "Testing Elasticsearch 6.x: Clean up"
./scripts/clean_up.sh

# Running tests
echo "Testing Elasticsearch 6.x: Running tests"
./runtests.py
24 changes: 22 additions & 2 deletions examples/factories/blog_post.py
Expand Up @@ -10,6 +10,8 @@

__all__ = (
'Comment',
'CommentAuthor',
'CommentAuthorFactory',
'CommentFactory',
'PostFactory',
'ManyViewsPostFactory',
Expand All @@ -25,6 +27,13 @@ def to_dict(self):
return self.__dict__


class CommentAuthor(Serializable):
"""Comment Author model (we need one for factories)."""

def __init__(self, *args, **kwargs):
self.name = kwargs.get('name')
self.age = kwargs.get('age')

class Comment(Serializable):
"""Comment model (we need one for factories)."""

Expand All @@ -34,18 +43,24 @@ def __init__(self, *args, **kwargs):
self.content = kwargs.get('content')
self.created_at = kwargs.get('created_at')


class Tag(Serializable):
"""Tag model (we need one for factories)."""

def __init__(self, *args, **kwargs):
self.name = kwargs.get('name')


class CommentAuthorFactory(Factory):

name = Faker('name')
age = Faker('pyint', min_value=10, max_value=40)

class Meta:
model = CommentAuthor

class CommentFactory(Factory):
"""Comment factory."""

author = Faker('name')
tag = FuzzyChoice([
'Elastic',
'MongoDB',
Expand All @@ -57,6 +72,11 @@ class CommentFactory(Factory):
content = Faker('text')
created_at = Faker('date')

@factory.post_generation
def author(obj, create, extracted, **kwargs):
if create:
obj.author = CommentAuthorFactory.create()

class Meta(object):
model = Comment

Expand Down
26 changes: 26 additions & 0 deletions examples/schema/meta/post.py
Expand Up @@ -291,3 +291,29 @@ class AbstractPostDocumentMeta:

"i_do_not_exist": "i_do_not_exist",
}

search_nested_fields = {
"comments": {
"path": "comments",
"fields": [
"tag",
{
"content": {
"field": "content.raw",
"boost": 3
}
}
]
},
"author": {
"path": "comments.author",
"fields": [
{
"name": {
"field": "name.raw",
"boost": 2
}
}
]
}
}
2 changes: 2 additions & 0 deletions examples/schema/read_only_post.py
Expand Up @@ -12,6 +12,7 @@
DefaultOrderingFilterBackend,
HighlightFilterBackend,
SourceFilterBackend,
SearchFilterBackend
)

from search_index.documents import ReadOnlyPost as ReadOnlyPostDocument
Expand All @@ -36,6 +37,7 @@ class Meta(AbstractPostDocumentMeta):
HighlightFilterBackend,
SourceFilterBackend,
FacetedSearchFilterBackend,
SearchFilterBackend,
# CustomFilterBackend,
OrderingFilterBackend,
DefaultOrderingFilterBackend,
Expand Down

0 comments on commit 1329be8

Please sign in to comment.