diff --git a/.github/workflows/python-package.yaml b/.github/workflows/python-package.yaml new file mode 100644 index 0000000..5cbf4d9 --- /dev/null +++ b/.github/workflows/python-package.yaml @@ -0,0 +1,52 @@ +name: Lint and Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + lint-and-test: + + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.7, 3.8] + + container: + image: python:${{ matrix.python-version }} + + services: + cassandra: + image: cassandra:3 + ports: + - 9090:9090 + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install -r requirements-lint.txt + + - name: Lint + run: | + make lint + + - name: Test + run: | + nosetests diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml new file mode 100644 index 0000000..84ff9b6 --- /dev/null +++ b/.github/workflows/python-publish.yaml @@ -0,0 +1,32 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools==47.3.0 wheel==0.34.2 twine==3.1.1 + + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* + diff --git a/Dockerfile b/Dockerfile index 114182f..9bd6884 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.6 COPY ./requirements.txt ./requirements-dev.txt /src/ -RUN pip install --no-index --find-links https://reddit-wheels.s3.amazonaws.com/index.html -r /src/requirements-dev.txt +RUN pip install -r /src/requirements-dev.txt COPY . /src WORKDIR /src diff --git a/README.rst b/README.rst index 37b5287..5fe08c3 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ Major changes: as the `conn` argument to functions rather than using the `Model.batch` syntax of cqlengine -Example usage: -:: +Example usage:: + import uuid from cassandra.cluster import Cluster diff --git a/requirements-lint.txt b/requirements-lint.txt index f1d0e93..4f81043 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -11,15 +11,16 @@ flake8==3.7.7 flake8-docstrings==1.3.0 flake8-polyfill==1.0.2 isort==4.3.16 -lazy-object-proxy==1.3.1 -lxml==4.3.3 +lazy-object-proxy==1.5.2 +lxml==4.6.2 mccabe==0.6.1 -mypy==0.701 -mypy-extensions==0.4.1 +mypy==0.800 +mypy-extensions==0.4.3 pycodestyle==2.5.0 pydocstyle==3.0.0 pyflakes==2.1.1 pylint==2.3.1 reorder-python-imports==1.6.0 -typed-ast==1.4.0 +typed-ast==1.4.2 +typing-extensions==3.7.4.3 wrapt==1.11.1 diff --git a/requirements.txt b/requirements.txt index d0574b6..0024315 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -cassandra-driver==3.17.0 +cassandra-driver==3.24.0 six==1.12.0 diff --git a/tests/integration/columns/test_container_columns.py b/tests/integration/columns/test_container_columns.py index 83c0b5f..089f03a 100644 --- a/tests/integration/columns/test_container_columns.py +++ b/tests/integration/columns/test_container_columns.py @@ -20,9 +20,6 @@ from datetime import datetime from datetime import timedelta -from tests.integration import CASSANDRA_VERSION -from tests.integration import is_prepend_reversed -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 import six @@ -36,6 +33,9 @@ from cqlmapper.management import sync_table from cqlmapper.models import Model from cqlmapper.models import ValidationError +from tests.integration import CASSANDRA_VERSION +from tests.integration import is_prepend_reversed +from tests.integration.base import BaseCassEngTestCase log = logging.getLogger(__name__) diff --git a/tests/integration/columns/test_counter_column.py b/tests/integration/columns/test_counter_column.py index dcd61e5..213b1ee 100644 --- a/tests/integration/columns/test_counter_column.py +++ b/tests/integration/columns/test_counter_column.py @@ -13,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 from cqlmapper import columns @@ -21,6 +20,7 @@ from cqlmapper.management import sync_table from cqlmapper.models import Model from cqlmapper.models import ModelDefinitionException +from tests.integration.base import BaseCassEngTestCase class TestCounterModel(Model): diff --git a/tests/integration/management/test_compaction_settings.py b/tests/integration/management/test_compaction_settings.py index 47e4fc5..f74440a 100644 --- a/tests/integration/management/test_compaction_settings.py +++ b/tests/integration/management/test_compaction_settings.py @@ -15,7 +15,6 @@ # limitations under the License. import copy -from tests.integration.base import BaseCassEngTestCase from unittest.mock import patch import six @@ -26,6 +25,7 @@ from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration.base import BaseCassEngTestCase class LeveledCompactionTestTable(Model): diff --git a/tests/integration/model/test_class_construction.py b/tests/integration/model/test_class_construction.py index fad03d5..f6ff9a7 100644 --- a/tests/integration/model/test_class_construction.py +++ b/tests/integration/model/test_class_construction.py @@ -15,7 +15,6 @@ # limitations under the License. import warnings -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 from cqlmapper import columns @@ -25,6 +24,7 @@ from cqlmapper.models import ModelException from cqlmapper.query import DMLQuery from cqlmapper.query_set import ModelQuerySet +from tests.integration.base import BaseCassEngTestCase class TestModelClassFunction(BaseCassEngTestCase): diff --git a/tests/integration/model/test_equality_operations.py b/tests/integration/model/test_equality_operations.py index 7b5dfa3..0e7eea7 100644 --- a/tests/integration/model/test_equality_operations.py +++ b/tests/integration/model/test_equality_operations.py @@ -13,13 +13,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 from cqlmapper import columns from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration.base import BaseCassEngTestCase class TestModel(Model): diff --git a/tests/integration/model/test_updates.py b/tests/integration/model/test_updates.py index ba52000..6e336f1 100644 --- a/tests/integration/model/test_updates.py +++ b/tests/integration/model/test_updates.py @@ -13,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from tests.integration.base import BaseCassEngTestCase from unittest.mock import patch from uuid import uuid4 @@ -22,6 +21,7 @@ from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration.base import BaseCassEngTestCase class TestUpdateModel(Model): diff --git a/tests/integration/model/test_value_lists.py b/tests/integration/model/test_value_lists.py index b973bfe..63c62a8 100644 --- a/tests/integration/model/test_value_lists.py +++ b/tests/integration/model/test_value_lists.py @@ -15,12 +15,11 @@ # limitations under the License. import random -from tests.integration.base import BaseCassEngTestCase - from cqlmapper import columns from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration.base import BaseCassEngTestCase class TestModel(Model): diff --git a/tests/integration/query/test_datetime_queries.py b/tests/integration/query/test_datetime_queries.py index 7f49195..b68d364 100644 --- a/tests/integration/query/test_datetime_queries.py +++ b/tests/integration/query/test_datetime_queries.py @@ -15,8 +15,6 @@ # limitations under the License. from datetime import datetime from datetime import timedelta -from tests.integration import execute_count -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 from cqlmapper import columns @@ -24,6 +22,8 @@ from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration import execute_count +from tests.integration.base import BaseCassEngTestCase class DateTimeQueryTestModel(Model): diff --git a/tests/integration/query/test_queryoperators.py b/tests/integration/query/test_queryoperators.py index ef710de..caaf714 100644 --- a/tests/integration/query/test_queryoperators.py +++ b/tests/integration/query/test_queryoperators.py @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. from datetime import datetime -from tests.integration import execute_count -from tests.integration.base import BaseCassEngTestCase from cqlmapper import columns from cqlmapper import functions @@ -25,6 +23,8 @@ from cqlmapper.models import Model from cqlmapper.operators import EqualsOperator from cqlmapper.statements import WhereClause +from tests.integration import execute_count +from tests.integration.base import BaseCassEngTestCase class TestQuerySetOperation(BaseCassEngTestCase): diff --git a/tests/integration/query/test_updates.py b/tests/integration/query/test_updates.py index 8a26ba5..e458bdc 100644 --- a/tests/integration/query/test_updates.py +++ b/tests/integration/query/test_updates.py @@ -13,9 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from tests.integration import execute_count -from tests.integration import is_prepend_reversed -from tests.integration.base import BaseCassEngTestCase from uuid import uuid4 from cqlmapper import columns @@ -23,6 +20,9 @@ from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration import execute_count +from tests.integration import is_prepend_reversed +from tests.integration.base import BaseCassEngTestCase class TestQueryUpdateModel(Model): diff --git a/tests/integration/test_batch_query.py b/tests/integration/test_batch_query.py index 138fc66..6e6eef8 100644 --- a/tests/integration/test_batch_query.py +++ b/tests/integration/test_batch_query.py @@ -15,8 +15,6 @@ # limitations under the License. import warnings -from tests.integration import execute_count -from tests.integration.base import BaseCassEngTestCase from unittest import mock from cqlmapper import columns @@ -25,6 +23,8 @@ from cqlmapper.management import drop_table from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration import execute_count +from tests.integration.base import BaseCassEngTestCase class TestMultiKeyModel(Model): diff --git a/tests/integration/test_consistency.py b/tests/integration/test_consistency.py index defc362..bd597d2 100644 --- a/tests/integration/test_consistency.py +++ b/tests/integration/test_consistency.py @@ -13,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from tests.integration.base import BaseCassEngTestCase from unittest import mock from uuid import uuid4 @@ -28,6 +27,7 @@ from cqlmapper.management import sync_table from cqlmapper.models import Model from cqlmapper.query_set import ModelQuerySet +from tests.integration.base import BaseCassEngTestCase class TestConsistencyModel(Model): diff --git a/tests/integration/test_timestamp.py b/tests/integration/test_timestamp.py index 7bb2d8d..53cbead 100644 --- a/tests/integration/test_timestamp.py +++ b/tests/integration/test_timestamp.py @@ -17,8 +17,6 @@ from datetime import datetime from datetime import timedelta -from tests.integration.base import BaseCassEngTestCase -from tests.integration.base import main from unittest import mock from uuid import uuid4 @@ -26,6 +24,8 @@ from cqlmapper.batch import Batch from cqlmapper.management import sync_table from cqlmapper.models import Model +from tests.integration.base import BaseCassEngTestCase +from tests.integration.base import main class TestTimestampModel(Model):