]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
travis: test against postgresql 10 and 11
authorDaniel Black <daniel@linux.ibm.com>
Mon, 6 Aug 2018 06:56:37 +0000 (16:56 +1000)
committerDaniel Axtens <dja@axtens.net>
Tue, 21 Aug 2018 15:32:59 +0000 (01:32 +1000)
postgresql 10 is the most recent major version, and it would be
good to keep an eye on postgres 11 compatibility also, so test
against both of those.

Specify PGPORT as a way to differentiate the new installations
from the postgres 9.6 server running on the default port (5432).
Use a local unix socket to work around the fact that by default
postgres only allows passwordless auth on local sockets - which
is tweaked for postgres 9.6 but not for later versions that aren't
in the usual Travis image.

Also print the current db version and user for validation.

Signed-off-by: Daniel Black <daniel@linux.ibm.com>
[cleanup, squash, commit message]
Signed-off-by: Daniel Axtens <dja@axtens.net>
.travis.yml
patchwork/settings/dev.py

index 6cb983f3ffec0cd00b1df4eefdb7dd98c2ab71be..49915549869501ca54d1091e08d3d2c19cefd5b1 100644 (file)
@@ -22,15 +22,63 @@ env:
     - PW_TEST_DB_TYPE=mysql PW_TEST_DB_USER=root
   global:
     - PW_TEST_DB_PASS=""
+    - PW_TEST_DB_HOST="localhost"
+
+matrix:
+  include:
+    - addons:
+        postgresql: "10"
+        apt:
+          packages:
+          - postgresql-10
+          - postgresql-client-10
+      env:
+        - PGPORT=5433
+        - PW_TEST_DB_HOST=""
+        - PW_TEST_DB_PORT=5433
+        - PW_TEST_DB_TYPE=postgres
+        - PW_TEST_DB_USER=travis
+      python: 3.6
+      sudo: true
+      before_install:
+        - sudo -u postgres psql -c "grant ALL on DATABASE postgres to travis WITH GRANT OPTION;"
+    - env:
+        - PGPORT=5433
+        - PW_TEST_DB_HOST=""
+        - PW_TEST_DB_PORT=5433
+        - PW_TEST_DB_TYPE=postgres
+        - PW_TEST_DB_USER=travis
+      python: 3.6
+      dist: trusty
+      addons:
+        postgresql: "11"
+        apt:
+          sources:
+          - sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg 11'
+            key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
+          packages:
+          - postgresql-11
+          - postgresql-client-11
+      sudo: true
+      before_install:
+        - sudo -u postgres psql -c "grant ALL on DATABASE postgres to travis WITH GRANT OPTION;"
+
 
 before_script:
-  - mysql -e 'create database patchwork character set utf8;'
-  - psql -c "create database patchwork with ENCODING = 'UTF8';" -U postgres
+  - if [[ $PW_TEST_DB_TYPE == mysql ]]; then mysql -e 'create database patchwork character set utf8;'; fi
+  - if [[ $PW_TEST_DB_TYPE == postgres ]]; then psql -c "create database patchwork with ENCODING = 'UTF8';" -U $PW_TEST_DB_USER; fi
 
 install:
   - pip install tox-travis
 
 script:
+  - >
+    if [[ $PW_TEST_DB_TYPE == mysql ]];
+    then
+      mysql -e 'SELECT VERSION(), CURRENT_USER();' -u $PW_TEST_DB_USER patchwork;
+    else
+      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER patchwork;
+    fi
   - tox
   - tox -e coverage
 
index 7bdfdffac8e67b7eef15764632707422899b2218..0f79b61a390c4e4e760b00da7004dfd9836169a6 100644 (file)
@@ -41,6 +41,7 @@ DATABASES = {
 
 if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres':
     DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
+    DATABASES['default']['HOST'] = os.getenv('PW_TEST_DB_HOST', '')
 
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'