Skip to content

Commit

Permalink
Revert tests and also add changes based on comments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon committed Feb 16, 2022
1 parent 0c40e51 commit 923c161
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 112 deletions.
120 changes: 43 additions & 77 deletions scripts/components/OpenSearch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function usage() {
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
echo -e "-p PLATFORM\t[Optional] Platform, default is 'uname -s'."
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'."
echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'None'."
echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'."
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
echo -e "-h help"
}
Expand Down Expand Up @@ -81,93 +81,59 @@ cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org

[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}')
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m`
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="None"

case $PLATFORM in
linux*)
case $DISTRIBUTION in
tar|None)
PACKAGE="tar"
EXT="tar.gz"
TYPE="archives"
;;
rpm)
PACKAGE="rpm"
EXT="rpm"
TYPE="packages"
;;
*)
echo "Unsupported platform and distribution combo: $PLATFORM-$DISTRIBUTION"
exit 1
;;
esac
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"

case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
linux-tar-x64|darwin-tar-x64)
PACKAGE="tar"
EXT="tar.gz"
TYPE="archives"
TARGET="$PLATFORM-$PACKAGE"
QUALIFIER="$PLATFORM-x64"
;;

darwin*)
case $DISTRIBUTION in
tar|None)
PACKAGE="tar"
EXT="tar.gz"
TYPE="archives"
;;
*)
echo "Unsupported platform and distribution combo: $PLATFORM-$DISTRIBUTION"
exit 1
;;
esac
linux-tar-arm64|darwin-tar-arm64)
PACKAGE="tar"
EXT="tar.gz"
TYPE="archives"
TARGET="$PLATFORM-arm64-$PACKAGE"
QUALIFIER="$PLATFORM-arm64"
;;

windows*)
case $DISTRIBUTION in
zip|None)
PACKAGE="zip"
EXT="zip"
TYPE="archives"
;;
*)
echo "Unsupported platform and distribution combo: $PLATFORM-$DISTRIBUTION"
exit 1
;;
esac
linux-rpm-x64)
PACKAGE="rpm"
EXT="rpm"
TYPE="packages"
TARGET="rpm"
QUALIFIER="x86_64"
;;
*)
echo "Unsupported platform: $PLATFORM"
exit 1
linux-rpm-arm64)
PACKAGE="rpm"
EXT="rpm"
TYPE="packages"
TARGET="arm64-rpm"
QUALIFIER="aarch64"
;;
esac

case $ARCHITECTURE in
x64)
case $DISTRIBUTION in
rpm)
TARGET="$DISTRIBUTION"
QUALIFIER="x86_64"
;;
*)
TARGET="$PLATFORM-$PACKAGE"
QUALIFIER="$PLATFORM-x64"
;;
esac
windows-zip-x64)
PACKAGE="zip"
EXT="zip"
TYPE="archives"
TARGET="$PLATFORM-$PACKAGE"
QUALIFIER="$PLATFORM-x64"
;;

arm64)
case $DISTRIBUTION in
rpm)
TARGET="$DISTRIBUTION"
QUALIFIER="aarch64"
;;
*)
TARGET="$PLATFORM-arm64-$PACKAGE"
QUALIFIER="$PLATFORM-arm64"
;;
esac
windows-zip-arm64)
PACKAGE="zip"
EXT="zip"
TYPE="archives"
TARGET="$PLATFORM-arm64-$PACKAGE"
QUALIFIER="$PLATFORM-arm64"
;;
*)
echo "Unsupported architecture: $ARCHITECTURE"
echo "Unsupported platform-distribution-architecture combo: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
exit 1
;;
esac

echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"

./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT

# Copy artifact to dist folder in bundle build output
Expand Down
2 changes: 1 addition & 1 deletion src/build_workflow/build_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, target: BuildTarget):
self.data["build"]["version"] = target.opensearch_version
self.data["build"]["platform"] = target.platform
self.data["build"]["architecture"] = target.architecture
self.data["build"]["distribution"] = target.distribution if target.distribution else "None"
self.data["build"]["distribution"] = target.distribution if target.distribution else "tar"
self.data["schema-version"] = "1.2"
self.components_hash: Dict[str, Dict[str, Any]] = {}

Expand Down
21 changes: 7 additions & 14 deletions src/build_workflow/builder_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@ def checkout(self, work_dir: str) -> None:

def build(self, build_recorder: BuildRecorder) -> None:
build_script = ScriptFinder.find_build_script(self.target.name, self.component.name, self.git_repo.working_directory)
distribution_parameter = "-d" + " " + self.target.distribution if self.target.distribution else None

build_command = " ".join(
filter(
None,
filter(None,
[
"bash",
build_script,
"-v",
self.target.version,
"-p",
self.target.platform,
"-a",
self.target.architecture,
distribution_parameter,
"-s",
str(self.target.snapshot).lower(),
"-o",
self.output_path,
f"-v {self.target.version}",
f"-p {self.target.platform}",
f"-a {self.target.architecture}",
f"-d {self.target.distribution}" if self.target.distribution else None,
f"-s {str(self.target.snapshot).lower()}",
f"-o {self.output_path}",
]
)
)
Expand Down
1 change: 0 additions & 1 deletion tests/data/opensearch-build-1.1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down
1 change: 0 additions & 1 deletion tests/data/opensearch-dashboards-build-1.2.0.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
architecture: x64
distribution: None
id: 25b38c278cdd45efa583765d8ba76346
name: OpenSearch Dashboards
platform: linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
architecture: x64
distribution: None
id: f49ffcf2c1b341d1b29e147093689c6d
name: OpenSearch
platform: linux
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
platform: windows
distribution: None
architecture: x64
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c94ebec444a94ada86a230c9297b1d73
name: OpenSearch Dashboards
version: 1.1.0
Expand Down
3 changes: 1 addition & 2 deletions tests/tests_assemble_workflow/test_bundles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-1.0
# 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
Expand Down Expand Up @@ -42,7 +42,6 @@ def test_bundle_opensearch_invalid(self) -> None:
"name": "invalid",
"platform": "linux",
"architecture": "x86",
"distribution": "None",
"id": "id",
"version": "1.0.0",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
platform: windows
distribution: None
architecture: x64
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
Expand Down
2 changes: 0 additions & 2 deletions tests/tests_build_workflow/test_build_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_record_component_and_artifact(self, mock_makedirs: Mock, mock_copyfile:
"build": {
"platform": "linux",
"architecture": "x64",
"distribution": "None",
"id": "1",
"name": "OpenSearch",
"version": "1.1.0",
Expand Down Expand Up @@ -135,7 +134,6 @@ def test_get_manifest(self) -> None:
"build": {
"platform": "linux",
"architecture": "x64",
"distribution": "None",
"id": "1",
"name": "OpenSearch",
"version": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down
1 change: 0 additions & 1 deletion tests/tests_manifests/data/opensearch-build-1.1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down
1 change: 0 additions & 1 deletion tests/tests_manifests/data/opensearch-build-1.2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.2.0
Expand Down
1 change: 0 additions & 1 deletion tests/tests_sign_workflow/data/opensearch-build-1.1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
architecture: x64
distribution: None
id: a8f93473cab545bbaac3e2ce599b5434
name: OpenSearch
platform: linux
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
architecture: x64
distribution: None
id: a8f93473cab545bbaac3e2ce599b5434
name: OpenSearch
platform: linux
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
platform: linux
distribution: None
architecture: x64
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
build:
platform: linux
distribution: None
architecture: x64
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build:
platform: linux
architecture: x64
distribution: None
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
Expand Down

0 comments on commit 923c161

Please sign in to comment.