Skip to content

Commit

Permalink
Migrate to GitHub Actions (#72)
Browse files Browse the repository at this point in the history
* Move CI to Github Actions

* Move CI to Github Actions - take 2

* Fix flake8 error

* Add deployment step

* Tidy up

* Update trigger for CI workflow

* Simplify test matrix with tox-gh-actions

* Exclude unsuitable matrix combinations

* Add Python 3.5 back

* Update deployment steps to use Jazzband index

* Split CI workflow into test, lint and deploy

* Rename deploy workflow  to match Jazzband precendence.

* Remove unused Docker files.

* Fix URL.

* Update test workflow.

- Tracks test coverage.
- Drops support for  Python 2.7 and 3.5, new minimum Python is  3.6.
- Drops support for Django 1.11, 2.0 and 2.1.
- Adds support for Django  3.0 and 3.1.
- Fix flake8 run.

* Fix a few Django warnings.

* Update lint workflow.

* Fix badges and URLs.

* Update changelog.

Co-authored-by: Bruno Alla <[email protected]>
  • Loading branch information
jezdez and browniebroke authored Jan 3, 2021
1 parent 16143ee commit e24f3c2
Show file tree
Hide file tree
Showing 18 changed files with 205 additions and 113 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
branch = 1
source = django_redshift_backend
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 }}
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ dist/
.tox
.pytest_cache/
doc/_build/
.coverage
coverage.xml
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

12 changes: 8 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
===============
Expand Down
6 changes: 3 additions & 3 deletions checklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions django_redshift_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -22,6 +22,7 @@
DatabaseCreation as BasePGDatabaseCreation,
DatabaseIntrospection,
)

from django.db.utils import NotSupportedError

from django_redshift_backend.distkey import DistKey
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions doc/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions docker-compose.yaml

This file was deleted.

1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ universal = 1

[flake8]
max-line-length=90
ignore = W504
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ def read(filename):
author_email='[email protected]',
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',
Expand Down
3 changes: 0 additions & 3 deletions test-requires.txt

This file was deleted.

Loading

0 comments on commit e24f3c2

Please sign in to comment.