diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..f46e24331 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 }} + diff --git a/.travis.yml b/.travis.yml index 1f2273c76..7a3814f71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/planemo/commands/cmd_database_create.py b/planemo/commands/cmd_database_create.py index 31d560d22..2fabb94c1 100644 --- a/planemo/commands/cmd_database_create.py +++ b/planemo/commands/cmd_database_create.py @@ -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. diff --git a/planemo/commands/cmd_database_delete.py b/planemo/commands/cmd_database_delete.py index 6f54a2c0f..fbeeae25f 100644 --- a/planemo/commands/cmd_database_delete.py +++ b/planemo/commands/cmd_database_delete.py @@ -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. diff --git a/planemo/commands/cmd_database_list.py b/planemo/commands/cmd_database_list.py index d832e626a..b8214ee5c 100644 --- a/planemo/commands/cmd_database_list.py +++ b/planemo/commands/cmd_database_list.py @@ -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. diff --git a/planemo/commands/cmd_profile_delete.py b/planemo/commands/cmd_profile_delete.py index c133d8baf..bb1db4cf0 100644 --- a/planemo/commands/cmd_profile_delete.py +++ b/planemo/commands/cmd_profile_delete.py @@ -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.""" diff --git a/planemo/database/postgres_docker.py b/planemo/database/postgres_docker.py index 615f2a895..26107c825 100644 --- a/planemo/database/postgres_docker.py +++ b/planemo/database/postgres_docker.py @@ -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 @@ -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 @@ -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.""" diff --git a/tests/test_cmd_serve.py b/tests/test_cmd_serve.py index 804524883..37f8d7233 100644 --- a/tests/test_cmd_serve.py +++ b/tests/test_cmd_serve.py @@ -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") diff --git a/tests/test_database_commands.py b/tests/test_database_commands.py index 82195ca32..388189187 100644 --- a/tests/test_database_commands.py +++ b/tests/test_database_commands.py @@ -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() diff --git a/tests/test_profile_commands.py b/tests/test_profile_commands.py index 695edd5f7..26cc04dfd 100644 --- a/tests/test_profile_commands.py +++ b/tests/test_profile_commands.py @@ -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()