Skip to content

feat: implement build in source for custom make #417

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

Merged
merged 7 commits into from
Dec 20, 2022

Conversation

torresxb1
Copy link
Contributor

@torresxb1 torresxb1 commented Dec 15, 2022

Issue #, if available:

Description of changes:
Adds the ability to build in source for custom make.

Note: This was branched off another PR: #416. While the parent PR is not merged in, those changes will also show up in this PR's diff. See this PR's actual changes here: torresxb1/aws-lambda-builders@in-source-entry...torresxb1:aws-lambda-builders:in-source-custom-make

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@torresxb1 torresxb1 requested a review from a team as a code owner December 15, 2022 00:31
@torresxb1 torresxb1 requested review from mildaniel and removed request for hawflau December 15, 2022 16:56
Copy link
Contributor

@mildaniel mildaniel left a comment

Choose a reason for hiding this comment

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

Thanks Rup, looks good. Can we just get a small unit test for the new _get_working_directory function 🙏

@lucashuy
Copy link
Contributor

Looks good to me, will defer to Daniel's comments

@torresxb1
Copy link
Contributor Author

Thanks Rup, looks good. Can we just get a small unit test for the new _get_working_directory function 🙏

@mildaniel This is actually something I've gone back and forth on in the past and still unsure about: should we unit test private functions or only public? It seems like it's a topic that has people on both sides, eg.: https://stackoverflow.com/questions/105007/should-i-test-private-methods-or-only-public-ones

In this case, I tested _get_working_directory indirectly by adding tests for the workflow itself (test_build_in_source and test_build_in_source_with_custom_working_directory). I have tested private functions before, so I haven't been consistent with this either. Is there a consensus on where the team stands on this?

The main point I see for not testing private functions is that we'd be testing implementation details rather than behaviour, and also refactoring private functions could mean updating unit tests even if the public behaviour didn't change.

@mildaniel
Copy link
Contributor

mildaniel commented Dec 15, 2022

My opinion is that all functions should be unit tested, public or private. I see both arguments, but I think it's a lot easier to cover edge cases on a granular level for each function than it is to try to cover every possible case on a macro level. If we have a module where only 5% of the code is exposed publicly, it's very difficult to write tests to cover all possible scenarios indirectly for the other 95% of code. Very quickly number of cases a higher level test needs to cover grows exponentially and it becomes impossible to thoroughly test the code. Testing coverage will then decrease, and ultimately so will the quality of the tests.

This is just my opinion though, so I'm happy to hear what others think.

manifest_path,
osutils=self.os_utils,
subprocess_make=subprocess_make,
build_logical_id=build_logical_id,
working_directory=working_directory,
)

self.actions = [CopySourceAction(source_dir, scratch_dir, excludes=self.EXCLUDED_FILES), make_action]
self.actions = []
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we still do a list comprehension here? for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how, given that one item is only added conditionally 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

self.actions = [CopySrc(...), make_action] if .... else [make_action]

Copy link
Contributor

Choose a reason for hiding this comment

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

Approving without blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merging without this change as I'm not sure if it improves readability and I feel like it wouldn't be able to nicely handle adding more conditional actions in the future.

@torresxb1
Copy link
Contributor Author

torresxb1 commented Dec 15, 2022

@mildaniel I see your point and I feel like that's one of the reasons I might've tested private functions before. Let me bring it up to the team to see if there's strong opinions. Won't block it on this, but I'll see if there's some consensus.

@torresxb1 torresxb1 requested a review from sriram-mv December 16, 2022 01:20
@torresxb1 torresxb1 force-pushed the in-source-custom-make branch from 3c92f1a to c921308 Compare December 16, 2022 19:14
manifest_path,
osutils=self.os_utils,
subprocess_make=subprocess_make,
build_logical_id=build_logical_id,
working_directory=working_directory,
)

self.actions = [CopySourceAction(source_dir, scratch_dir, excludes=self.EXCLUDED_FILES), make_action]
self.actions = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Approving without blocking.

@torresxb1 torresxb1 force-pushed the in-source-custom-make branch from c921308 to d8279c6 Compare December 20, 2022 18:50
@torresxb1 torresxb1 enabled auto-merge (squash) December 20, 2022 19:00
@torresxb1 torresxb1 merged commit ef4ab58 into aws:develop Dec 20, 2022
@torresxb1 torresxb1 deleted the in-source-custom-make branch December 20, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants