-
Notifications
You must be signed in to change notification settings - Fork 152
feat: add custom working directory for custom build workflow #378
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
Changes from all commits
5f85087
daf7b19
182bd01
ad998b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,48 @@ def test_must_build_python_project_through_makefile(self): | |
| output_files = set(os.listdir(self.artifacts_dir)) | ||
| self.assertEqual(expected_files, output_files) | ||
|
|
||
| def test_build_python_project_failed_through_makefile_no_python_source_in_default_working_directory(self): | ||
| source_code = os.path.join(os.path.dirname(__file__), "testdata", "makefile-in-different-working-directory") | ||
| manifest_path_valid = os.path.join(source_code, "Makefile") | ||
| with self.assertRaises(WorkflowFailedError): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this test fail and raise a WorkflowFailedError? working_directory is an optional param right?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I think it's because the requirements file is inside
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I had a call with Sriram to explain that but forgot to reply to this comment |
||
| self.builder.build( | ||
| source_code, | ||
| self.artifacts_dir, | ||
| self.scratch_dir, | ||
| manifest_path_valid, | ||
| runtime=self.runtime, | ||
| options={"build_logical_id": "HelloWorldFunction"}, | ||
| ) | ||
|
|
||
| def test_must_build_python_project_through_makefile_with_custom_working_directory(self): | ||
| source_code = os.path.join(os.path.dirname(__file__), "testdata", "makefile-in-different-working-directory") | ||
| manifest_path_valid = os.path.join(source_code, "Makefile") | ||
| working_directory = os.path.join(source_code, "source_code") | ||
| self.builder.build( | ||
| source_code, | ||
| self.artifacts_dir, | ||
| self.scratch_dir, | ||
| manifest_path_valid, | ||
| runtime=self.runtime, | ||
| options={"build_logical_id": "HelloWorldFunction", "working_directory": working_directory}, | ||
| ) | ||
| dependencies_installed = { | ||
| "chardet", | ||
| "urllib3", | ||
| "idna", | ||
| "urllib3-1.25.11.dist-info", | ||
| "chardet-3.0.4.dist-info", | ||
| "certifi-2020.4.5.2.dist-info", | ||
| "certifi", | ||
| "idna-2.10.dist-info", | ||
| "requests", | ||
| "requests-2.23.0.dist-info", | ||
| } | ||
|
|
||
| expected_files = self.test_data_files.union(dependencies_installed) | ||
| output_files = set(os.listdir(self.artifacts_dir)) | ||
| self.assertEqual(expected_files, output_files) | ||
|
|
||
| def test_must_build_python_project_through_makefile_unknown_target(self): | ||
| with self.assertRaises(WorkflowFailedError): | ||
| self.builder.build( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| build-HelloWorldFunction: | ||
| cp *.py $(ARTIFACTS_DIR) | ||
| cp requirements-requests.txt $(ARTIFACTS_DIR) | ||
| python -m pip install -r requirements-requests.txt -t $(ARTIFACTS_DIR) | ||
| rm -rf $(ARTIFACTS_DIR)/bin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import requests | ||
|
|
||
|
|
||
| def lambda_handler(event, context): | ||
| # Just return the requests version. | ||
| return "{}".format(requests.__version__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| requests==2.23.0 | ||
|
|
||
| # Pinning so the test can expect a given version | ||
| certifi==2020.4.5.2 # dep of requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this implied behavior? we should document that in the docstring as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the current default behaviour. Custom builder run against the scratch_dir, so if there is no working_directory passed by the customers, we should use the current default behaviour. I updated the docstring.