Skip to content

Commit

Permalink
Allow incremental build to respect version qualifier (#5327)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon authored Feb 17, 2025
1 parent 95f1b58 commit 25436c7
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/build_workflow/build_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def commits_diff(self, input_manifest: InputManifest) -> List[str]:
return [input_manifest.build.name.replace(" ", "-")]
previous_build_manifest = BuildManifest.from_path(build_manifest_path)
stable_input_manifest = input_manifest.stable()
if previous_build_manifest.build.version != stable_input_manifest.build.version:
stable_input_manifest_version = (
stable_input_manifest.build.version
if not stable_input_manifest.build.qualifier
else f"{stable_input_manifest.build.version}-{stable_input_manifest.build.qualifier}"
)
if previous_build_manifest.build.version != stable_input_manifest_version:
logging.info("The version of previous build manifest doesn't match the current input manifest. Rebuilding Core.")
return [input_manifest.build.name.replace(" ", "-")]
components = []
Expand Down
213 changes: 213 additions & 0 deletions tests/tests_build_workflow/data/opensearch-input-3.0.0-alpha1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
---
schema-version: '1.1'
build:
name: OpenSearch
version: 3.0.0
qualifier: alpha1
ci:
image:
name: opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1
args: -e JAVA_HOME=/opt/java/openjdk-23
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
ref: main
- name: common-utils
repository: https://github.com/opensearch-project/common-utils.git
ref: main
platforms:
- linux
- windows
- name: opensearch-learning-to-rank-base
repository: https://github.com/opensearch-project/opensearch-learning-to-rank-base.git
ref: main
platforms:
- linux
- windows
- name: opensearch-remote-metadata-sdk
repository: https://github.com/opensearch-project/opensearch-remote-metadata-sdk.git
ref: main
platforms:
- linux
- windows
- name: job-scheduler
repository: https://github.com/opensearch-project/job-scheduler.git
ref: main
platforms:
- linux
- windows
- name: security
repository: https://github.com/opensearch-project/security.git
ref: main
platforms:
- linux
- windows
- name: k-NN
repository: https://github.com/opensearch-project/k-NN.git
ref: main
platforms:
- linux
- windows
- name: geospatial
repository: https://github.com/opensearch-project/geospatial.git
ref: main
platforms:
- linux
- windows
depends_on:
- job-scheduler
- name: cross-cluster-replication
repository: https://github.com/opensearch-project/cross-cluster-replication.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- name: ml-commons
repository: https://github.com/opensearch-project/ml-commons.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- name: neural-search
repository: https://github.com/opensearch-project/neural-search.git
ref: main
platforms:
- linux
- windows
depends_on:
- ml-commons
- k-NN
- name: notifications-core
repository: https://github.com/opensearch-project/notifications.git
ref: main
working_directory: notifications
platforms:
- linux
- windows
depends_on:
- common-utils
- name: notifications
repository: https://github.com/opensearch-project/notifications.git
ref: main
working_directory: notifications
platforms:
- linux
- windows
depends_on:
- common-utils
- name: opensearch-observability
repository: https://github.com/opensearch-project/observability.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- name: opensearch-reports
repository: https://github.com/opensearch-project/reporting.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- job-scheduler
- name: sql
repository: https://github.com/opensearch-project/sql.git
ref: main
platforms:
- linux
- windows
depends_on:
- ml-commons
- name: asynchronous-search
repository: https://github.com/opensearch-project/asynchronous-search.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- name: anomaly-detection
repository: https://github.com/opensearch-project/anomaly-detection.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- job-scheduler
- name: alerting
repository: https://github.com/opensearch-project/alerting.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- name: security-analytics
repository: https://github.com/opensearch-project/security-analytics.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- alerting
- job-scheduler
- name: index-management
repository: https://github.com/opensearch-project/index-management.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- job-scheduler
- name: performance-analyzer
repository: https://github.com/opensearch-project/performance-analyzer.git
ref: main
platforms:
- linux
- name: custom-codecs
repository: https://github.com/opensearch-project/custom-codecs.git
ref: main
platforms:
- linux
- windows
- name: flow-framework
repository: https://github.com/opensearch-project/flow-framework.git
ref: main
platforms:
- linux
- windows
depends_on:
- common-utils
- opensearch-remote-metadata-sdk
- name: skills
repository: https://github.com/opensearch-project/skills.git
ref: main
platforms:
- linux
- windows
depends_on:
- job-scheduler
- anomaly-detection
- sql
- ml-commons
- name: query-insights
repository: https://github.com/opensearch-project/query-insights.git
ref: main
platforms:
- linux
- windows
- name: opensearch-system-templates
repository: https://github.com/opensearch-project/opensearch-system-templates.git
ref: main
platforms:
- linux
- windows
27 changes: 27 additions & 0 deletions tests/tests_build_workflow/test_build_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
class TestBuildIncremental(unittest.TestCase):
INPUT_MANIFEST = InputManifest.from_path(
os.path.join(os.path.dirname(__file__), "data", "opensearch-input-2.12.0.yml"))
INPUT_MANIFEST_QUALIFIER = InputManifest.from_path(
os.path.join(os.path.dirname(__file__), "data", "opensearch-input-3.0.0-alpha1.yml"))
BUILD_MANIFEST = BuildManifest.from_path(
os.path.join(os.path.dirname(__file__), "data", "opensearch-build-tar-2.12.0.yml"))
BUILD_MANIFEST_WINDOWS = BuildManifest.from_path(
Expand Down Expand Up @@ -54,6 +56,31 @@ def test_no_commits_diff(self, stable_mock_input_manifest: MagicMock, mock_build
self.assertFalse(diff_list)
self.assertEqual(len(diff_list), 0)

@patch("os.path.exists")
@patch("manifests.build_manifest.BuildManifest.from_path")
@patch("manifests.input_manifest.InputManifest.stable")
def test_no_commits_diffi_with_qualifier(self, stable_mock_input_manifest: MagicMock, mock_build_manifest: MagicMock, mock_path_exists: MagicMock) -> None:
mock_path_exists.return_value = True
input_manifest_data = {'schema-version': '1.1', 'build': {'name': 'OpenSearch', 'version': '3.0.0', 'qualifier': 'alpha1'},
'components': [{'name': 'OpenSearch',
'repository': 'https://github.com/opensearch-project/OpenSearch.git',
'ref': '91a93dacb84eae4f09decbabe54771585d42b570',
'checks': ['gradle:publish', 'gradle:properties:version']}]}
build_manifest_data = {'schema-version': '1.2',
'build': {'name': 'OpenSearch', 'version': '3.0.0-alpha1', 'platform': 'linux',
'architecture': 'x64', 'id': 'b2b848e29077488ca7e8c37501b36c87'},
'components': [{'name': 'OpenSearch',
'repository': 'https://github.com/opensearch-project/OpenSearch.git',
'ref': 'main', 'commit_id': '91a93dacb84eae4f09decbabe54771585d42b570',
'version': '3.0.0-alpha1'}]}
stable_mock_input_manifest.return_value = InputManifest(input_manifest_data)
mock_build_manifest.return_value = BuildManifest(build_manifest_data)

diff_list = self.buildIncremental.commits_diff(self.INPUT_MANIFEST_QUALIFIER)

self.assertFalse(diff_list)
self.assertEqual(len(diff_list), 0)

@patch("os.path.exists")
@patch("manifests.build_manifest.BuildManifest.from_path")
@patch("manifests.input_manifest.InputManifest.stable")
Expand Down

0 comments on commit 25436c7

Please sign in to comment.