-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dblock <[email protected]>
- Loading branch information
Showing
9 changed files
with
2,834 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import glob | ||
import os | ||
import re | ||
|
||
from manifests.input_manifest import InputManifest | ||
from manifests.manifests import Manifests | ||
|
||
|
||
class InputManifests(Manifests): | ||
def __init__(self): | ||
files = glob.glob(os.path.join(self.manifests_path, "opensearch-*.yml")) | ||
# there's an opensearch-1.0.0-maven.yml that we want to skip | ||
files = [f for f in files if re.search(r"/opensearch-([0-9.]*)\.yml$", f)] | ||
super().__init__(InputManifest, files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import os | ||
import re | ||
|
||
from sortedcontainers import SortedDict # type: ignore | ||
|
||
|
||
class Manifests(SortedDict): | ||
def __init__(self, klass, files): | ||
super(Manifests, self).__init__() | ||
self.klass = klass | ||
self.__append__(files) | ||
|
||
def __append__(self, files): | ||
for filename in files: | ||
basename = os.path.basename(filename) | ||
match = re.search(r"-([0-9.]*).yml$", basename) | ||
if not match: | ||
raise ValueError(f"Invalid file: {basename}") | ||
|
||
version = match.group(1) | ||
manifest = self.klass.from_path(filename) | ||
self.__setitem__(version, manifest) | ||
|
||
@property | ||
def manifests_path(self): | ||
return os.path.realpath( | ||
os.path.join(os.path.dirname(__file__), "../../../manifests") | ||
) | ||
|
||
@property | ||
def versions(self): | ||
return list(map(lambda manifest: manifest.build.version, self.values())) | ||
|
||
@property | ||
def latest(self): | ||
if len(self) == 0: | ||
raise RuntimeError("No manifests found") | ||
|
||
return self.values()[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
|
||
class Component: | ||
def __init__(self, name, repo, snapshot=False): | ||
self.name = name | ||
self.git_repo = repo | ||
self.snapshot = snapshot | ||
|
||
def gradle_cmd(self, target, props={}): | ||
cmd = [f"./gradlew {target}"] | ||
cmd.extend([f"-D{k}={v}" for k, v in props.items()]) | ||
return " ".join(cmd) |
51 changes: 51 additions & 0 deletions
51
bundle-workflow/src/manifests_workflow/component_opensearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
from git.git_repository import GitRepository | ||
from manifests_workflow.component import Component | ||
from system.properties_file import PropertiesFile | ||
|
||
|
||
class ComponentOpenSearch(Component): | ||
@classmethod | ||
def checkout( | ||
self, | ||
name, | ||
path, | ||
opensearch_version, | ||
branch="main", | ||
snapshot=False, | ||
working_directory=None, | ||
): | ||
return ComponentOpenSearch( | ||
name, | ||
GitRepository( | ||
f"https://github.com/opensearch-project/{name}.git", | ||
branch, | ||
path, | ||
working_directory, | ||
), | ||
opensearch_version, | ||
snapshot, | ||
) | ||
|
||
def __init__(self, name, repo, opensearch_version, snapshot=False): | ||
super().__init__(name, repo, snapshot) | ||
self.opensearch_version = opensearch_version | ||
|
||
def get_properties(self): | ||
cmd = self.gradle_cmd( | ||
"properties", | ||
{ | ||
"opensearch.version": self.opensearch_version, | ||
"build.snapshot": str(self.snapshot).lower(), | ||
}, | ||
) | ||
return PropertiesFile(self.git_repo.output(cmd)) | ||
|
||
@property | ||
def version(self): | ||
return self.get_properties().get_value("version") |
56 changes: 56 additions & 0 deletions
56
bundle-workflow/src/manifests_workflow/component_opensearch_min.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import re | ||
import subprocess | ||
|
||
from git.git_repository import GitRepository | ||
from manifests_workflow.component import Component | ||
from system.properties_file import PropertiesFile | ||
|
||
|
||
class ComponentOpenSearchMin(Component): | ||
def __init__(self, repo, snapshot=False): | ||
super().__init__("OpenSearch", repo, snapshot) | ||
|
||
@classmethod | ||
def get_root_branches(self): | ||
branches = ["main"] | ||
remote_branches = ( | ||
subprocess.check_output( | ||
"git ls-remote https://github.com/opensearch-project/OpenSearch.git refs/heads/* | cut -f2 | cut -d/ -f3", | ||
shell=True, | ||
) | ||
.decode() | ||
.split("\n") | ||
) | ||
branches.extend(filter(lambda b: re.match(r"[\d]+.[\dx]*", b), remote_branches)) | ||
return branches | ||
|
||
@classmethod | ||
def checkout(self, path, branch="main", snapshot=False): | ||
return ComponentOpenSearchMin( | ||
GitRepository( | ||
"https://github.com/opensearch-project/OpenSearch.git", branch, path | ||
), | ||
snapshot, | ||
) | ||
|
||
def publish_to_maven_local(self): | ||
cmd = self.gradle_cmd( | ||
"publishToMavenLocal", {"build.snapshot": str(self.snapshot).lower()} | ||
) | ||
self.git_repo.execute_silent(cmd) | ||
|
||
def get_properties(self): | ||
cmd = self.gradle_cmd( | ||
"properties", {"build.snapshot": str(self.snapshot).lower()} | ||
) | ||
return PropertiesFile(self.git_repo.output(cmd)) | ||
|
||
@property | ||
def version(self): | ||
return self.get_properties().get_value("version") |
Oops, something went wrong.