diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..4cfe7f6 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +branch = 1 +source = django_redshift_backend diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..694c31b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + linter: + - flake8 + - check + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + with: + python-version: 3.6 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U tox + + - run: tox -e ${{ matrix.linter }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2c50e0b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/django-redshift-backend' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U setuptools twine wheel + + - name: Build package + run: | + python setup.py --version + python setup.py sdist --format=gztar bdist_wheel + twine check dist/* + + - name: Upload packages to Jazzband + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: jazzband + password: ${{ secrets.JAZZBAND_RELEASE_KEY }} + repository_url: https://jazzband.co/projects/django-redshift-backend/upload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ea9b9fd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + django-version: ['2.2', '3.0', '3.1', 'dev'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Tox tests + run: | + tox -v + env: + DJANGO: ${{ matrix.django-version }} + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 00af728..6d8d3e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ dist/ .tox .pytest_cache/ doc/_build/ +.coverage +coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3bc2cc0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -dist: xenial -language: python -sudo: false -python: -- '2.7' -- '3.5' -- '3.6' -- '3.7' -cache: pip -env: - - DJANGO="2.0" - - DJANGO="2.1" - - DJANGO="1.11" -install: -- travis_retry pip install tox-travis -script: -- tox - -jobs: - exclude: - - env: DJANGO="2.0" - python: '2.7' - - env: DJANGO="2.1" - python: '2.7' - include: - - stage: deploy - install: skip - script: skip - python: 2.7 - env: skip - deploy: - provider: pypi - user: jazzband - server: https://jazzband.co/projects/django-redshift-backend/upload - distributions: sdist bdist_wheel - password: - secure: Ce8w7iTF3Cc/Tu8PPDUYtzFiSQIzjSjeFx+lPintaSJA7V/ndARWBvVLFSKghzayB5vPihDs934O0HbTsRAKHB4ChEzOiFH6u2utLkxPgqpKbmAbTRn12Xv46mwSNWV7XBnTOs8AzfqEI7y/fHDO6DT1j4FNGgyRqclH4GgsibU= - on: - tags: true - repo: jazzband/django-redshift-backend diff --git a/CHANGES.rst b/CHANGES.rst index 27a0f27..96996e3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,19 @@ CHANGES ======= +Unreleased +---------- + +* Drop Python 2.7 and 3.5 support. + +* Drop Django 1.11, 2.0 and 2.1 support. + +* Add Python 3.8 and 3.9 support. + +* Add Django 3.0 and 3.1 support. + +* Moved CI to GitHub Actions: https://github.com/jazzband/django-redshift-backend/actions + 1.1.0 (2019/08/02) ------------------ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 586702e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM python:3.6.1 - -RUN pip install -U setuptools pip - -COPY . /app -WORKDIR /app -VOLUME /app - -RUN pip install -U -r test-requires.txt tox - -CMD ["tox", "-e", "flake8,py{27,36}-django{18,19,110,111}"] - diff --git a/README.rst b/README.rst index d1fe61c..19ad6d1 100644 --- a/README.rst +++ b/README.rst @@ -26,9 +26,13 @@ This is a `Amazon Redshift`_ database backend for Django_. :alt: License :target: https://github.com/jazzband/django-redshift-backend/blob/master/LICENSE -.. image:: https://img.shields.io/travis/jazzband/django-redshift-backend/master.svg - :alt: Travis (.org) branch - :target: https://travis-ci.org/jazzband/django-redshift-backend +.. image:: https://github.com/jazzband/django-redshift-backend/workflows/Test/badge.svg + :target: https://github.com/jazzband/django-redshift-backend/actions + :alt: GitHub Actions + +.. image:: https://codecov.io/gh/jazzband/django-redshift-backend/branch/master/graph/badge.svg + :target: https://codecov.io/gh/jazzband/django-redshift-backend + :alt: Coverage .. image:: https://img.shields.io/github/stars/jazzband/django-redshift-backend.svg?style=social&label=Stars :alt: GitHub stars @@ -40,7 +44,7 @@ This is a `Amazon Redshift`_ database backend for Django_. Documentation ============= -- http://django-redshift-backend.rtfd.io/ +- https://django-redshift-backend.rtfd.io/ Django settings =============== diff --git a/checklist.rst b/checklist.rst index 6cc33b3..418fea2 100644 --- a/checklist.rst +++ b/checklist.rst @@ -2,10 +2,10 @@ Procedure: -1. check travis-ci testing result: https://travis-ci.org/jazzband/django-redshift-backend +1. check CI status testing result: https://github.com/jazzband/django-redshift-backend/actions?query=workflow%3ATest 2. update release version/date in ``CHANGES.rst`` -3. tagging with version name that MUST following semver. e.g.: ``git tag 1.0.1`` -4. ``git push --tags`` to invoke release process on travis-ci. +3. create Github release, tagging with version name that MUST following semver. e.g.: ``git tag 1.0.1`` +4. publish Github release to invoke release process in Github Actions. 5. approve release files. please check your email or https://jazzband.co/projects/django-redshift-backend 6. check PyPI page: https://pypi.org/p/django-redshift-backend 7. bump version in ``CHANGES.rst`` and commit/push them onto GitHub diff --git a/django_redshift_backend/base.py b/django_redshift_backend/base.py index 4a72fa5..c359f2a 100644 --- a/django_redshift_backend/base.py +++ b/django_redshift_backend/base.py @@ -13,7 +13,7 @@ from django.conf import settings from django.core.exceptions import FieldDoesNotExist from django.db.backends.base.validation import BaseDatabaseValidation -from django.db.backends.postgresql_psycopg2.base import ( +from django.db.backends.postgresql.base import ( DatabaseFeatures as BasePGDatabaseFeatures, DatabaseWrapper as BasePGDatabaseWrapper, DatabaseOperations as BasePGDatabaseOperations, @@ -22,6 +22,7 @@ DatabaseCreation as BasePGDatabaseCreation, DatabaseIntrospection, ) + from django.db.utils import NotSupportedError from django_redshift_backend.distkey import DistKey @@ -92,8 +93,9 @@ def distinct_sql(self, fields, *args): if fields: # https://github.com/jazzband/django-redshift-backend/issues/14 # Redshift doesn't support DISTINCT ON - raise NotSupportedError('DISTINCT ON fields is not supported ' - 'by this database backend') + raise NotSupportedError( + 'DISTINCT ON fields is not supported by this database backend' + ) return super(DatabaseOperations, self).distinct_sql(fields, *args) @@ -149,10 +151,10 @@ def create_model(self, model): # ## if 'definition' contains 'varchar', length must be 3 times # ## because Redshift requires bytes length for utf-8 chars. - m = re.match('varchar\((\d+?)\)', definition) + m = re.match(r'varchar\((\d+?)\)', definition) if m: definition = re.sub( - 'varchar\((\d+?)\)', + r"varchar\((\d+?)\)", "varchar({0})".format( str(int(m.group(1)) * self.multiply_varchar_length)), definition) @@ -448,8 +450,7 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type, "table": self.quote_name(new_rel.related_model._meta.db_table), "changes": fragment[0], }, - fragment[1], - ) + fragment[1]) for sql, params in other_actions: self.execute(sql, params) # Does it have a foreign key? diff --git a/doc/dev.rst b/doc/dev.rst index f5b8f4d..aba8166 100644 --- a/doc/dev.rst +++ b/doc/dev.rst @@ -38,9 +38,9 @@ tox have several sections for testing. CI (Continuous Integration) ---------------------------- -All tests will be run on Travis CI service. +All tests will be run on Github Actions: -* https://travis-ci.org/jazzband/django-redshift-backend +* https://github.com/jazzband/django-redshift-backend/actions?query=workflow%3ATest Pull Request diff --git a/doc/index.rst b/doc/index.rst index 6d311c4..aebcd36 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -26,9 +26,9 @@ This is a `Amazon Redshift`_ database backend for Django_. :alt: License :target: https://github.com/jazzband/django-redshift-backend/blob/master/LICENSE -.. image:: https://img.shields.io/travis/jazzband/django-redshift-backend/master.svg - :alt: Travis (.org) branch - :target: https://travis-ci.org/jazzband/django-redshift-backend +.. image:: https://img.shields.io/github/workflow/status/jazzband/django-redshift-backend/Test/master + :alt: Tests + :target: https://github.com/jazzband/django-redshift-backend/actions?query=workflow%3ATest .. image:: https://img.shields.io/github/stars/jazzband/django-redshift-backend.svg?style=social&label=Stars :alt: GitHub stars diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index e48b1d0..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: '2' -services: - build: - build: . - image: shimizukawa/test-django-redshift-backend - #volumes: - # - .:/doc \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 792785f..a79d9a2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,4 @@ universal = 1 [flake8] max-line-length=90 +ignore = W504 diff --git a/setup.py b/setup.py index 3bd68f8..4cc405e 100644 --- a/setup.py +++ b/setup.py @@ -23,26 +23,26 @@ def read(filename): author_email='shimizukawa@gmail.com', description='Redshift database backend for Django', long_description=read('README.rst') + read('CHANGES.rst'), + long_description_content_type='text/x-rst', install_requires=requires, extra_requires={ 'psycopg2-binary': ['psycopg2-binary'], 'psycopg2': ['psycopg2'], }, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + python_requires='>=3.6, <4', classifiers=[ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Framework :: Django', - 'Framework :: Django :: 1.11', - 'Framework :: Django :: 2.0', - 'Framework :: Django :: 2.1', + 'Framework :: Django :: 2.2', + 'Framework :: Django :: 3.0', + 'Framework :: Django :: 3.1', 'Intended Audience :: Developers', 'Environment :: Plugins', 'Topic :: Software Development :: Libraries :: Python Modules', diff --git a/test-requires.txt b/test-requires.txt deleted file mode 100644 index c91b866..0000000 --- a/test-requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -psycopg2-binary>=2.7 -pytest -mock>=2.0 diff --git a/tox.ini b/tox.ini index af3127e..92322f9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,45 +1,55 @@ [tox] envlist = - py{27,35,36}-dj111, - py{35,36,37}-dj20, - py{35,36,37}-dj21, - flake8, - isort, - readme + py{36,37,38,39}-dj{22,30,31,dev} + flake8 + check skipsdist = True -[travis] +[gh-actions] python = - 2.7: py27 - 3.5: py35 - 3.6: py36,flake8,readme + 3.6: py36, flake8, check 3.7: py37 + 3.8: py38 + 3.9: py39 -[travis:env] +[gh-actions:env] DJANGO = - 1.11: dj111 - 2.0: dj20 - 2.1: dj21 + 2.2: dj22 + 3.0: dj30 + 3.1: dj31 + dev: djdev [testenv] deps = - dj111: Django>=1.11,<1.12 - dj20: Django>=2.0,<2.1 - dj21: Django>=2.1,<2.2 - djmaster: https://github.com/django/django/archive/master.tar.gz - -rtest-requires.txt + coverage + psycopg2-binary>=2.7 + pytest + pytest-cov + mock>=2.0 + dj22: Django>=2.2,<2.3 + dj30: Django>=3.0,<3.1 + dj31: Django>=3.1,<3.2 + djdev: https://github.com/django/django/archive/master.tar.gz setenv = DJANGO_SETTINGS_MODULE = settings PYTHONPATH = {toxinidir} pip_pre = True -commands = py.test {posargs} +commands = + pytest -v --cov django_redshift_backend --cov-append --cov-report term-missing --cov-report=xml {posargs} +ignore_outcome = + djdev: True +ignore_errors = + djdev: True [testenv:flake8] basepython = python3 -deps = flake8>=3.5,<3.6 +deps = flake8 commands = flake8 django_redshift_backend tests -[testenv:readme] -basepython = python3 -deps = readme_renderer -commands = python setup.py check -r -s +[testenv:check] +deps = + twine + wheel +commands = + python setup.py sdist bdist_wheel + twine check dist/*