示例#1
0
def assert_equal_multiplication(expected, env_vars: Optional[dict] = None):
    setup_env_vars(env_vars)
    var1 = Variations([
        dict(if_env_set="VAR_1 == value_1"),
        dict(if_env_set="VAR_2 == value_2")
    ])
    var2 = Variations([dict(if_env_set=" && VAR_3 == value_3")])
    configs = var1 * var2
    result = list(filter(check_if_env_set, configs.all()))
    assert expected == result
    def prepare_environment(self, project_configs):
        afterall_steps = []
        for item in project_configs:
            if not item.get("code_report", False):
                continue

            self.set_code_report_directory(self.settings.project_root)
            temp_filename = "${CODE_REPORT_FILE}"
            name = utils.calculate_file_absolute_path(
                self.report_path, item.get("name")) + ".json"
            actual_filename = os.path.join(self.report_path, name)

            for key in item:
                if key == "command":
                    item[key] = [
                        word.replace(temp_filename, actual_filename)
                        for word in item[key]
                    ]
                else:
                    try:
                        item[key] = item[key].replace(temp_filename,
                                                      actual_filename)
                    except AttributeError as error:
                        if "object has no attribute 'replace'" not in str(
                                error):
                            raise

            afterall_item = deepcopy(item)
            afterall_steps.append(afterall_item)
        return Variations(afterall_steps)
示例#3
0
def test_if_env_set_not_in_config():
    var = Variations([
        dict(code_report=True),
        dict(artifacts="htmlcov", command=["echo 123"], pass_tag="PASS")
    ])
    os.environ["VAR_1"] = "False"
    os.environ["VAR_2"] = ""
    for item in var:
        assert check_if_env_set(item) is True
    def prepare_environment(self, project_configs):
        afterall_steps = []
        for item in project_configs:
            if not item.get("code_report", False):
                continue

            self.set_code_report_directory(self.settings.project_root)

            temp_filename = "${CODE_REPORT_FILE}"
            for enum, i in enumerate(item["command"]):
                if temp_filename in i:
                    name = utils.calculate_file_absolute_path(
                        self.report_path, item.get("name")) + ".json"
                    actual_filename = os.path.join(self.report_path, name)
                    item["command"][enum] = item["command"][enum].replace(
                        temp_filename, actual_filename)

            afterall_item = deepcopy(item)
            afterall_steps.append(afterall_item)
        return Variations(afterall_steps)
示例#5
0
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

configs = Variations([dict(name='Build ', command=['build.sh'], artifacts='out')])

if __name__ == '__main__':
    print(configs.dump())
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

script_name = './basic_build_script.sh'

build = Variations(
    [dict(name='Build ', command=[script_name], artifacts='out')])

platforms = Variations([
    dict(name='for platform A ',
         command=['--platform_a'],
         if_env_set="PLATFORM == A"),
    dict(name='for platform B ',
         command=['--platform_b'],
         if_env_set="PLATFORM == B")
])

bits = Variations([
    dict(name='32 bits', command=['--32'], artifacts='/result*32.txt'),
    dict(name='64 bits', command=['--64'], if_env_set=" & IS_X64")
])

# Will run every platform with a specified tool with '--32' flag
# Will run same platforms with '--64' flag only if $IS_X64 variable is set (e.g. by "export IS_X64=true")
configs = build * platforms * bits

if __name__ == '__main__':
    print(configs.dump())
示例#7
0
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

not_script = Variations([dict(name='Not script', command=["not_run.sh"])])

script = Variations([dict(command=["run.sh"], directory="examples")])

step = Variations([dict(name='Step 1', critical=True), dict(name='Step 2')])

additional_substep = Variations(
    [dict(name=', additional substep', command=["fail"], critical=False)])

substep = Variations([
    dict(name=', failed substep', command=["fail"], artrifacts="*.sh"),
    dict(name=', successful substep', command=["pass"], artifacts="*.txt")
])

configs = not_script + script * step * (substep + additional_substep)

if __name__ == '__main__':
    print(configs.dump())
示例#8
0
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

not_script = Variations(
    [dict(name='Not script', command=["not_run.sh"], critical=True)])

script = Variations([dict(command=["run.sh"])])

step = Variations([dict(name='Step 1', critical=True), dict(name='Step 2')])

substep = Variations([
    dict(name=', failed substep', command=["fail"]),
    dict(name=', successful substep', command=["pass"])
])

configs = script * step * substep + not_script + script

if __name__ == '__main__':
    print(configs.dump())
示例#9
0
from universum.configuration_support import Variations


one = Variations([{'name': 'one', 'command': ['echo', 'one']}])

two = Variations([{'name': 'two'}])
two_one = Variations([{'name': '_one', 'command': ['./universum_config/sleep_and_fail.sh']}])
two_two = Variations([{'name': '_two', 'command': ['./universum_config/large_output_and_success.sh']}])

three = Variations([{'name': 'three', 'command': ['./universum_config/fail.sh']}])

configs = one + two * (two_one + two_two) + three
示例#10
0
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

background = Variations([dict(name="Background", background=True)])
sleep = Variations([dict(name=' long step', command=["sleep", "1"])])
multiply = Variations([dict(name="_1"), dict(name="_2"), dict(name="_3")])
wait = Variations([
    dict(name='Step requiring background results',
         command=["run.sh", "pass"],
         finish_background=True)
])

script = Variations(
    [dict(name=" unsuccessful step", command=["run.sh", "fail"])])

configs = background * (script + sleep * multiply) + wait + background * (
    sleep + script)

if __name__ == '__main__':
    print(configs.dump())
示例#11
0
#!/usr/bin/env python3.7

import os.path
from universum.configuration_support import Variations, get_project_root

#
# One way to specify path to the script: add full path to the command
#
script_name = './basic_build_script.sh'
script_path = os.path.abspath(os.path.join(get_project_root(), script_name))

build32 = Variations(
    [dict(name='Build ', command=[script_path], artifacts='out')])

platforms32 = Variations([
    dict(name='for platform A ', command=['--platform_a']),
    dict(name='for platform B ', command=['--platform_b'])
])

bits32 = Variations(
    [dict(name='32 bits', command=['--32'], artifacts='/result*32.txt')])
configs = build32 * platforms32 * bits32

#
# Alternative way to specify path to the script: provide working directory in the 'directory' attribute of configuration
#
build64 = Variations([
    dict(name='Build ',
         directory=get_project_root(),
         command=[script_name],
         artifacts='out')
示例#12
0
#!/usr/bin/env python3.7

from universum.configuration_support import Variations

mkdir = Variations([dict(name="Create directory", command=["mkdir", "-p"])])
mkfile = Variations([dict(name="Create file", command=["touch"])])
dirs1 = Variations([
    dict(name=" one/two{}/three".format(str(x)),
         command=["one/two{}/three".format(str(x))]) for x in range(0, 6)
])
files1 = Variations([
    dict(name=" one/two{}/three/file{}.txt".format(str(x), str(x)),
         command=["one/two{}/three/file{}.txt".format(str(x), str(x))])
    for x in range(0, 6)
])

dirs2 = Variations([dict(name=" one/three", command=["one/three"])])
files2 = Variations(
    [dict(name=" one/three/file.sh", command=["one/three/file.sh"])])

artifacts = Variations([
    dict(name="Existing artifacts",
         artifacts="one/**/file*",
         report_artifacts="one/*"),
    dict(name="Missing artifacts",
         artifacts="something",
         report_artifacts="something_else")
])

configs = mkdir * dirs1 + mkdir * dirs2 + mkfile * files1 + mkfile * files2 + artifacts
示例#13
0
configs = Variations([
    dict(name="Update Docker images", command=["make", "images"]),
    dict(name="Update Pylint",
         command=[
             "python3.7", "-m", "pip", "install", "-U", "--user",
             "--progress-bar", "off", "pylint"
         ]),
    dict(name="Create virtual environment",
         command=["python3.7", "-m", "venv", env_name]),
    dict(name="Install development",
         command=run_virtual(pip_install(".[development]"))),
    dict(name="Make", artifacts="doc/_build", command=run_virtual("make")),
    dict(name="Install tests",
         artifacts="junit_results.xml",
         command=run_virtual(pip_install(".[test]"))),
    dict(name="Make tests",
         artifacts="htmlcov",
         command=run_virtual("export LANG=en_US.UTF-8; make test")),
    dict(name="Run static pylint",
         code_report=True,
         command=[
             "python3.7", "-m", "universum.analyzers.pylint",
             "--python-version=3.7", "--rcfile=pylintrc",
             "--result-file=${CODE_REPORT_FILE}", "--files", "*.py",
             "universum/", "tests/"
         ]),
    dict(
        name="Run Jenkins plugin Java tests",
        artifacts=
        "universum_log_collapser/universum_log_collapser/target/surefire-reports/*.xml",
        command=["mvn", "-B", "test"],
        directory="universum_log_collapser/universum_log_collapser"),
    dict(name="Run Jenkins plugin CLI version",
         command=["mvn", "-B", "compile", "assembly:single"],
         directory="universum_log_collapser/universum_log_collapser"),
    dict(name="Generate HTML for JavaScript tests",
         command=["universum_log_collapser/e2e/universum_live_log_to_html.py"
                  ]),
    dict(name="Prepare Jenkins plugin JavaScript tests project",
         command=["npm", "install"],
         directory="universum_log_collapser/e2e"),
    dict(name="Run Jenkins plugin JavaScript tests",
         command=["npm", "test"],
         directory="universum_log_collapser/e2e")
])