Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: change Travis to use Docker #133

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 37 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,28 @@ 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" MYSQL_VERSION="5.7"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to avoid all the DOCKER_SERVICE and URIs.

- 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=postgresql REQUIREMENTS=lowest DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="11"
- EXTRAS=postgresql REQUIREMENTS=lowest DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="12"
- 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" MYSQL_VERSION="5.7"
- 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=postgresql REQUIREMENTS=release DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="11"
- EXTRAS=postgresql REQUIREMENTS=release DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="12"
- 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" MYSQL_VERSION="5.7"
- 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"
- EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="11"
- EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="12"

python:
- "3.6"
Expand All @@ -51,32 +48,42 @@ 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" MYSQL_VERSION="5.7"
- 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"
- env: EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="11"
- env: EXTRAS=postgresql REQUIREMENTS=devel DOCKER_SERVICE=postgresql SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://testuser:testpsw@localhost:5432/invenio" POSTGRESQL_VERSION="12"
- 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed: Which case triggers this if? I am not able to understand it.

docker-compose -f docker-services.yml up -d "${DOCKER_SERVICE}"; fi

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

after_script:
- docker-compose -f docker-services.yml down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be needed either. Should use docker-services-cli 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 -*-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be needed.

#
# 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:${MYSQL_VERSION}
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"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
'invenio-base>=1.2.2',
'Flask-Alembic>=2.0.1',
'Flask-SQLAlchemy>=2.1',
'SQLAlchemy>=1.1.0',
'SQLAlchemy>=1.2.18',
'SQLAlchemy-Utils>=0.33.1,<0.36',
]

Expand Down