Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JAVA_HOME arguments in manifest workflow from template manifests. #2358

Merged
merged 6 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manifests/templates/opensearch-dashboards/1.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
schema-version: '1.0'
build:
name: OpenSearch Dashboards
version: 1.3.4
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2
components:
- name: OpenSearch-Dashboards
repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git
ref: tags/1.3.4
14 changes: 14 additions & 0 deletions manifests/templates/opensearch-dashboards/2.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
schema-version: '1.0'
build:
name: OpenSearch Dashboards
version: 2.1.0
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2
components:
- name: OpenSearch-Dashboards
repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git
ref: tags/2.1.0
checks:
- npm:package:version
12 changes: 12 additions & 0 deletions manifests/templates/opensearch-dashboards/3.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
schema-version: '1.0'
build:
name: OpenSearch Dashboards
version: 3.0.0
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2
components:
- name: OpenSearch-Dashboards
repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git
ref: main
16 changes: 16 additions & 0 deletions manifests/templates/opensearch/1.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
schema-version: '1.0'
build:
name: OpenSearch
version: 1.3.4
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2
args: -e JAVA_HOME=/opt/java/openjdk-11
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
ref: tags/1.3.4
checks:
- gradle:publish
- gradle:properties:version
16 changes: 16 additions & 0 deletions manifests/templates/opensearch/2.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
schema-version: '1.0'
build:
name: OpenSearch
version: 2.1.0
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2
args: -e JAVA_HOME=/opt/java/openjdk-17
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
ref: tags/2.1.0
checks:
- gradle:publish
- gradle:properties:version
16 changes: 16 additions & 0 deletions manifests/templates/opensearch/3.x/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
schema-version: '1.0'
build:
name: OpenSearch
version: 3.0.0
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2
args: -e JAVA_HOME=/opt/java/openjdk-17
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
ref: main
checks:
- gradle:publish
- gradle:properties:version
2 changes: 2 additions & 0 deletions src/manifests/input_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def __init__(self, data: dict) -> None:

def __to_dict__(self) -> dict:
return {
"name": self.name
} if self.args is None else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to do this because to_dict should compact the outcome. Just return what you have in else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dblock Actually I think we might need this. Otherwise it will output args: None in dashboard manifest it generated.

Copy link
Member

@dblock dblock Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we call to_dict, which removes these None values.

"name": self.name,
"args": self.args
}
Expand Down
19 changes: 10 additions & 9 deletions src/manifests_workflow/input_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,23 @@ def update(self, min_klass: Union[Type[ComponentOpenSearchMin], Type[ComponentOp
self.add_to_cron(release_version)

def create_manifest(self, version: str, components: List = []) -> InputManifest:
image_map = {
"opensearch": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2",
"opensearch-dashboards": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2"
}
templates_base_path = os.path.join(self.manifests_path(), "templates")
template_version_folder = version.split(".")[0] + ".x"
template_full_path = os.path.join(templates_base_path, self.prefix, template_version_folder,
"manifest.yml")
if os.path.exists(template_full_path):
zelinh marked this conversation as resolved.
Show resolved Hide resolved
input_manifest_templates = InputManifest.from_file(open(template_full_path))
else:
input_manifest_templates = InputManifest.from_file(open(os.path.join(templates_base_path, self.prefix,
"2.x", "manifest.yml")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hard-coding is bound to cause problems.

  1. Use the entire manifest, not just the templates.ci part, so remove the default data.
  2. Add a default folder for the default manifest and load that instead of 2.x/manifest.yml.


data: Dict = {
"schema-version": "1.0",
"build": {
"name": self.name,
"version": version
},
"ci": {
"image": {
"name": image_map[self.prefix]
}
},
"ci": input_manifest_templates.ci.__to_dict__(),
"components": [],
}

Expand Down
5 changes: 3 additions & 2 deletions tests/tests_manifests_workflow/test_input_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def test_create_manifest_opensearch(self) -> None:
{
"schema-version": "1.0",
"build": {"name": "opensearch", "version": "1.2.3"},
"ci": {"image": {"name": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2"}},
"ci": {"image": {"name": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2",
"args": "-e JAVA_HOME=/opt/java/openjdk-11"}},
},
)

Expand All @@ -36,7 +37,7 @@ def test_create_manifest_opensearch_dashboards(self) -> None:
{
"schema-version": "1.0",
"build": {"name": "opensearch-dashboards", "version": "1.2.3"},
"ci": {"image": {"name": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2"}},
"ci": {"image": {"name": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v2", }},
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def test_files(self) -> None:

@patch("os.makedirs")
@patch("os.chdir")
@patch("manifests_workflow.input_manifests.InputManifest.from_file")
@patch("manifests_workflow.input_manifests.InputManifests.add_to_cron")
@patch("manifests_workflow.input_manifests.InputManifest.from_path")
@patch("manifests_workflow.input_manifests_opensearch.ComponentOpenSearchMin")
@patch("manifests_workflow.input_manifests_opensearch.ComponentOpenSearch")
@patch("manifests_workflow.input_manifests.InputManifest")
def test_update(self, mock_input_manifest: MagicMock, mock_component_opensearch: MagicMock,
mock_component_opensearch_min: MagicMock, mock_input_manifest_from_path: MagicMock,
mock_add_to_cron: MagicMock, *mocks: MagicMock) -> None:
mock_add_to_cron: MagicMock, mock_input_manifest_from_file: MagicMock, *mocks: MagicMock) -> None:
mock_component_opensearch_min.return_value = MagicMock(name="OpenSearch")
mock_component_opensearch_min.branches.return_value = ["main", "0.9.0"]
mock_component_opensearch_min.checkout.return_value = MagicMock(version="0.9.0")
Expand All @@ -46,6 +47,7 @@ def test_update(self, mock_input_manifest: MagicMock, mock_component_opensearch:
mock_input_manifest_from_path.return_value.components = {
"common-utils": Component({"name": "common-utils", "repository": "git", "ref": "ref"})
}
mock_input_manifest_from_file.return_value.ci.__to_dict__ = MagicMock
manifests = InputManifestsOpenSearch()
manifests.update()
self.assertEqual(mock_input_manifest().to_file.call_count, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ def test_files(self) -> None:

@patch("os.makedirs")
@patch("os.chdir")
@patch("manifests_workflow.input_manifests.InputManifest.from_file")
@patch("manifests_workflow.input_manifests.InputManifests.add_to_cron")
@patch("manifests_workflow.input_manifests.InputManifest.from_path")
@patch("manifests_workflow.input_manifests_opensearch_dashboards.ComponentOpenSearchDashboardsMin")
@patch("manifests_workflow.input_manifests.InputManifest")
def test_update(self, mock_input_manifest: MagicMock, mock_component_opensearch_min: MagicMock,
mock_input_manifest_from_path: MagicMock, mock_add_to_cron: MagicMock, *mocks: MagicMock) -> None:
mock_input_manifest_from_path: MagicMock, mock_add_to_cron: MagicMock,
mock_input_manifest_from_file: MagicMock, *mocks: MagicMock) -> None:
mock_component_opensearch_min.return_value = MagicMock(name="OpenSearch-Dashboards")
mock_component_opensearch_min.branches.return_value = ["main", "0.9.0"]
mock_component_opensearch_min.checkout.return_value = MagicMock(version="0.9.0")
mock_input_manifest_from_path.return_value = MagicMock(components=[])
mock_input_manifest_from_file.return_value.ci.__to_dict__ = MagicMock
manifests = InputManifestsOpenSearchDashboards()
manifests.update()
self.assertEqual(mock_input_manifest().to_file.call_count, 1)
Expand Down