コード例 #1
0
 def test_compatible_opensearch_versions(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.2",
                     architecture="x86",
                     patches=["1.1.0", "1.1.1"],
                     snapshot=False).compatible_opensearch_versions,
         ['1.1.2', '1.1.0', '1.1.1', '1.1.0-SNAPSHOT', '1.1.1-SNAPSHOT'],
     )
コード例 #2
0
 def __mock_target(self, name: str = "OpenSearch") -> BuildTarget:
     return BuildTarget(
         build_id="1",
         output_dir="output_dir",
         name=name,
         version="1.1.0",
         architecture="x64",
         snapshot=True,
     )
コード例 #3
0
 def test_compatible_component_versions_snapshot(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.2",
                     architecture="x86",
                     patches=["1.1.0", "1.1.1"],
                     snapshot=True).compatible_component_versions,
         [
             '1.1.2.0-SNAPSHOT', '1.1.0.0', '1.1.1.0', '1.1.0.0-SNAPSHOT',
             '1.1.1.0-SNAPSHOT'
         ],
     )
コード例 #4
0
 def __mock(self, snapshot: bool = True) -> BuildRecorder:
     return BuildRecorder(
         BuildTarget(
             build_id="1",
             output_dir="output_dir",
             name="OpenSearch",
             version="1.1.0",
             platform="linux",
             architecture="x64",
             snapshot=snapshot,
         ))
コード例 #5
0
ファイル: run_build.py プロジェクト: mch2/opensearch-build
def main():
    args = BuildArgs()
    console.configure(level=args.logging_level)
    manifest = InputManifest.from_file(args.manifest)

    if args.ref_manifest:
        manifest = manifest.stable()
        if os.path.exists(args.ref_manifest):
            if manifest == InputManifest.from_path(args.ref_manifest):
                logging.info(f"No changes since {args.ref_manifest}")
            else:
                logging.info(f"Updating {args.ref_manifest}")
                manifest.to_file(args.ref_manifest)
        else:
            logging.info(f"Creating {args.ref_manifest}")
            manifest.to_file(args.ref_manifest)
        exit(0)

    output_dir = BuildOutputDir(manifest.build.filename).dir

    with TemporaryDirectory(keep=args.keep, chdir=True) as work_dir:
        logging.info(f"Building in {work_dir.name}")

        target = BuildTarget(
            name=manifest.build.name,
            version=manifest.build.version,
            patches=manifest.build.patches,
            snapshot=args.snapshot if args.snapshot is not None else manifest.build.snapshot,
            output_dir=output_dir,
            platform=args.platform or manifest.build.platform,
            architecture=args.architecture or manifest.build.architecture,
        )

        build_recorder = BuildRecorder(target)

        logging.info(f"Building {manifest.build.name} ({target.architecture}) into {target.output_dir}")

        for component in manifest.components.select(focus=args.component, platform=target.platform):
            logging.info(f"Building {component.name}")

            builder = Builders.builder_from(component, target)
            try:
                builder.checkout(work_dir.name)
                builder.build(build_recorder)
                builder.export_artifacts(build_recorder)
            except:
                logging.error(f"Error building {component.name}, retry with: {args.component_command(component.name)}")
                raise

        build_recorder.write_manifest()

    logging.info("Done.")
 def __mock(self, props: dict = {}, snapshot: bool = True) -> Generator[BuildArtifactOpenSearchDashboardsCheckPlugin, None, None]:
     with patch("build_workflow.opensearch_dashboards.build_artifact_check_plugin.ZipFile") as mock_zipfile:
         mock_zipfile.return_value.__enter__.return_value.read.return_value.decode.return_value = props
         yield BuildArtifactOpenSearchDashboardsCheckPlugin(
             BuildTarget(
                 build_id="1",
                 output_dir="output_dir",
                 name="OpenSearch",
                 version="1.1.0",
                 patches=["1.0.0"],
                 architecture="x64",
                 snapshot=snapshot,
             )
         )
コード例 #7
0
 def setUp(self) -> None:
     self.builder = BuilderFromSource(
         InputComponentFromSource({
             "name": "common-utils",
             "repository": "url",
             "ref": "ref"
         }),
         BuildTarget(
             name="OpenSearch",
             version="1.1.0",
             platform="linux",
             architecture="x64",
             snapshot=False,
         ),
     )
コード例 #8
0
 def test_build_id_hex(self) -> None:
     self.assertEqual(
         len(BuildTarget(version="1.1.0", architecture="x86").build_id), 32)
コード例 #9
0
 def test_component_version_snapshot(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86",
                     snapshot=True).component_version,
         "1.1.0.0-SNAPSHOT",
     )
コード例 #10
0
 def test_opensearch_version_snapshot_qualifier(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86", snapshot=True, qualifier="alpha1").opensearch_version,
         "1.1.0-alpha1-SNAPSHOT",
     )
コード例 #11
0
 def test_component_version(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86",
                     snapshot=False).component_version,
         "1.1.0.0",
     )
コード例 #12
0
 def test_compatible_component_versions_qualifier(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False, qualifier="alpha1").compatible_component_versions,
         ['1.1.2.0-alpha1', '1.1.0.0-alpha1', '1.1.1.0-alpha1', '1.1.0.0-alpha1-SNAPSHOT', '1.1.1.0-alpha1-SNAPSHOT'],
     )
コード例 #13
0
 def test_opensearch_version(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86",
                     snapshot=False).opensearch_version,
         "1.1.0",
     )
コード例 #14
0
 def test_platform(self, value_platform: Mock) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", snapshot=False).platform, "value")
     value_platform.assert_called_once()
コード例 #15
0
 def test_distribution_from_arg(self) -> None:
     self.assertEqual(BuildTarget(version="1.3.0", architecture="x86", distribution="rpm").distribution, "rpm")
コード例 #16
0
 def test_platform_value(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", platform="value",
                     snapshot=False).platform, "value")
コード例 #17
0
 def test_output_dir(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86").output_dir,
         "artifacts")
コード例 #18
0
 def test_arch_value(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="value",
                     snapshot=False).architecture, "value")
コード例 #19
0
 def test_arch(self, value_architecture: Mock) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", snapshot=False).architecture, "value")
     value_architecture.assert_called_once()
コード例 #20
0
 def test_build_id_from_arg(self) -> None:
     self.assertEqual(
         BuildTarget(version="1.1.0", architecture="x86",
                     build_id="id").build_id, "id")
コード例 #21
0
    def setUp(self) -> None:
        self.builder = BuilderFromSource(
            InputComponentFromSource({
                "name": "sample_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.1.0",
                platform="linux",
                architecture="x64",
                snapshot=False,
            ),
        )

        self.builder_distribution = BuilderFromSource(
            InputComponentFromSource({
                "name": "OpenSearch",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="tar",
                snapshot=False,
            ),
        )

        self.builder_distribution_support = BuilderFromSource(
            InputComponentFromSource({
                "name": "sample_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="rpm",
                snapshot=False,
            ),
        )

        self.builder_distribution_support_component_not_found = BuilderFromSource(
            InputComponentFromSource({
                "name": "not_found_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="rpm",
                snapshot=False,
            ),
        )