Skip to content

Commit 42b1cc2

Browse files
pfouquejpic
authored andcommitted
Add github action
1 parent b331fbf commit 42b1cc2

File tree

5 files changed

+108
-87
lines changed

5 files changed

+108
-87
lines changed

.github/workflows/django.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version:
17+
- '3.8'
18+
- '3.9'
19+
- '3.10'
20+
- '3.11'
21+
- '3.12'
22+
services:
23+
postgres:
24+
image: postgres:14-alpine
25+
env:
26+
POSTGRES_USER: postgres
27+
POSTGRES_DB: postgres
28+
POSTGRES_PASSWORD: dbdiff
29+
ports:
30+
- 5432:5432
31+
options: >-
32+
--health-cmd pg_isready
33+
--health-interval 10s
34+
--health-timeout 5s
35+
--health-retries 5
36+
mysql:
37+
image: mysql:latest
38+
ports:
39+
- 3306:3306
40+
env:
41+
MYSQL_ROOT_PASSWORD: dbdiff
42+
steps:
43+
- uses: actions/checkout@v1
44+
- name: Set up Python ${{ matrix.python-version }}
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
- name: Install dependencies
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install tox tox-gh-actions codecov
52+
- name: Test with tox
53+
run: tox -v
54+
env:
55+
DB_HOST: 127.0.0.1
56+
DB_PASSWORD: dbdiff
57+
PGPASSWORD: dbdiff
58+
- name: Codecov
59+
run: codecov

.travis.yml

-76
This file was deleted.
+14-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
from .settings import * # noqa
22

3+
import os
4+
35
DATABASES = {
46
'default': {
57
'ENGINE': 'django.db.backends.mysql',
6-
'NAME': 'dbdiff_test',
7-
'USER': 'root',
8+
'HOST': os.environ.get('DB_HOST', ''),
9+
'NAME': os.environ.get('DB_NAME', 'dbdiff_test'),
10+
'USER': os.environ.get('DB_USER', 'root'),
11+
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
12+
'PORT': os.environ.get('DB_PORT', ''),
13+
'OPTIONS': {
14+
'charset': 'utf8mb4',
15+
},
16+
'TEST':{
17+
'CHARSET': 'utf8mb4',
18+
'COLLATION': 'utf8mb4_unicode_ci',
19+
}
820
}
921
}
+9-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
from .settings import * # noqa
22

3+
import os
4+
35
DATABASES = {
46
'default': {
57
'ENGINE': 'django.db.backends.postgresql_psycopg2',
6-
'NAME': 'dbdiff_test',
7-
'USER': 'postgres',
8+
'HOST': os.environ.get('DB_HOST', ''),
9+
'NAME': os.environ.get('DB_NAME', 'dbdiff_test'),
10+
'USER': os.environ.get('DB_USER', 'postgres'),
11+
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
12+
'PORT': os.environ.get('DB_PORT', '5432'),
13+
'OPTIONS': {},
14+
815
}
916
}

tox.ini

+26-7
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@ envlist =
55
py{38,39,310,311}-django41-{sqlite,mysql,postgresql}
66
py{38,39,310}-django40-{sqlite,mysql,postgresql}
77
py{38,39,310}-django32-{sqlite,mysql,postgresql}
8+
qa
9+
skip_missing_interpreters = True
10+
sitepackages = False
11+
12+
[gh-actions]
13+
python =
14+
3.8: py38, docs, checkqa, pylint, mypy
15+
3.9: py39
16+
3.10: py310
17+
3.11: py311
18+
3.12: py312
819

920
[testenv]
1021
usedevelop = true
1122
commands =
12-
mysql: mysql -u root -e 'drop database if exists test_dbdiff_test;'
13-
postgresql: psql -U postgres -c 'drop database if exists test_dbdiff_test;'
14-
py.test -vv --cov dbdiff --create-db --strict -r fEsxXw {posargs:dbdiff}
15-
whitelist_externals =
23+
mysql: mysql -u root -h {env:DB_HOST} --password={env:DB_PASSWORD} --protocol tcp -e 'drop database if exists test_dbdiff_test;'
24+
postgresql: psql -U postgres -h {env:DB_HOST} -c 'drop database if exists test_dbdiff_test;'
25+
pytest -vv --cov dbdiff --create-db --strict -r fEsxXw {posargs:dbdiff}
26+
allowlist_externals =
1627
mysql
1728
psql
1829
deps =
@@ -21,25 +32,33 @@ deps =
2132
pytest-cov
2233
mock
2334
coverage
24-
django50: Django==5.0a1
35+
django50: Django==5.0b1
2536
django42: Django>=4.2,<5.0
2637
django41: Django>=4.1,<4.2
2738
django40: Django>=4.0,<4.1
2839
django32: Django>=3.2,<4.0
29-
postgresql: psycopg2
40+
postgresql: psycopg2-binary==2.9.9
3041
mysql: mysqlclient
3142
setenv =
3243
PIP_ALLOW_EXTERNAL=true
3344
DJANGO_SETTINGS_MODULE=dbdiff.tests.project.settings
3445
sqlite: DJANGO_SETTINGS_MODULE=dbdiff.tests.project.settings_sqlite
3546
postgresql: DJANGO_SETTINGS_MODULE=dbdiff.tests.project.settings_postgresql
47+
postgresql: DB_NAME=dbdiff_test
48+
postgresql: DB_ENGINE=postgresql_psycopg2
49+
postgresql: DB_USER=postgres
3650
mysql: DJANGO_SETTINGS_MODULE=dbdiff.tests.project.settings_mysql
51+
mysql: DB_NAME=dbdiff_test
52+
mysql: DB_ENGINE=mysql
53+
mysql: DB_USER=root
3754
passenv =
3855
TEST_*
3956
DBDIFF_*
57+
DB_*
58+
PGPASSWORD
4059

4160
[testenv:qa]
42-
basepython = python2.7
61+
basepython = python3.8
4362
commands =
4463
flake8 --show-source --exclude tests --max-complexity=7 --ignore=D203 dbdiff
4564
flake8 --show-source --exclude migrations --max-complexity=3 --ignore=D100,D101,D102,D103 dbdiff/tests

0 commit comments

Comments
 (0)