Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Python CI
on: [push, pull_request]
env:
PLANEMO_SKIP_REDUNDANT_TESTS: 1
PLANEMO_ENABLE_POSTGRES_TESTS: 1
PLANEMO_SKIP_GALAXY_CWL_TESTS: 1
PLANEMO_TEST_WORKFLOW_RUN_PROFILE: 1
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.7]
tox-action:
- lint
- lint_readme
- lint_docs
- quick
- unit
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: true
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox coveralls
- name: Test with tox
run: |
export TOXENV=$(echo $TOXENV | sed 's/\.//') && tox
env:
TOXENV: py${{ matrix.python-version }}-${{ matrix.tox-action }}

28 changes: 1 addition & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
language: python
env:
global:
- PLANEMO_SKIP_REDUNDANT_TESTS=1
- PLANEMO_ENABLE_POSTGRES_TESTS=1
- PLANEMO_SKIP_GALAXY_CWL_TESTS=1
- PLANEMO_TEST_WORKFLOW_RUN_PROFILE=travisworkflowtests
matrix:
include:
- python: 2.7
env: TOX_ENV=py27-lint
- python: 3.7
env: TOX_ENV=py37-lint_readme
- python: 3.7
env: TOX_ENV=py37-lint_docs
- python: 3.7
env: TOX_ENV=py37-lint_docstrings
- python: 3.7
env: TOX_ENV=py37-lint
- python: 3.7
env: TOX_ENV=py37-quick
- python: 2.7
env: TOX_ENV=py27-unit
- python: 3.7
env: TOX_ENV=py37-unit
allow_failures:
- env: TOX_ENV=py37-lint_docstrings

install:
- pip install tox coveralls
- pip install tox

script: tox -e $TOX_ENV

after_success:
- coveralls

services:
- postgresql
3 changes: 2 additions & 1 deletion planemo/commands/cmd_database_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@click.command('database_create')
@options.database_identifier_argument()
@options.database_source_options()
@options.profile_database_options()
@options.docker_config_options()
@command_function
def cli(ctx, identifier, **kwds):
"""Create a *development* database.
Expand Down
3 changes: 2 additions & 1 deletion planemo/commands/cmd_database_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

@click.command('database_delete')
@options.database_identifier_argument()
@options.database_source_options()
@options.profile_database_options()
@options.docker_config_options()
@command_function
def cli(ctx, identifier, **kwds):
"""Delete a *development* database.
Expand Down
3 changes: 2 additions & 1 deletion planemo/commands/cmd_database_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


@click.command('database_create')
@options.database_source_options()
@options.profile_database_options()
@options.docker_config_options()
@command_function
def cli(ctx, **kwds):
"""List databases in configured database source.
Expand Down
1 change: 1 addition & 0 deletions planemo/commands/cmd_profile_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@click.command('profile_delete')
@options.profile_name_argument()
@options.profile_database_options()
@options.docker_config_options()
@command_function
def cli(ctx, profile_name, **kwds):
"""Delete a profile."""
Expand Down
12 changes: 11 additions & 1 deletion planemo/database/postgres_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from galaxy.tools.deps import docker_util
from galaxy.tools.deps import dockerfiles
from galaxy.tools.deps.commands import execute
from galaxy.util import unicodify

from .interface import DatabaseSource
from .postgres import _CommandBuilder, ExecutesPostgresSqlMixin
Expand All @@ -23,7 +24,7 @@ def docker_exec(name, commands=[], **kwds):

def is_running_container(name=DEFAULT_CONTAINER_NAME, **kwds):
ps_command = docker_ps(["--format", "{{.Names}}"], **kwds)
running_containers = execute(ps_command)
running_containers = unicodify(execute(ps_command))
containers = running_containers.splitlines()
return name in containers

Expand All @@ -37,6 +38,15 @@ def start_postgres_docker(name=DEFAULT_CONTAINER_NAME, password=DEFAULT_POSTGRES
execute(run_command)


def stop_postgres_docker(name=DEFAULT_CONTAINER_NAME, **kwds):
stop_command = docker_util.command_list(
"stop",
[name],
**kwds
)
execute(stop_command)


class DockerPostgresDatabaseSource(ExecutesPostgresSqlMixin, DatabaseSource):
"""Postgres database running inside a Docker container."""

Expand Down
1 change: 1 addition & 0 deletions tests/test_cmd_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def test_serve_profile(self):

@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
@skip_unless_executable("psql")
def test_serve_postgres_profile(self):
self._test_serve_profile("--database_type", "postgres")

Expand Down
18 changes: 16 additions & 2 deletions tests/test_database_commands.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
from planemo.database.postgres_docker import stop_postgres_docker
from .test_utils import (
CliTestCase,
skip_unless_environ,
skip_unless_executable,
)


class DatabaseCommandsTestCase(CliTestCase):

@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
def test_database_commands(self):
def _database_commands(self, database_type="postgres"):
with self._isolate():
result = self._check_exit_code(["database_list"])
assert "test1234" not in result.output
self._check_exit_code(["database_create", "test1234"])
self._check_exit_code(["database_create", "test1234", "--database_type", database_type])
result = self._check_exit_code(["database_list"])
assert "test1234" in result.output
self._check_exit_code(["database_delete", "test1234"])
result = self._check_exit_code(["database_list"])
assert "test1234" not in result.output

@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
@skip_unless_executable("psql")
def test_database_commands(self):
self._database_commands()

@skip_unless_executable("docker")
def test_database_commands_docker(self):
try:
self._database_commands(database_type="postgres_docker")
finally:
stop_postgres_docker()
19 changes: 16 additions & 3 deletions tests/test_profile_commands.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
from planemo.database.postgres_docker import stop_postgres_docker
from .test_utils import (
CliTestCase,
skip_unless_environ,
skip_unless_executable
)


class ProfileCommandsTestCase(CliTestCase):

@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
def test_profile_commands(self):
def _profile_commands(self, database_type="postgresql"):
with self._isolate():
result = self._check_exit_code(["profile_list"])
assert "profile1234" not in result.output
self._check_exit_code(["profile_create", "profile1234"])
self._check_exit_code(["profile_create", "profile1234", "--database_type", database_type])
result = self._check_exit_code(["profile_list"])
assert "profile1234" in result.output
self._check_exit_code(["profile_delete", "profile1234"])
result = self._check_exit_code(["profile_list"])
assert "profile1234" not in result.output, result.output

@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
@skip_unless_executable("psql")
def test_profile_commands(self):
self._profile_commands()

@skip_unless_executable("docker")
def test_profile_commands_docker(self):
try:
self._profile_commands(database_type="postgres_docker")
finally:
stop_postgres_docker()