Skip to content

Commit 79ced29

Browse files
authored
Merge pull request #976 from mvdbeek/gh_workflow
Implement github workflow and fix profile commands if psql unavailable
2 parents 93b5913 + 0298f84 commit 79ced29

10 files changed

Lines changed: 90 additions & 36 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Python CI
2+
on: [push, pull_request]
3+
env:
4+
PLANEMO_SKIP_REDUNDANT_TESTS: 1
5+
PLANEMO_ENABLE_POSTGRES_TESTS: 1
6+
PLANEMO_SKIP_GALAXY_CWL_TESTS: 1
7+
PLANEMO_TEST_WORKFLOW_RUN_PROFILE: 1
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
python-version: [2.7, 3.7]
15+
tox-action:
16+
- lint
17+
- lint_readme
18+
- lint_docs
19+
- quick
20+
- unit
21+
steps:
22+
- uses: actions/checkout@v1
23+
with:
24+
fetch-depth: 1
25+
submodules: true
26+
- uses: actions/setup-python@v1
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install tox coveralls
33+
- name: Test with tox
34+
run: |
35+
export TOXENV=$(echo $TOXENV | sed 's/\.//') && tox
36+
env:
37+
TOXENV: py${{ matrix.python-version }}-${{ matrix.tox-action }}
38+

.travis.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
11
language: python
2-
env:
3-
global:
4-
- PLANEMO_SKIP_REDUNDANT_TESTS=1
5-
- PLANEMO_ENABLE_POSTGRES_TESTS=1
6-
- PLANEMO_SKIP_GALAXY_CWL_TESTS=1
7-
- PLANEMO_TEST_WORKFLOW_RUN_PROFILE=travisworkflowtests
82
matrix:
93
include:
10-
- python: 2.7
11-
env: TOX_ENV=py27-lint
12-
- python: 3.7
13-
env: TOX_ENV=py37-lint_readme
14-
- python: 3.7
15-
env: TOX_ENV=py37-lint_docs
164
- python: 3.7
175
env: TOX_ENV=py37-lint_docstrings
18-
- python: 3.7
19-
env: TOX_ENV=py37-lint
20-
- python: 3.7
21-
env: TOX_ENV=py37-quick
22-
- python: 2.7
23-
env: TOX_ENV=py27-unit
24-
- python: 3.7
25-
env: TOX_ENV=py37-unit
266
allow_failures:
277
- env: TOX_ENV=py37-lint_docstrings
288

299
install:
30-
- pip install tox coveralls
10+
- pip install tox
3111

3212
script: tox -e $TOX_ENV
33-
34-
after_success:
35-
- coveralls
36-
37-
services:
38-
- postgresql

planemo/commands/cmd_database_create.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
@click.command('database_create')
1212
@options.database_identifier_argument()
13-
@options.database_source_options()
13+
@options.profile_database_options()
14+
@options.docker_config_options()
1415
@command_function
1516
def cli(ctx, identifier, **kwds):
1617
"""Create a *development* database.

planemo/commands/cmd_database_delete.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
@click.command('database_delete')
1111
@options.database_identifier_argument()
12-
@options.database_source_options()
12+
@options.profile_database_options()
13+
@options.docker_config_options()
1314
@command_function
1415
def cli(ctx, identifier, **kwds):
1516
"""Delete a *development* database.

planemo/commands/cmd_database_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010

1111
@click.command('database_create')
12-
@options.database_source_options()
12+
@options.profile_database_options()
13+
@options.docker_config_options()
1314
@command_function
1415
def cli(ctx, **kwds):
1516
"""List databases in configured database source.

planemo/commands/cmd_profile_delete.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@click.command('profile_delete')
1212
@options.profile_name_argument()
1313
@options.profile_database_options()
14+
@options.docker_config_options()
1415
@command_function
1516
def cli(ctx, profile_name, **kwds):
1617
"""Delete a profile."""

planemo/database/postgres_docker.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from galaxy.tools.deps import docker_util
55
from galaxy.tools.deps import dockerfiles
66
from galaxy.tools.deps.commands import execute
7+
from galaxy.util import unicodify
78

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

2425
def is_running_container(name=DEFAULT_CONTAINER_NAME, **kwds):
2526
ps_command = docker_ps(["--format", "{{.Names}}"], **kwds)
26-
running_containers = execute(ps_command)
27+
running_containers = unicodify(execute(ps_command))
2728
containers = running_containers.splitlines()
2829
return name in containers
2930

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

3940

41+
def stop_postgres_docker(name=DEFAULT_CONTAINER_NAME, **kwds):
42+
stop_command = docker_util.command_list(
43+
"stop",
44+
[name],
45+
**kwds
46+
)
47+
execute(stop_command)
48+
49+
4050
class DockerPostgresDatabaseSource(ExecutesPostgresSqlMixin, DatabaseSource):
4151
"""Postgres database running inside a Docker container."""
4252

tests/test_cmd_serve.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def test_serve_profile(self):
121121

122122
@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
123123
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
124+
@skip_unless_executable("psql")
124125
def test_serve_postgres_profile(self):
125126
self._test_serve_profile("--database_type", "postgres")
126127

tests/test_database_commands.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1+
from planemo.database.postgres_docker import stop_postgres_docker
12
from .test_utils import (
23
CliTestCase,
34
skip_unless_environ,
5+
skip_unless_executable,
46
)
57

68

79
class DatabaseCommandsTestCase(CliTestCase):
810

911
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
10-
def test_database_commands(self):
12+
def _database_commands(self, database_type="postgres"):
1113
with self._isolate():
1214
result = self._check_exit_code(["database_list"])
1315
assert "test1234" not in result.output
14-
self._check_exit_code(["database_create", "test1234"])
16+
self._check_exit_code(["database_create", "test1234", "--database_type", database_type])
1517
result = self._check_exit_code(["database_list"])
1618
assert "test1234" in result.output
1719
self._check_exit_code(["database_delete", "test1234"])
1820
result = self._check_exit_code(["database_list"])
1921
assert "test1234" not in result.output
22+
23+
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
24+
@skip_unless_executable("psql")
25+
def test_database_commands(self):
26+
self._database_commands()
27+
28+
@skip_unless_executable("docker")
29+
def test_database_commands_docker(self):
30+
try:
31+
self._database_commands(database_type="postgres_docker")
32+
finally:
33+
stop_postgres_docker()

tests/test_profile_commands.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1+
from planemo.database.postgres_docker import stop_postgres_docker
12
from .test_utils import (
23
CliTestCase,
34
skip_unless_environ,
5+
skip_unless_executable
46
)
57

68

79
class ProfileCommandsTestCase(CliTestCase):
810

9-
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
10-
def test_profile_commands(self):
11+
def _profile_commands(self, database_type="postgresql"):
1112
with self._isolate():
1213
result = self._check_exit_code(["profile_list"])
1314
assert "profile1234" not in result.output
14-
self._check_exit_code(["profile_create", "profile1234"])
15+
self._check_exit_code(["profile_create", "profile1234", "--database_type", database_type])
1516
result = self._check_exit_code(["profile_list"])
1617
assert "profile1234" in result.output
1718
self._check_exit_code(["profile_delete", "profile1234"])
1819
result = self._check_exit_code(["profile_list"])
1920
assert "profile1234" not in result.output, result.output
21+
22+
@skip_unless_environ("PLANEMO_ENABLE_POSTGRES_TESTS")
23+
@skip_unless_executable("psql")
24+
def test_profile_commands(self):
25+
self._profile_commands()
26+
27+
@skip_unless_executable("docker")
28+
def test_profile_commands_docker(self):
29+
try:
30+
self._profile_commands(database_type="postgres_docker")
31+
finally:
32+
stop_postgres_docker()

0 commit comments

Comments
 (0)