diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/build.sh b/bundle-workflow/src/git/__init__.py similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/build.sh rename to bundle-workflow/src/git/__init__.py diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/install.sh b/bundle-workflow/src/paths/__init__.py similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/install.sh rename to bundle-workflow/src/paths/__init__.py diff --git a/bundle-workflow/src/sign.py b/bundle-workflow/src/sign.py index 8bb91ad09e..287851d673 100755 --- a/bundle-workflow/src/sign.py +++ b/bundle-workflow/src/sign.py @@ -7,7 +7,6 @@ # compatible open source license. import argparse -import os from manifests.build_manifest import BuildManifest from signing_workflow.signer import Signer @@ -21,7 +20,6 @@ args = parser.parse_args() manifest = BuildManifest.from_file(args.manifest) -basepath = os.path.dirname(os.path.abspath(args.manifest.name)) signer = Signer() for component in manifest.components: diff --git a/bundle-workflow/src/signing_workflow/__init__.py b/bundle-workflow/src/signing_workflow/__init__.py index 2fee7d03b3..bdd0c714d1 100644 --- a/bundle-workflow/src/signing_workflow/__init__.py +++ b/bundle-workflow/src/signing_workflow/__init__.py @@ -1,7 +1,7 @@ -# SPDX-License-Identifier: Apache-2.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 +# compatible open source license. # -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - # This page intentionally left blank. diff --git a/bundle-workflow/src/signing_workflow/signer.py b/bundle-workflow/src/signing_workflow/signer.py index 056215990b..1af0c24349 100644 --- a/bundle-workflow/src/signing_workflow/signer.py +++ b/bundle-workflow/src/signing_workflow/signer.py @@ -8,7 +8,6 @@ import os import pathlib -import sys from git.git_repository import GitRepository @@ -17,12 +16,10 @@ The signed artifacts will be found in the same location as the original artifacts. """ -sys.path.insert(0, "../git") - class Signer: - ACCEPTED_FILE_TYPES = ['.zip', '.jar', '.war', '.pom', '.module', '.tar.gz'] + ACCEPTED_FILE_TYPES = [".zip", ".jar", ".war", ".pom", ".module", ".tar.gz"] def __init__(self): self.git_repo = GitRepository(self.get_repo_url(), "HEAD") @@ -32,14 +29,16 @@ def __init__(self): def sign_artifacts(self, artifacts, basepath): for artifact in artifacts: if self.is_invalid_file_type(artifact): - print(f'Skipping signing of file ${artifact}') + print(f"Skipping signing of file ${artifact}") continue location = os.path.join(basepath, artifact) self.sign(location) self.verify(location + ".asc") def is_invalid_file_type(self, file_name): - return ''.join(pathlib.Path(file_name).suffixes) not in Signer.ACCEPTED_FILE_TYPES + return ( + "".join(pathlib.Path(file_name).suffixes) not in Signer.ACCEPTED_FILE_TYPES + ) def get_repo_url(self): if "GITHUB_TOKEN" in os.environ: diff --git a/bundle-workflow/tests/signing_workflow/__init__.py b/bundle-workflow/tests/signing_workflow/__init__.py deleted file mode 100644 index a461c5e0e8..0000000000 --- a/bundle-workflow/tests/signing_workflow/__init__.py +++ /dev/null @@ -1,11 +0,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 -# compatible open source license. - -import os -import sys - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../..")) -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../src")) diff --git a/bundle-workflow/tests/signing_workflow/test_sign.py b/bundle-workflow/tests/signing_workflow/test_sign.py deleted file mode 100644 index 96050c1530..0000000000 --- a/bundle-workflow/tests/signing_workflow/test_sign.py +++ /dev/null @@ -1,33 +0,0 @@ -import unittest -from unittest.mock import MagicMock, call, patch - -from src.signing_workflow.signer import Signer - - -class TestSigner(unittest.TestCase): - - @patch('src.signing_workflow.signer.GitRepository') - def test_accepted_file_types(self, git_repo): - - artifacts = [ - 'bad-xml.xml', - 'the-jar.jar', - 'the-zip.zip', - 'the-war.war', - 'the-pom.pom', - 'the-module.module', - 'the-tar.tar.gz', - 'random-file.txt', - ] - expected = [ - call('/path/the-jar.jar'), - call('/path/the-zip.zip'), - call('/path/the-war.war'), - call('/path/the-pom.pom'), - call('/path/the-module.module'), - call('/path/the-tar.tar.gz'), - ] - signer = Signer() - signer.sign = MagicMock() - signer.sign_artifacts(artifacts, '/path') - self.assertEqual(signer.sign.call_args_list, expected) diff --git a/bundle-workflow/tests/git/__init__.py b/bundle-workflow/tests/tests_git/__init__.py similarity index 100% rename from bundle-workflow/tests/git/__init__.py rename to bundle-workflow/tests/tests_git/__init__.py diff --git a/bundle-workflow/tests/git/test_git_repository.py b/bundle-workflow/tests/tests_git/test_git_repository.py similarity index 100% rename from bundle-workflow/tests/git/test_git_repository.py rename to bundle-workflow/tests/tests_git/test_git_repository.py diff --git a/bundle-workflow/tests/paths/__init__.py b/bundle-workflow/tests/tests_paths/__init__.py similarity index 100% rename from bundle-workflow/tests/paths/__init__.py rename to bundle-workflow/tests/tests_paths/__init__.py diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts/build.sh b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/build.sh similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts/build.sh rename to bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/build.sh diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts/install.sh b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/install.sh similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts/install.sh rename to bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/install.sh diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/integtest.sh b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/integtest.sh similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts-folder/scripts/integtest.sh rename to bundle-workflow/tests/tests_paths/data/git/component-with-scripts-folder/scripts/integtest.sh diff --git a/bundle-workflow/tests/paths/data/git/component-with-scripts/integtest.sh b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts/build.sh similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-with-scripts/integtest.sh rename to bundle-workflow/tests/tests_paths/data/git/component-with-scripts/build.sh diff --git a/bundle-workflow/tests/paths/data/git/component-without-scripts/.gitkeep b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts/install.sh similarity index 100% rename from bundle-workflow/tests/paths/data/git/component-without-scripts/.gitkeep rename to bundle-workflow/tests/tests_paths/data/git/component-with-scripts/install.sh diff --git a/bundle-workflow/tests/tests_paths/data/git/component-with-scripts/integtest.sh b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts/integtest.sh new file mode 100644 index 0000000000..bdd0c714d1 --- /dev/null +++ b/bundle-workflow/tests/tests_paths/data/git/component-with-scripts/integtest.sh @@ -0,0 +1,7 @@ +# 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. +# +# This page intentionally left blank. diff --git a/bundle-workflow/tests/tests_paths/data/git/component-without-scripts/.gitkeep b/bundle-workflow/tests/tests_paths/data/git/component-without-scripts/.gitkeep new file mode 100644 index 0000000000..bdd0c714d1 --- /dev/null +++ b/bundle-workflow/tests/tests_paths/data/git/component-without-scripts/.gitkeep @@ -0,0 +1,7 @@ +# 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. +# +# This page intentionally left blank. diff --git a/bundle-workflow/tests/paths/test_script_finder.py b/bundle-workflow/tests/tests_paths/test_script_finder.py similarity index 100% rename from bundle-workflow/tests/paths/test_script_finder.py rename to bundle-workflow/tests/tests_paths/test_script_finder.py diff --git a/bundle-workflow/tests/tests_signing_workflow/__init__.py b/bundle-workflow/tests/tests_signing_workflow/__init__.py new file mode 100644 index 0000000000..04c694fd3a --- /dev/null +++ b/bundle-workflow/tests/tests_signing_workflow/__init__.py @@ -0,0 +1,12 @@ +# 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 sys + +sys.path.insert( + 0, os.path.realpath(os.path.join(os.path.dirname(__file__), "../../src")) +) diff --git a/bundle-workflow/tests/tests_signing_workflow/test_sign.py b/bundle-workflow/tests/tests_signing_workflow/test_sign.py new file mode 100644 index 0000000000..45362cc727 --- /dev/null +++ b/bundle-workflow/tests/tests_signing_workflow/test_sign.py @@ -0,0 +1,32 @@ +import unittest +from unittest.mock import MagicMock, call, patch + +from src.signing_workflow.signer import Signer + + +class TestSigner(unittest.TestCase): + @patch("src.signing_workflow.signer.GitRepository") + def test_accepted_file_types(self, git_repo): + + artifacts = [ + "bad-xml.xml", + "the-jar.jar", + "the-zip.zip", + "the-war.war", + "the-pom.pom", + "the-module.module", + "the-tar.tar.gz", + "random-file.txt", + ] + expected = [ + call("/path/the-jar.jar"), + call("/path/the-zip.zip"), + call("/path/the-war.war"), + call("/path/the-pom.pom"), + call("/path/the-module.module"), + call("/path/the-tar.tar.gz"), + ] + signer = Signer() + signer.sign = MagicMock() + signer.sign_artifacts(artifacts, "/path") + self.assertEqual(signer.sign.call_args_list, expected) diff --git a/bundle-workflow/tests/system/__init__.py b/bundle-workflow/tests/tests_system/__init__.py similarity index 100% rename from bundle-workflow/tests/system/__init__.py rename to bundle-workflow/tests/tests_system/__init__.py diff --git a/bundle-workflow/tests/system/test_arch.py b/bundle-workflow/tests/tests_system/test_arch.py similarity index 100% rename from bundle-workflow/tests/system/test_arch.py rename to bundle-workflow/tests/tests_system/test_arch.py diff --git a/bundle-workflow/tests/system/test_temporary_directory.py b/bundle-workflow/tests/tests_system/test_temporary_directory.py similarity index 100% rename from bundle-workflow/tests/system/test_temporary_directory.py rename to bundle-workflow/tests/tests_system/test_temporary_directory.py