Skip to content

Commit

Permalink
update: megre master
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dovgan authored Feb 16, 2021
1 parent 133dff5 commit dcb0755
Show file tree
Hide file tree
Showing 12 changed files with 1,810 additions and 2,876 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def readme():

vcs = p4 + github

docs = ('sphinx', 'sphinx-argparse', 'sphinx_rtd_theme') # This extra is required for RTD to generate documentation
docs = ('sphinx==3.4.3', 'sphinx-argparse', 'sphinx_rtd_theme') # This extra is required for RTD to generate documentation

setup(
name=universum.__title__,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_p4_exception_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from universum import __main__
from tests.perforce_utils import P4Environment
from .perforce_utils import P4Environment


@pytest.fixture()
Expand Down
36 changes: 36 additions & 0 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# pylint: disable = redefined-outer-name

import pytest

from universum import __main__
from . import utils
from .perforce_utils import P4Environment


@pytest.fixture(name='print_text_on_teardown')
Expand Down Expand Up @@ -67,3 +70,36 @@ def test_non_utf8_environment(docker_main):
configs = Configuration([dict(name="Test configuration", command=["ls", "-la"])])
""", vcs_type="none", environment=['LANG=en_US', 'LC_ALL=en_US'])
assert "\u2514" not in output


@pytest.fixture()
def perforce_environment(perforce_workspace, tmpdir):
yield P4Environment(perforce_workspace, tmpdir, test_type="main")


def test_p4_repository_difference_format(perforce_environment, tmpdir):
p4 = perforce_environment.p4
p4_file = perforce_environment.repo_file

config = """
from universum.configuration_support import Configuration
configs = Configuration([dict(name="This is a changed step name", command=["ls", "-la"])])
"""
p4.run_edit(perforce_environment.depot)
p4_file.write(config)
change = p4.fetch_change()
change["Description"] = "CL for shelving"
shelve_cl = p4.save_change(change)[0].split()[1]
p4.run_shelve("-fc", shelve_cl)

settings = perforce_environment.settings
settings.PerforceMainVcs.shelve_cls = [shelve_cl]
settings.Launcher.config_path = p4_file.basename

result = __main__.run(settings)

assert result == 0
diff = tmpdir.join('artifacts', 'REPOSITORY_DIFFERENCE.txt').read()
assert "This is a changed step name" in diff
assert "b'" not in diff
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from universum import submit, poll, main, github_handler
from universum.lib import gravity
from tests.thirdparty.pyfeed.rfc3339 import tf_from_timestamp
from .thirdparty.pyfeed.rfc3339 import tf_from_timestamp
from . import default_args

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion universum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "Universum"
__version__ = "0.19.3"
__version__ = "0.19.4"
6 changes: 3 additions & 3 deletions universum/config_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def execute(self) -> None:
config = Path(config_name)
config.write_text("""#!/usr/bin/env {}
from universum.configuration_support import Configuration
from universum.configuration_support import Configuration, Step
configs = Configuration([dict(name='Show directory contents', command=['ls', '-la']),
dict(name='Print a line', command=['bash', '-c', 'echo Hello world'])])
configs = Configuration([Step(name='Show directory contents', command=['ls', '-la']),
Step(name='Print a line', command=['bash', '-c', 'echo Hello world'])])
if __name__ == '__main__':
print(configs.dump())
Expand Down
19 changes: 15 additions & 4 deletions universum/configuration_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@ class Step:
will not be processed correctly and therefore should be splat into ``["ls", "-a"]``. Lists like
``["build.sh", "--platform A"]`` will not be processed correctly and thus should be plat into
``["build.sh", "--platform", "A"]``. A build step can have an empty list as a command - such step won't do
anything except showing up the step name in Universum execution logs. Some common actions, such as ``echo``
or ``cp``, are bash features and not actual programs to run. These features should be called as
``["bash", "-c", "echo -e 'Some line goes here'"]``. Note that in this case the string to be passed to bash
is one argument containing white spaces and therefore not splat by commas.
anything except showing up the step name in Universum execution logs. Some common actions, such as ``echo``,
are bash features and not actual programs to run. These features should be called as
``["bash", "-c", "echo -e 'Some line goes here'"]``. Any other shell can also be used instead of bash.
Note that in this case the string to be passed to bash is one argument containing white spaces
and therefore not splat by commas.
.. note::
When a process is launched via shell, that shell also parses the arguments, which does not happen
with arguments of a direct process launch. In case of direct process launch the arguments including
special characters (e.g. ``*.txt``) are treated as usual strings. To make the lack of filename expansion
(globbing) more obvious and to make the relaunch of executed command by copy-pasting more convenient,
these arguments are printed within quotes in log. To use bash for globbing, please also use ``bash -c``
as explained above.
environment
Required environment variables, e.g. ``environment={"VAR1": "String", "VAR2": "123"}`` Can be set at any
step level, but re-declaring variables is not supported, so please make sure to mention every variable only
Expand Down
5 changes: 3 additions & 2 deletions universum/lib/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Callable, List, Optional, TypeVar, Union
from types import TracebackType
import inspect
import os
import sys
import traceback
Expand Down Expand Up @@ -116,7 +115,9 @@ def function_to_run(*args, **kwargs):


def trim_and_convert_to_unicode(line: Union[bytes, str]) -> str:
if not isinstance(line, str):
if isinstance(line, bytes):
line = line.decode("utf-8")
elif not isinstance(line, str):
line = str(line)

if line.endswith("\n"):
Expand Down
2 changes: 1 addition & 1 deletion universum/nonci.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def execute(self):

self.out.log("Cleaning artifacts...")
self.artifacts.clean_artifacts_silently()

project_configs = self.process_project_configs()
self.code_report_collector.prepare_environment(project_configs)
self.artifacts.set_and_clean_artifacts(project_configs, ignore_existing_artifacts=True)

self.launch_project()
Expand Down
Loading

0 comments on commit dcb0755

Please sign in to comment.