Skip to content
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

feat: Add zip method #68

Merged
merged 13 commits into from
Mar 19, 2024
Merged

feat: Add zip method #68

merged 13 commits into from
Mar 19, 2024

Conversation

tianfeng92
Copy link
Contributor

One-line summary

Add zip method: this method receives source directory and destination file and zips file accordingly.

@tianfeng92 tianfeng92 marked this pull request as ready for review March 18, 2024 17:37
@tianfeng92 tianfeng92 requested a review from a team as a code owner March 18, 2024 17:37
@tianfeng92 tianfeng92 requested a review from alexplischke March 18, 2024 21:05
Co-authored-by: Alex Plischke <alex.plischke@saucelabs.com>
@tianfeng92 tianfeng92 requested a review from alexplischke March 18, 2024 22:45
@tianfeng92 tianfeng92 requested a review from alexplischke March 18, 2024 22:57
@tianfeng92 tianfeng92 merged commit 10a0db3 into main Mar 19, 2024
1 check passed
@tianfeng92 tianfeng92 deleted the DEVX-2680 branch March 19, 2024 15:27
Comment on lines +113 to +115
console.error(
`Zip file creation failed for destination: "${dest}", source: "${source}". Error: ${error}.`,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I'm hung up on is whether or not its better to let whoever is invoking the function to print the error. Printing to console is a user facing behaviour and having a low level utility function do that seems more surprising than just throwing the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, added this comment, but forgot to submit the review. Fine to disregard, but still wanted to bring it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that an error thrown by a low-level function may be unexpected. However, given that the zipping behavior is determined by user settings in the sauce configuration, such an error could be understandable and helpful.
It allows users to debug and modify their configuration as necessary. This is different from generating JUnit or Sauce reports, where a failure could be misinterpreted as a test failure, as those operations are not directly controlled by the user.

Choose a reason for hiding this comment

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

@tianfeng92 Mike is talking about removing this log line and instead throwing the error all the way back to the caller (the runner in that case). The caller (runner) is then the one to handle (i.e. log) the error.

Choose a reason for hiding this comment

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

Oops, added this comment, but forgot to submit the review. Fine to disregard, but still wanted to bring it up.

Now that you bring this up, I'd personally prefer that approach. Generally I'm in favor of keeping user facing messaging out of low level libs. Having user facing messages in low level libs, prevents the lib from being used more broadly and robs the caller of controlling what the user should see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense. Let me draft a PR to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants