Example #1
0
def _ci_step(examples: List[Example]):
  """
  CI step to verify all beam examples/tests/katas
  """

  ci_helper = CIHelper()
  asyncio.run(ci_helper.verify_examples(examples))
Example #2
0
async def test_verify_examples(mock_get_statuses,
                               mock_verify_examples_statuses):
    helper = CIHelper()
    await helper.verify_examples([])

    mock_get_statuses.assert_called_once_with([])
    mock_verify_examples_statuses.assert_called_once_with([])
Example #3
0
File: ci_cd.py Project: cc13ny/beam
def ci_step():
    """
    CI step to verify all beam examples/tests/katas
    """
    root_dir = os.getenv("BEAM_ROOT_DIR")
    ci_helper = CIHelper()
    examples = find_examples(root_dir)
    ci_helper.verify_examples(examples)
Example #4
0
def ci_step():
    """
  CI step to verify all beam examples/tests/katas
  """
    setup_logger()
    root_dir = os.getenv("BEAM_ROOT_DIR")
    categories_file = os.getenv("BEAM_EXAMPLE_CATEGORIES")
    supported_categories = get_supported_categories(categories_file)
    ci_helper = CIHelper()
    examples = find_examples(root_dir, supported_categories)
    asyncio.run(ci_helper.verify_examples(examples))
Example #5
0
async def test__verify_examples(mock_get_compile_output, mock_get_run_output):
    helper = CIHelper()
    object_meta = {
        "name": "name",
        "description": "description",
        "multifile": False,
        "categories": ["category-1", "category-2"],
        "pipeline_options": "--option option",
        "default_example": False
    }
    object_meta_def_ex = copy.copy(object_meta)
    object_meta_def_ex["default_example"] = True
    pipeline_id = str(uuid.uuid4())
    default_example = Example(name="name",
                              pipeline_id=pipeline_id,
                              sdk=SDK_JAVA,
                              filepath="filepath",
                              code="code_of_example",
                              output="output_of_example",
                              status=STATUS_FINISHED,
                              tag=Tag(**object_meta_def_ex),
                              link="link")
    finished_example = Example(name="name",
                               pipeline_id=pipeline_id,
                               sdk=SDK_JAVA,
                               filepath="filepath",
                               code="code_of_example",
                               output="output_of_example",
                               status=STATUS_FINISHED,
                               tag=Tag(**object_meta),
                               link="link")
    examples_without_def_ex = [
        finished_example,
        finished_example,
    ]
    examples_with_several_def_ex = [
        default_example,
        default_example,
    ]
    examples_without_errors = [
        default_example,
        finished_example,
    ]
    examples_with_errors = [
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_VALIDATION_ERROR,
                tag=Tag(**object_meta_def_ex),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_ERROR,
                tag=Tag(**object_meta),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_COMPILE_ERROR,
                tag=Tag(**object_meta),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_PREPARATION_ERROR,
                tag=Tag(**object_meta),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_RUN_TIMEOUT,
                tag=Tag(**object_meta),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_VALIDATION_ERROR,
                tag=Tag(**object_meta),
                link="link"),
        Example(name="name",
                pipeline_id=pipeline_id,
                sdk=SDK_JAVA,
                filepath="filepath",
                code="code_of_example",
                output="output_of_example",
                status=STATUS_RUN_ERROR,
                tag=Tag(**object_meta),
                link="link"),
    ]

    with pytest.raises(VerifyException):
        await helper._verify_examples(examples_with_errors)
    with pytest.raises(VerifyException):
        await helper._verify_examples(examples_without_def_ex)
    with pytest.raises(VerifyException):
        await helper._verify_examples(examples_with_several_def_ex)
    await helper._verify_examples(examples_without_errors)