Skip to content

Commit

Permalink
tests: change Travis to use Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco committed Sep 27, 2020
1 parent 1ba8741 commit adf9347
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 30 deletions.
59 changes: 29 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,22 @@ language: python
cache:
- pip

services:
- mysql
- postgresql

addons:
postgresql: "10"
apt:
packages:
- postgresql-10
- postgresql-client-10

env:
global:
- DOCKER_COMPOSE_VERSION=1.26.2
matrix:
- EXTRAS=sqlite REQUIREMENTS=lowest SQLALCHEMY_DATABASE_URI="sqlite:///test.db"
- EXTRAS=mysql REQUIREMENTS=lowest SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=lowest SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=lowest SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- EXTRAS=mysql REQUIREMENTS=lowest DOCKER_SERVICE=mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://testuser:testpsw@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=lowest DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=lowest DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- EXTRAS=sqlite REQUIREMENTS=release SQLALCHEMY_DATABASE_URI="sqlite:///test.db"
- EXTRAS=mysql REQUIREMENTS=release SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=release SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=release SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- EXTRAS=mysql REQUIREMENTS=release DOCKER_SERVICE=mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://testuser:testpsw@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=release DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=release DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- EXTRAS=sqlite REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="sqlite:///test.db"
- EXTRAS=mysql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- EXTRAS=mysql REQUIREMENTS=devel DOCKER_SERVICE=mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://testuser:testpsw@localhost:3306/invenio"
- EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="10"

python:
- "3.6"
Expand All @@ -51,32 +42,40 @@ matrix:
fast_finish: true
allow_failures:
- env: EXTRAS=sqlite REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="sqlite:///test.db"
- env: EXTRAS=mysql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="mysql+pymysql://travis@localhost:3306/invenio"
- env: EXTRAS=postgresql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- env: EXTRAS=postgresql REQUIREMENTS=devel SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- env: EXTRAS=mysql REQUIREMENTS=devel DOCKER_SERVICE=mysql SQLALCHEMY_DATABASE_URI="mysql+pymysql://testuser:testpsw@localhost:3306/invenio"
- env: EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="9.6"
- env: EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="10"
- python: 3.8

before_install:
# docker-compose setup
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
# Python
- "travis_retry pip install --upgrade pip setuptools py"
- "travis_retry pip install twine wheel coveralls requirements-builder"
- "requirements-builder -e docs,versioning,tests,$EXTRAS --level=min setup.py > .travis-lowest-requirements.txt"
- "requirements-builder -e docs,versioning,tests,$EXTRAS --level=pypi setup.py > .travis-release-requirements.txt"
- "requirements-builder -e docs,versioning,tests,$EXTRAS --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements.txt"
- "psql --version"
- if [$EXTRAS == "postgresql"]; then sudo systemctl stop postgresql; fi
- if [$EXTRAS == "postgresql"]; then travis_setup_postgresql $POSTGRESQL_VERSION; fi
- if [$EXTRAS == "postgresql"]; then sudo systemctl start postgresql@$POSTGRESQL_VERSION-main; fi
- "mysql -e 'CREATE DATABASE IF NOT EXISTS invenio;' -uroot"
- "psql -c 'CREATE DATABASE invenio;' -U postgres"

install:
- "travis_retry pip install -r .travis-${REQUIREMENTS}-requirements.txt"
- "travis_retry pip install -e .[docs,versioning,tests,$EXTRAS]"
- "psql --version"

before_script:
- "docker --version"
- "docker-compose --version"
- if [ -n "${DOCKER_SERVICE}" ]; then
docker-compose -f docker-services.yml up -d "${DOCKER_SERVICE}"; sleep 10; fi

script:
- "./run-tests.sh"

after_script:
- docker-compose -f docker-services.yml down

after_success:
- coveralls

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

include *.yml
include *.rst
include *.sh
include *.txt
Expand Down
28 changes: 28 additions & 0 deletions docker-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

version: "2.3"
services:
mysql:
image: mysql
restart: "always"
environment:
- "MYSQL_ROOT_PASSWORD=testrootpsw"
- "MYSQL_DATABASE=invenio"
- "MYSQL_USER=testuser"
- "MYSQL_PASSWORD=testpsw"
ports:
- "3306:3306"
postgresql:
image: postgres:${POSTGRESQL_VERSION}
restart: "always"
environment:
- "POSTGRES_USER=testuser"
- "POSTGRES_PASSWORD=testpsw"
- "POSTGRES_DB=invenio"
ports:
- "5432:5432"

0 comments on commit adf9347

Please sign in to comment.