Skip to content

Commit 0bc32b4

Browse files
authored
Replace travis with github actions (#368)
* Replace travis with github actions * Fix flake8 issues
1 parent 4df6637 commit 0bc32b4

File tree

12 files changed

+63
-93
lines changed

12 files changed

+63
-93
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Running unittests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.6, 3.7, 3.8]
16+
django: ["2.2", "3.0", "3.1"]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements-tests.txt
28+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
- name: Linting
30+
run: flake8
31+
- name: Run unittests
32+
env:
33+
TOX_ENV: py${{ matrix.python-version}}-django${{ matrix.django }}
34+
run: |
35+
tox -e $TOX_ENV

.travis.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

dbbackup/management/commands/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ...storage import StorageError
1414

1515
if six.PY2:
16-
input = raw_input
16+
input = raw_input # noqa
1717
else:
1818
long = int
1919

dbbackup/management/commands/mediabackup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def backup_mediafiles(self):
9393
filename = utils.filename_generate(extension,
9494
servername=self.servername,
9595
content_type=self.content_type)
96-
96+
9797
tarball = self._create_tar(filename)
9898
# Apply trans
9999
if self.encrypt:

dbbackup/management/commands/mediarestore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"""
44
import tarfile
55

6-
from django.core.management.base import CommandError
76
from django.core.files.storage import get_storage_class
87

98
from ._base import BaseDbBackupCommand, make_option
10-
from ...storage import get_storage, StorageError
9+
from ...storage import get_storage
1110
from ... import utils
1211

1312

dbbackup/settings.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# DO NOT IMPORT THIS BEFORE django.configure() has been run!
22

3-
import logging.config
43
import tempfile
54
import socket
65
from django.conf import settings
7-
import dbbackup.log
86

97
DATABASES = getattr(settings, 'DBBACKUP_DATABASES', list(settings.DATABASES.keys()))
108

@@ -24,8 +22,8 @@
2422
MEDIA_PATH = getattr(settings, 'DBBACKUP_MEDIA_PATH', settings.MEDIA_ROOT)
2523

2624
DATE_FORMAT = getattr(settings, 'DBBACKUP_DATE_FORMAT', '%Y-%m-%d-%H%M%S')
27-
FILENAME_TEMPLATE = getattr(settings, 'DBBACKUP_FILENAME_TEMPLATE', '{databasename}-{servername}-{datetime}.{extension}')
28-
MEDIA_FILENAME_TEMPLATE = getattr(settings, 'DBBACKUP_MEDIA_FILENAME_TEMPLATE', '{servername}-{datetime}.{extension}')
25+
FILENAME_TEMPLATE = getattr(settings, 'DBBACKUP_FILENAME_TEMPLATE', '{databasename}-{servername}-{datetime}.{extension}') # noqa
26+
MEDIA_FILENAME_TEMPLATE = getattr(settings, 'DBBACKUP_MEDIA_FILENAME_TEMPLATE', '{servername}-{datetime}.{extension}') # noqa
2927

3028
GPG_ALWAYS_TRUST = getattr(settings, 'DBBACKUP_GPG_ALWAYS_TRUST', False)
3129
GPG_RECIPIENT = GPG_ALWAYS_TRUST = getattr(settings, 'DBBACKUP_GPG_RECIPIENT', None)

dbbackup/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ def filename_to_date(filename, datefmt=None):
377377
return datetime.strptime(datestring, datefmt)
378378

379379

380-
def filename_generate(extension, database_name='', servername=None, content_type='db', wildcard=None):
380+
def filename_generate(
381+
extension, database_name='', servername=None, content_type='db', wildcard=None
382+
):
381383
"""
382384
Create a new backup filename.
383385

requirements-tests.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
pep8
1+
coverage
2+
django-storages
23
flake8
4+
mock
5+
pep8
6+
psycopg2
37
pylint
4-
coverage
8+
python-dotenv
59
python-gnupg
6-
django-storages
710
pytz
811
testfixtures
9-
mock
10-
python-dotenv
11-
psycopg2
12+
tox-gh-actions
13+
tox

runtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ def main(argv=None):
2020
return result
2121
execute_from_command_line(argv)
2222

23+
2324
if __name__ == '__main__':
2425
sys.exit(bool(main(sys.argv)))

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[flake8]
2-
max-line-length = 99
3-
exclude = tests,settings
2+
max-line-length = 100
3+
include = dbbackup
4+
exclude = tests,settings,venv,docs

0 commit comments

Comments
 (0)