Skip to content

Commit 58078cb

Browse files
committed
Merge remote-tracking branch 'upstream/main' into small-fix-ci
2 parents 4d9f343 + 2064d4f commit 58078cb

20 files changed

+2819
-32
lines changed

manifests/1.3.0/opensearch-1.3.0.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,24 @@ components:
2626
checks:
2727
- gradle:properties:version
2828
- gradle:dependencies:opensearch.version
29+
- name: alerting
30+
repository: https://github.com/opensearch-project/alerting.git
31+
ref: main
32+
checks:
33+
- gradle:properties:version
34+
- gradle:dependencies:opensearch.version: alerting
2935
- name: asynchronous-search
3036
repository: https://github.com/opensearch-project/asynchronous-search.git
3137
ref: main
3238
checks:
3339
- gradle:properties:version
3440
- gradle:dependencies:opensearch.version
41+
- name: index-management
42+
repository: https://github.com/opensearch-project/index-management.git
43+
ref: main
44+
checks:
45+
- gradle:properties:version
46+
- gradle:dependencies:opensearch.version
3547
- name: k-NN
3648
repository: https://github.com/opensearch-project/k-NN.git
3749
ref: main

src/assemble_workflow/bundle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from assemble_workflow.bundle_recorder import BundleRecorder
1616
from assemble_workflow.dist import Dist
17+
from assemble_workflow.dists import Dists
1718
from manifests.build_manifest import BuildComponent, BuildComponents, BuildManifest
1819
from paths.script_finder import ScriptFinder
1920
from system.temporary_directory import TemporaryDirectory
@@ -132,7 +133,8 @@ def __get_min_dist(self, build_components: BuildComponents) -> Dist:
132133
min_dist_path = self._copy_component(min_bundle, "dist")
133134
logging.info(f"Copied min bundle to {min_dist_path}.")
134135
min_path = f"{self.build.filename}-{self.build.version}".replace("-SNAPSHOT", "")
135-
min_dist = Dist.from_path(min_bundle.name, min_dist_path, min_path)
136+
logging.info(f"Start creating distribution {self.build.distribution} for {min_bundle.name}.")
137+
min_dist = Dists.create_dist(min_bundle.name, min_dist_path, min_path, self.build.distribution)
136138
logging.info(f"Extracting dist into {self.tmp_dir.name}.")
137139
min_dist.extract(self.tmp_dir.name)
138140
logging.info(f"Extracted dist into {self.tmp_dir.name}.")

src/assemble_workflow/bundle_recorder.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313

1414

1515
class BundleRecorder:
16+
EXTENSIONS = {
17+
"tar": ".tar.gz",
18+
"zip": ".zip",
19+
}
20+
1621
def __init__(self, build: BuildManifest.Build, output_dir: str, artifacts_dir: str, bundle_location: BundleLocation) -> None:
1722
self.output_dir = output_dir
1823
self.build_id = build.id
1924
self.bundle_location = bundle_location
2025
self.version = build.version
26+
self.distribution = build.distribution
2127
self.package_name = self.__get_package_name(build)
2228
self.artifacts_dir = artifacts_dir
2329
self.architecture = build.architecture
@@ -27,6 +33,7 @@ def __init__(self, build: BuildManifest.Build, output_dir: str, artifacts_dir: s
2733
build.version,
2834
build.platform,
2935
build.architecture,
36+
build.distribution,
3037
self.__get_package_location(),
3138
)
3239

@@ -37,7 +44,8 @@ def __get_package_name(self, build: BuildManifest.Build) -> str:
3744
build.platform,
3845
build.architecture,
3946
]
40-
return "-".join(parts) + (".zip" if build.platform == "windows" else ".tar.gz")
47+
extension = self.EXTENSIONS[self.distribution] if self.distribution else self.EXTENSIONS['tar']
48+
return "-".join(parts) + extension
4149

4250
# Assembled output are expected to be served from a separate "dist" folder
4351
# Example: https://ci.opensearch.org/ci/dbc/bundle-build/1.2.0/build-id/linux/x64/dist/
@@ -66,14 +74,15 @@ def write_manifest(self, folder: str) -> None:
6674
self.get_manifest().to_file(manifest_path)
6775

6876
class BundleManifestBuilder:
69-
def __init__(self, build_id: str, name: str, version: str, platform: str, architecture: str, location: str) -> None:
77+
def __init__(self, build_id: str, name: str, version: str, platform: str, architecture: str, distribution: str, location: str) -> None:
7078
self.data: Dict[str, Any] = {}
7179
self.data["build"] = {}
7280
self.data["build"]["id"] = build_id
7381
self.data["build"]["name"] = name
7482
self.data["build"]["version"] = str(version)
7583
self.data["build"]["platform"] = platform
7684
self.data["build"]["architecture"] = architecture
85+
self.data["build"]["distribution"] = distribution if distribution else "tar"
7786
self.data["build"]["location"] = location
7887
self.data["schema-version"] = "1.1"
7988
# We need to store components as a hash so that we can append artifacts by component name

src/assemble_workflow/dist.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __extract__(self, dest: str) -> None:
2929
def __build__(self, name: str, dest: str) -> None:
3030
pass
3131

32-
def __find_min_archive_path(self, dest: str) -> str:
32+
def find_min_archive_path(self, dest: str) -> str:
3333
'''
3434
Return the single folder at the top level of the tar.
3535
'''
@@ -41,7 +41,7 @@ def __find_min_archive_path(self, dest: str) -> str:
4141

4242
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), os.path.join(dest, "*"))
4343

44-
def __rename_archive_path(self, path: str) -> str:
44+
def rename_archive_path(self, path: str) -> str:
4545
'''
4646
Rename the single folder at the top level of the tar that contains the min distribution to match current version.
4747
For example, when OpenSearch 1.1.1 is built using the 1.1.0 artifact, we rename opensearch-1.1.0 to opensearch-1.1.1.
@@ -58,8 +58,8 @@ def __rename_archive_path(self, path: str) -> str:
5858

5959
def extract(self, dest: str) -> str:
6060
self.__extract__(dest)
61-
self.archive_path = self.__rename_archive_path(
62-
self.__find_min_archive_path(dest)
61+
self.archive_path = self.rename_archive_path(
62+
self.find_min_archive_path(dest)
6363
)
6464
return self.archive_path
6565

@@ -69,16 +69,6 @@ def build(self, name: str, dest: str) -> None:
6969
shutil.copyfile(name, path)
7070
logging.info(f"Published {path}.")
7171

72-
@classmethod
73-
def from_path(cls, name: str, path: str, min_path: str) -> 'Dist':
74-
ext = os.path.splitext(path)[1]
75-
if ext == ".gz":
76-
return DistTar(name, path, min_path)
77-
elif ext == ".zip":
78-
return DistZip(name, path, min_path)
79-
else:
80-
raise ValueError(f'Invalid min "dist" extension in input artifacts: {ext} ({path}).')
81-
8272

8373
class DistZip(Dist):
8474
def __extract__(self, dest: str) -> None:

src/assemble_workflow/dists.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# The OpenSearch Contributors require contributions made to
4+
# this file be licensed under the Apache-2.0 license or a
5+
# compatible open source license.
6+
7+
import logging
8+
9+
from assemble_workflow.dist import Dist, DistTar, DistZip
10+
11+
12+
class Dists:
13+
DISTRIBUTIONS_MAP = {
14+
"tar": DistTar,
15+
"zip": DistZip,
16+
}
17+
18+
@classmethod
19+
def create_dist(cls, name: str, path: str, min_path: str, distribution: str) -> Dist:
20+
if distribution is None:
21+
logging.info("Distribution not specified, default to tar")
22+
distribution = 'tar'
23+
24+
return cls.DISTRIBUTIONS_MAP[distribution](name, path, min_path)

src/manifests/build_manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
version: string
2323
platform: linux, darwin or windows
2424
architecture: x64 or arm64
25+
distribution: tar, zip, and rpm
26+
id: build id
2527
components:
2628
- name: string
2729
repository: URL of git repository

src/manifests/bundle_manifest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class BundleManifest(ComponentManifest['BundleManifest', 'BundleComponents']):
2323
version: string
2424
platform: linux, darwin or windows
2525
architecture: x64 or arm64
26+
distribution: tar, zip, and rpm
27+
id: build id
2628
location: /relative/path/to/tarball
2729
components:
2830
- name: string
@@ -39,6 +41,7 @@ class BundleManifest(ComponentManifest['BundleManifest', 'BundleComponents']):
3941
"schema": {
4042
"platform": {"required": True, "type": "string"}, # added in 1.1
4143
"architecture": {"required": True, "type": "string"},
44+
"distribution": {"type": "string"},
4245
"id": {"required": True, "type": "string"},
4346
"location": {"required": True, "type": "string"},
4447
"name": {"required": True, "type": "string"},
@@ -80,6 +83,7 @@ def __init__(self, data: Dict[str, str]):
8083
self.version = data["version"]
8184
self.platform = data["platform"]
8285
self.architecture = data["architecture"]
86+
self.distribution: str = data.get('distribution', None)
8387
self.location = data["location"]
8488
self.id = data["id"]
8589

@@ -89,10 +93,15 @@ def __to_dict__(self) -> dict:
8993
"version": self.version,
9094
"platform": self.platform,
9195
"architecture": self.architecture,
96+
"distribution": self.distribution,
9297
"location": self.location,
9398
"id": self.id,
9499
}
95100

101+
@property
102+
def filename(self) -> str:
103+
return self.name.lower().replace(" ", "-")
104+
96105

97106
class BundleComponents(Components['BundleComponent']):
98107
@classmethod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This page intentionally left blank.

0 commit comments

Comments
 (0)