diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..fa8910e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint + +on: + - push + - pull_request + +jobs: + test: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade tox setuptools + + - name: Run linting + run: tox -e lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..411d451 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,58 @@ +name: Test + +on: + - push + - pull_request + +jobs: + tests: + name: ${{ matrix.name }} + runs-on: ubuntu-latest + services: + postgres: + image: postgres:12 + env: + POSTGRES_DB: sqlalchemy_searchable_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + strategy: + fail-fast: false + matrix: + include: + - name: "Python 3.9" + python: "3.9" + + - name: "Python 3.8" + python: "3.8" + + - name: "Python 3.7" + python: "3.7" + + - name: "PyPy" + python: "pypy3.9" + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade tox setuptools + + - name: Run tests + env: + SQLALCHEMY_SEARCHABLE_TEST_PASSWORD: postgres + TOXENV: py-sqla1.3, py-sqla1.4 + run: tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b622eb5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -sudo: required -dist: xenial - -before_install: - - wget -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - - - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs 2>/dev/null)-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' - - sudo apt-get update - - sudo /etc/init.d/postgresql stop - - sudo apt-get install postgresql-12 postgresql-client-12 - - sudo /etc/init.d/postgresql stop - - sudo cp /etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo /etc/init.d/postgresql start 12 - -before_script: - - psql -c 'create database sqlalchemy_searchable_test;' -U postgres - -language: python -env: - - TOXENV=py-sqla{1.3,1.4} -matrix: - include: - - python: 3.6 - - python: 3.7 - - python: 3.8 - - python: 3.9 - - python: pypy3 - - python: 3.7 - env: TOXENV=lint -install: - - pip install tox -script: - - tox diff --git a/README.rst b/README.rst index d99fe49..de456bb 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ SQLAlchemy-Searchable ===================== -|Build Status| |Version Status| |Downloads| +|Version Status| |Downloads| Fulltext searchable models for SQLAlchemy. Only supports PostgreSQL @@ -14,8 +14,6 @@ Resources - `Code `_ -.. |Build Status| image:: https://travis-ci.org/kvesteri/sqlalchemy-searchable.png?branch=master - :target: https://travis-ci.org/kvesteri/sqlalchemy-searchable .. |Version Status| image:: https://img.shields.io/pypi/v/SQLAlchemy-Searchable.svg :target: https://pypi.python.org/pypi/SQLAlchemy-Searchable/ .. |Downloads| image:: https://img.shields.io/pypi/dm/SQLAlchemy-Searchable.svg diff --git a/tests/__init__.py b/tests/__init__.py index 578b6a9..e8ad911 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import inspect import itertools as it +import os import sqlalchemy as sa from sqlalchemy import create_engine @@ -18,10 +19,15 @@ vectorizer ) -CONNECTION_STRING = ( - 'postgresql://postgres@localhost/sqlalchemy_searchable_test' +DB_USER = os.environ.get('SQLALCHEMY_SEARCHABLE_TEST_USER', 'postgres') +DB_PASSWORD = os.environ.get('SQLALCHEMY_SEARCHABLE_TEST_PASSWORD', '') +DB_NAME = os.environ.get( + 'SQLALCHEMY_SEARCHABLE_TEST_DB', + 'sqlalchemy_searchable_test' ) +CONNECTION_STRING = f'postgresql://{DB_USER}:{DB_PASSWORD}@localhost/{DB_NAME}' + try: import __pypy__ except ImportError: diff --git a/tests/test_multiple_vectors_per_class.py b/tests/test_multiple_vectors_per_class.py index 88f0c05..6410682 100644 --- a/tests/test_multiple_vectors_per_class.py +++ b/tests/test_multiple_vectors_per_class.py @@ -27,7 +27,9 @@ class TextItem(self.Base): name_vector = sa.Column(TSVectorType('name', auto_index=True)) - content_vector = sa.Column(TSVectorType('content', auto_index=True)) + content_vector = sa.Column( + TSVectorType('content', auto_index=True) + ) class TestMultipleSearchVectorsSearchFunction(TestCase): @@ -42,7 +44,9 @@ class TextMultiItem(self.Base): name = sa.Column(sa.Unicode(255)) content = sa.Column(sa.UnicodeText) name_vector = sa.Column(TSVectorType('name', auto_index=False)) - content_vector = sa.Column(TSVectorType('content', auto_index=False)) + content_vector = sa.Column( + TSVectorType('content', auto_index=False) + ) self.TextMultiItem = TextMultiItem diff --git a/tox.ini b/tox.ini index d5fa61b..720c607 100644 --- a/tox.ini +++ b/tox.ini @@ -7,8 +7,13 @@ deps= psycopg2cffi>=2.6.1; platform_python_implementation == 'PyPy' psycopg2>=2.4.6; platform_python_implementation == 'CPython' sqla1.3: SQLAlchemy>=1.3,<1.4 + sqla1.4: SQLAlchemy>=1.4,<1.5 lint: flake8 - lint: isort + lint: isort>=4.0,<5.0 +passenv = + SQLALCHEMY_SEARCHABLE_TEST_USER + SQLALCHEMY_SEARCHABLE_TEST_PASSWORD + SQLALCHEMY_SEARCHABLE_TEST_DB commands=py.test {posargs} [testenv:lint]